[PHP-CVS] cvs: php-src(PHP_5_2) /ext/dbase dbf_head.c
felipe Sat Jan 17 17:21:49 2009 UTC Modified files: (Branch: PHP_5_2) /php-src/ext/dbase dbf_head.c Log: - Fixed bug #46282 (Corrupt DBF When Using DATE) Patch by: arne at bukkie dot nl http://cvs.php.net/viewvc.cgi/php-src/ext/dbase/dbf_head.c?r1=1.14.4.1.2.8&r2=1.14.4.1.2.9&diff_format=u Index: php-src/ext/dbase/dbf_head.c diff -u php-src/ext/dbase/dbf_head.c:1.14.4.1.2.8 php-src/ext/dbase/dbf_head.c:1.14.4.1.2.9 --- php-src/ext/dbase/dbf_head.c:1.14.4.1.2.8 Sun Nov 18 14:20:17 2007 +++ php-src/ext/dbase/dbf_head.cSat Jan 17 17:21:49 2009 @@ -198,12 +198,6 @@ dbfield.dbf_flen[0] = dbf->db_flen; dbfield.dbf_flen[1] = dbf->db_fdc; break; - case 'D': - dbf->db_flen = 8; - break; - case 'L': - dbf->db_flen = 1; - break; default: put_short(dbfield.dbf_flen, dbf->db_flen); } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src(PHP_5_2) /ext/dbase dbf_head.c dbf_rec.c
iliaa Sat Feb 24 18:00:43 2007 UTC Modified files: (Branch: PHP_5_2) /php-src/ext/dbase dbf_head.c dbf_rec.c Log: strncpy() -> strlcpy() http://cvs.php.net/viewvc.cgi/php-src/ext/dbase/dbf_head.c?r1=1.14.4.1.2.4&r2=1.14.4.1.2.5&diff_format=u Index: php-src/ext/dbase/dbf_head.c diff -u php-src/ext/dbase/dbf_head.c:1.14.4.1.2.4 php-src/ext/dbase/dbf_head.c:1.14.4.1.2.5 --- php-src/ext/dbase/dbf_head.c:1.14.4.1.2.4 Sat Feb 24 02:17:24 2007 +++ php-src/ext/dbase/dbf_head.cSat Feb 24 18:00:43 2007 @@ -184,7 +184,7 @@ /* build the on disk field info */ scp = dbf->db_fname; dcp = dbfield.dbf_name; - strncpy(dbfield.dbf_name, dbf->db_fname, DBF_NAMELEN); + strlcpy(dbfield.dbf_name, dbf->db_fname, DBF_NAMELEN); dbfield.dbf_type = dbf->db_type; switch (dbf->db_type) { http://cvs.php.net/viewvc.cgi/php-src/ext/dbase/dbf_rec.c?r1=1.10&r2=1.10.6.1&diff_format=u Index: php-src/ext/dbase/dbf_rec.c diff -u php-src/ext/dbase/dbf_rec.c:1.10 php-src/ext/dbase/dbf_rec.c:1.10.6.1 --- php-src/ext/dbase/dbf_rec.c:1.10Thu Nov 27 10:15:20 2003 +++ php-src/ext/dbase/dbf_rec.c Sat Feb 24 18:00:43 2007 @@ -152,8 +152,7 @@ if ( !cp ) cp = (char *)malloc(flen + 1); if ( cp ) { - strncpy(cp, &rp[fldp->db_foffset], flen); - cp[flen] = 0; + strlcpy(cp, &rp[fldp->db_foffset], flen + 1); } return cp; } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src(PHP_5_2) /ext/dbase dbf_head.c /ext/dbase/tests 002.phpt
tony2001Wed Sep 6 11:34:43 2006 UTC Added files: (Branch: PHP_5_2) /php-src/ext/dbase/tests002.phpt Modified files: /php-src/ext/dbase dbf_head.c Log: fix leaks & uninitialized vars add test http://cvs.php.net/viewvc.cgi/php-src/ext/dbase/dbf_head.c?r1=1.14.4.1.2.2&r2=1.14.4.1.2.3&diff_format=u Index: php-src/ext/dbase/dbf_head.c diff -u php-src/ext/dbase/dbf_head.c:1.14.4.1.2.2 php-src/ext/dbase/dbf_head.c:1.14.4.1.2.3 --- php-src/ext/dbase/dbf_head.c:1.14.4.1.2.2 Tue Aug 8 15:55:27 2006 +++ php-src/ext/dbase/dbf_head.cWed Sep 6 11:34:43 2006 @@ -26,10 +26,14 @@ if ((dbh = (dbhead_t *)calloc(1, sizeof(dbhead_t))) == NULL) return NULL; - if (lseek(fd, 0, 0) < 0) + if (lseek(fd, 0, 0) < 0) { + free(dbh); return NULL; - if ((ret = read(fd, &dbhead, sizeof(dbhead))) < 0) + } + if ((ret = read(fd, &dbhead, sizeof(dbhead))) <= 0) { + free(dbh); return NULL; + } /* build in core info */ dbh->db_fd = fd; @@ -54,6 +58,7 @@ if (gf_retval < 0) { free_dbf_head(dbh); + free(tdbf); return NULL; } if (gf_retval != 2 ) { @@ -89,7 +94,7 @@ free(cur_f->db_format); } } - + free(dbf); free(dbh); } @@ -119,7 +124,7 @@ if (lseek(fd, 0, 0) < 0) return -1; - if ((ret = write(fd, &dbhead, sizeof(dbhead))) < 0) + if ((ret = write(fd, &dbhead, sizeof(dbhead))) <= 0) return -1; return ret; } @@ -132,7 +137,7 @@ struct dbf_dfield dbfield; int ret; - if ((ret = read(dbh->db_fd, &dbfield, sizeof(dbfield))) < 0) { + if ((ret = read(dbh->db_fd, &dbfield, sizeof(dbfield))) <= 0) { return ret; } @@ -192,7 +197,7 @@ } /* now write it out to disk */ - if ((ret = write(dbh->db_fd, &dbfield, sizeof(dbfield))) < 0) { + if ((ret = write(dbh->db_fd, &dbfield, sizeof(dbfield))) <= 0) { return ret; } return 1; @@ -252,21 +257,14 @@ cp = dp; if ((fd = VCWD_OPEN(cp, o_flags|O_BINARY)) < 0) { - cp = (char *)malloc(MAXPATHLEN); /* So where does this get free()'d? -RL */ - strncpy(cp, dp, MAXPATHLEN-5); strcat(cp, ".dbf"); - if ((fd = VCWD_OPEN(cp, o_flags)) < 0) { - free(cp); - perror("open"); - return NULL; - } + return NULL; } if ((dbh = get_dbf_head(fd)) == NULL) { return NULL; } - dbh->db_name = cp; + dbh->db_cur_rec = 0; - return dbh; } http://cvs.php.net/viewvc.cgi/php-src/ext/dbase/tests/002.phpt?view=markup&rev=1.1 Index: php-src/ext/dbase/tests/002.phpt +++ php-src/ext/dbase/tests/002.phpt --TEST-- dbase_open() tests --SKIPIF-- --FILE-- --EXPECTF-- Warning: dbase_open(): unable to open database %s in %s on line %d bool(false) Warning: dbase_open(): unable to open database %s in %s on line %d bool(false) Warning: dbase_open(): unable to open database %s in %s on line %d bool(false) Warning: dbase_open(): unable to open database %s in %s on line %d bool(false) Warning: dbase_open(): unable to open database in %s on line %d bool(false) int(%d) int(%d) Done -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src(PHP_5_2) /ext/dbase dbf_head.c
tony2001Thu May 25 11:46:38 2006 UTC Modified files: (Branch: PHP_5_2) /php-src/ext/dbase dbf_head.c Log: MFH: remove debug output and fix bug #37589 http://cvs.php.net/viewcvs.cgi/php-src/ext/dbase/dbf_head.c?r1=1.14.4.1&r2=1.14.4.1.2.1&diff_format=u Index: php-src/ext/dbase/dbf_head.c diff -u php-src/ext/dbase/dbf_head.c:1.14.4.1 php-src/ext/dbase/dbf_head.c:1.14.4.1.2.1 --- php-src/ext/dbase/dbf_head.c:1.14.4.1 Mon Jan 23 22:42:12 2006 +++ php-src/ext/dbase/dbf_head.cThu May 25 11:46:38 2006 @@ -260,7 +260,6 @@ } if ((dbh = get_dbf_head(fd)) == NULL) { - fprintf(stderr, "Unable to get header\n"); return NULL; } dbh->db_name = cp; -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php