CVS update: php3/functions
| From: | sas | Date: | Wed, 23 Jun 1999 22:20:32 +0000 |
| Subject: | CVS update: php3/functions | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-7486@lists.php.net to get a copy of this message | ||
Date: Wednesday June 23, 1999 @ 18:20
Author: sas
Update of /repository/php3/functions
In directory php:/tmp/cvs-serv21689
Modified Files:
dbase.c
Log Message:
workaround a bug in the dbase library where db_rlen isn't set
correctly
Index: php3/functions/dbase.c
diff -u php3/functions/dbase.c:1.72 php3/functions/dbase.c:1.73
--- php3/functions/dbase.c:1.72 Fri Jan 1 12:59:08 1999
+++ php3/functions/dbase.c Wed Jun 23 18:20:31 1999
@@ -27,7 +27,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: dbase.c,v 1.72 1999/01/01 17:59:08 zeev Exp $ */
+/* $Id: dbase.c,v 1.73 1999/06/23 22:20:31 sas Exp $ */
#if defined(COMPILE_DL)
#include "dl/phpdl.h"
#endif
@@ -37,6 +37,10 @@
#endif
#include <stdlib.h>
+#ifdef HAVE_SYS_TYPES_H
+#include <sys/types.h>
+#endif
+
#include "php.h"
#include "internal_functions.h"
#include "php3_list.h"
@@ -354,6 +358,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) {
@@ -379,11 +384,17 @@
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) {