CVS update: php4/ext/dbase

From: Date: Sun, 27 Jun 1999 21:23:17 +0000
Subject: CVS update: php4/ext/dbase
Groups: php.version4 
Request: Send a blank email to php-version4+get-1699@lists.php.net to get a copy of this message
Date: Sunday June 27, 1999 @ 17:23 Author: sas Update of /repository/php4/ext/dbase In directory php:/tmp/cvs-serv28021/ext/dbase Modified Files: dbase.c Log Message: port over from php3 Index: php4/ext/dbase/dbase.c diff -u php4/ext/dbase/dbase.c:1.5 php4/ext/dbase/dbase.c:1.6 --- php4/ext/dbase/dbase.c:1.5 Sun Jun 27 17:15:12 1999 +++ php4/ext/dbase/dbase.c Sun Jun 27 17:23:17 1999 @@ -1,6 +1,6 @@ /* +----------------------------------------------------------------------+ - | PHP HTML Embedded Scripting Language Version 3.0 | + | PHP HTML Embedded Scripting Language Version 4.0 | +----------------------------------------------------------------------+ | Copyright (c) 1997,1998 PHP Development Team (See Credits file) | +----------------------------------------------------------------------+ @@ -32,6 +32,10 @@ #include <stdlib.h> +#ifdef HAVE_SYS_TYPES_H +#include <sys/types.h> +#endif + #include "php.h" #include "safe_mode.h" #include "fopen-wrappers.h" @@ -416,6 +420,7 @@ int dbh_type; dbfield_t *dbf, *cur_f; char *data, *fnp, *str_value; + size_t cursize = 0; DBase_TLS_VARS; if (ARG_COUNT(ht) != 2 || getParameters(ht,2,&dbh_id,&record)==FAILURE) { @@ -441,11 +446,16 @@ RETURN_FALSE; } - fnp = (char *)emalloc(dbh->db_rlen); + fnp = NULL; for (cur_f = dbf; cur_f < &dbf[dbh->db_nfields]; cur_f++) { /* get the value */ str_value = (char *)emalloc(cur_f->db_flen + 1); - sprintf(str_value, cur_f->db_format, get_field_val(data, cur_f, fnp)); + + if(cursize <= cur_f->db_flen) { + cursize = cur_f->db_flen + 1; + fnp = erealloc(fnp, cursize); + } + snprintf(str_value, cursize, cur_f->db_format, get_field_val(data, cur_f, fnp)); /* now convert it to the right php internal type */ switch (cur_f->db_type) {

« previous php.version4 (#1699) next »