cvs: php4 /ext/dba dba.c dba_cdb.c /ext/dba/libcdb cdb_make.c /ext/dba/libflatfile flatfile.c
| From: | Marcus Boerger | Date: | Thu, 24 Apr 2003 20:54:44 +0000 |
| Subject: | cvs: php4 /ext/dba dba.c dba_cdb.c /ext/dba/libcdb cdb_make.c /ext/dba/libflatfile flatfile.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-20474@lists.php.net to get a copy of this message | ||
helly Thu Apr 24 16:54:44 2003 EDT
Modified files:
/php4/ext/dba dba.c dba_cdb.c
/php4/ext/dba/libcdb cdb_make.c
/php4/ext/dba/libflatfile flatfile.c
Log:
MFB: safe_emalloc()
Index: php4/ext/dba/dba.c
diff -u php4/ext/dba/dba.c:1.88 php4/ext/dba/dba.c:1.89
--- php4/ext/dba/dba.c:1.88 Sun Apr 13 15:50:28 2003
+++ php4/ext/dba/dba.c Thu Apr 24 16:54:43 2003
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: dba.c,v 1.88 2003/04/13 19:50:28 helly Exp $ */
+/* $Id: dba.c,v 1.89 2003/04/24 20:54:43 helly Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -525,7 +525,7 @@
}
/* we pass additional args to the respective handler */
- args = emalloc(ac * sizeof(zval *));
+ args = safe_emalloc(ac, sizeof(zval *), 0);
if (zend_get_parameters_array_ex(ac, args) != SUCCESS) {
FREENOW;
WRONG_PARAM_COUNT;
@@ -541,7 +541,8 @@
list_entry *le;
/* calculate hash */
- key = emalloc(keylen);
+ key = safe_emalloc(keylen, 1, 1);
+ key[keylen] = '\0';
keylen = 0;
for(i = 0; i < ac; i++) {
Index: php4/ext/dba/dba_cdb.c
diff -u php4/ext/dba/dba_cdb.c:1.28 php4/ext/dba/dba_cdb.c:1.29
--- php4/ext/dba/dba_cdb.c:1.28 Mon Apr 14 17:50:48 2003
+++ php4/ext/dba/dba_cdb.c Thu Apr 24 16:54:43 2003
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: dba_cdb.c,v 1.28 2003/04/14 21:50:48 helly Exp $ */
+/* $Id: dba_cdb.c,v 1.29 2003/04/24 20:54:43 helly Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -163,7 +163,7 @@
}
}
len = cdb_datalen(&cdb->c);
- new_entry = emalloc(len+1);
+ new_entry = safe_emalloc(len, 1, 1);
if (php_cdb_read(&cdb->c, new_entry, len, cdb_datapos(&cdb->c)) == -1) {
efree(new_entry);
@@ -268,7 +268,7 @@
uint32_unpack(buf, &klen);
uint32_unpack(buf + 4, &dlen);
- key = emalloc(klen + 1);
+ key = safe_emalloc(klen, 1, 1);
if (cdb_file_read(cdb->file, key, klen) < klen) {
efree(key);
key = NULL;
@@ -300,7 +300,7 @@
uint32_unpack(buf, &klen);
uint32_unpack(buf + 4, &dlen);
- key = emalloc(klen + 1);
+ key = safe_emalloc(klen, 1, 1);
if (cdb_file_read(cdb->file, key, klen) < klen) {
efree(key);
key = NULL;
Index: php4/ext/dba/libcdb/cdb_make.c
diff -u php4/ext/dba/libcdb/cdb_make.c:1.5 php4/ext/dba/libcdb/cdb_make.c:1.6
--- php4/ext/dba/libcdb/cdb_make.c:1.5 Tue Dec 31 11:06:25 2002
+++ php4/ext/dba/libcdb/cdb_make.c Thu Apr 24 16:54:43 2003
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: cdb_make.c,v 1.5 2002/12/31 16:06:25 sebastian Exp $ */
+/* $Id: cdb_make.c,v 1.6 2003/04/24 20:54:43 helly Exp $ */
/* incorporated from D.J.Bernstein's cdb-0.75 (http://cr.yp.to/cdb.html)*/
@@ -79,8 +79,7 @@
head = c->head;
if (!head || (head->num >= CDB_HPLIST)) {
- head = (struct cdb_hplist *)
- emalloc(sizeof(struct cdb_hplist));
+ head = (struct cdb_hplist *) emalloc(sizeof(struct cdb_hplist));
if (!head)
return -1;
head->num = 0;
@@ -172,8 +171,7 @@
return -1;
}
- c->split = (struct cdb_hp *)
- emalloc(memsize * sizeof(struct cdb_hp));
+ c->split = (struct cdb_hp *) safe_emalloc(memsize, sizeof(struct cdb_hp), 0);
if (!c->split)
return -1;
@@ -242,5 +240,5 @@
/* {{{ cdb_make_version */
char *cdb_make_version()
{
- return "0.75, $Revision: 1.5 $";
+ return "0.75, $Revision: 1.6 $";
}
Index: php4/ext/dba/libflatfile/flatfile.c
diff -u php4/ext/dba/libflatfile/flatfile.c:1.10 php4/ext/dba/libflatfile/flatfile.c:1.11
--- php4/ext/dba/libflatfile/flatfile.c:1.10 Tue Feb 18 17:19:18 2003
+++ php4/ext/dba/libflatfile/flatfile.c Thu Apr 24 16:54:43 2003
@@ -19,7 +19,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: flatfile.c,v 1.10 2003/02/18 22:19:18 helly Exp $ */
+/* $Id: flatfile.c,v 1.11 2003/04/24 20:54:43 helly Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -91,7 +91,7 @@
if (flatfile_findkey(dba, key_datum TSRMLS_CC)) {
if (php_stream_gets(dba->fp, buf, sizeof(buf))) {
value_datum.dsize = atoi(buf);
- value_datum.dptr = emalloc(value_datum.dsize+1);
+ value_datum.dptr = safe_emalloc(value_datum.dsize, 1, 1);
value_datum.dsize = php_stream_read(dba->fp, value_datum.dptr, value_datum.dsize);
} else {
value_datum.dptr = NULL;
@@ -307,7 +307,7 @@
/* {{{ flatfile_version */
char *flatfile_version()
{
- return "1.0, $Revision: 1.10 $";
+ return "1.0, $Revision: 1.11 $";
}
/* }}} */