Re: [PHP-CVS] cvs: non-pecl /simple_cvs simple_cvs.c simple_cvs_defs.h simple_cvs_utils.c
Hello Shie, Tuesday, April 20, 2004, 9:30:41 AM, you wrote: > shie Tue Apr 20 03:30:41 2004 EDT > Modified files: > /non-pecl/simple_cvs simple_cvs.c simple_cvs_defs.h > simple_cvs_utils.c > Log: > fixed: sprintf==>snprintf (thanks to derick) @@ -417,7 +416,7 @@ Please use the SCVS_STAT_* constants to check for statuses */ PHP_FUNCTION(scvs_status) { - char *un, buf[1024]; + char *un, buf[BUFSIZE]; int un_len; if (ZEND_NUM_ARGS() != 1 || @@ -435,7 +434,7 @@ if(array_init(return_value) != SUCCESS) zend_error(E_ERROR, "unable to create array"); /* chdir into the module dir - thereby performing the MINIMAL sanity check */ - sprintf(buf, "%s/%s", GGET(workingDir), GGET(moduleName)); + snprintf(buf, BUFSIZE, "%s/%s", GGET(workingDir), GGET(moduleName)); if (chdir(buf) != 0) { [...] This pretty much looks like spprintf would be correct. -- Best regards, Marcusmailto:[EMAIL PROTECTED] -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: non-pecl /simple_cvs simple_cvs.c simple_cvs_defs.h simple_cvs_utils.c
shieTue Apr 20 03:30:41 2004 EDT Modified files: /non-pecl/simple_cvssimple_cvs.c simple_cvs_defs.h simple_cvs_utils.c Log: fixed: sprintf==>snprintf (thanks to derick) http://cvs.php.net/diff.php/non-pecl/simple_cvs/simple_cvs.c?r1=1.3&r2=1.4&ty=u Index: non-pecl/simple_cvs/simple_cvs.c diff -u non-pecl/simple_cvs/simple_cvs.c:1.3 non-pecl/simple_cvs/simple_cvs.c:1.4 --- non-pecl/simple_cvs/simple_cvs.c:1.3Mon Apr 19 11:50:18 2004 +++ non-pecl/simple_cvs/simple_cvs.cTue Apr 20 03:30:40 2004 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: simple_cvs.c,v 1.3 2004/04/19 15:50:18 shie Exp $ */ +/* $Id: simple_cvs.c,v 1.4 2004/04/20 07:30:40 shie Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -62,7 +62,6 @@ PHP_FE(scvs_set_cvsroot,NULL) PHP_FE(scvs_set_module_name,NULL) PHP_FE(scvs_set_working_dir, NULL) - PHP_FE(scvs_set_cvsroot,NULL) {NULL, NULL, NULL} /* Must be the last line in simple_cvs_functions[] */ }; /* }}} */ @@ -417,7 +416,7 @@ Please use the SCVS_STAT_* constants to check for statuses */ PHP_FUNCTION(scvs_status) { - char *un, buf[1024]; + char *un, buf[BUFSIZE]; int un_len; if (ZEND_NUM_ARGS() != 1 || @@ -435,7 +434,7 @@ if(array_init(return_value) != SUCCESS) zend_error(E_ERROR, "unable to create array"); /* chdir into the module dir - thereby performing the MINIMAL sanity check */ - sprintf(buf, "%s/%s", GGET(workingDir), GGET(moduleName)); + snprintf(buf, BUFSIZE, "%s/%s", GGET(workingDir), GGET(moduleName)); if (chdir(buf) != 0) { zend_error(E_WARNING, "No module folder. please checkout first"); return; @@ -514,7 +513,7 @@ } /* chdir into the module dir - thereby performing the MINIMAL sanity check */ - sprintf(buf, "%s/%s", GGET(workingDir), GGET(moduleName)); + snprintf(buf, BUFSIZE, "%s/%s", GGET(workingDir), GGET(moduleName)); if (chdir(buf) != 0) { zend_error(E_WARNING, "No module folder. please checkout first"); return; @@ -543,7 +542,7 @@ } /* chdir into the module dir - thereby performing the MINIMAL sanity check */ - sprintf(buf, "%s/%s", GGET(workingDir), GGET(moduleName)); + snprintf(buf, BUFSIZE, "%s/%s", GGET(workingDir), GGET(moduleName)); if (chdir(buf) != 0) { zend_error(E_WARNING, "No module folder. please checkout first"); return; @@ -573,7 +572,7 @@ } /* chdir into the module dir - thereby performing the MINIMAL sanity check */ - sprintf(buf, "%s/%s", GGET(workingDir), GGET(moduleName)); + snprintf(buf, BUFSIZE, "%s/%s", GGET(workingDir), GGET(moduleName)); if (chdir(buf) != 0) { zend_error(E_WARNING, "No module folder. please checkout first"); return; http://cvs.php.net/diff.php/non-pecl/simple_cvs/simple_cvs_defs.h?r1=1.1&r2=1.2&ty=u Index: non-pecl/simple_cvs/simple_cvs_defs.h diff -u non-pecl/simple_cvs/simple_cvs_defs.h:1.1 non-pecl/simple_cvs/simple_cvs_defs.h:1.2 --- non-pecl/simple_cvs/simple_cvs_defs.h:1.1 Wed Apr 14 12:42:41 2004 +++ non-pecl/simple_cvs/simple_cvs_defs.h Tue Apr 20 03:30:40 2004 @@ -15,6 +15,8 @@ | Author: | +--+ */ +#define BUFSIZE1024 + #define CVS_BINARY "/usr/bin/cvs" #define CMD_CHECKOUT "checkout" http://cvs.php.net/diff.php/non-pecl/simple_cvs/simple_cvs_utils.c?r1=1.1&r2=1.2&ty=u Index: non-pecl/simple_cvs/simple_cvs_utils.c diff -u non-pecl/simple_cvs/simple_cvs_utils.c:1.1 non-pecl/simple_cvs/simple_cvs_utils.c:1.2 --- non-pecl/simple_cvs/simple_cvs_utils.c:1.1 Wed Apr 14 12:42:41 2004 +++ non-pecl/simple_cvs/simple_cvs_utils.c Tue Apr 20 03:30:40 2004 @@ -99,9 +99,8 @@ /* perform a pserver login job, using 'pass' as password */ int cvs_pserver_login_job(char *pass) { -#define MAXBUF 1024 int pid, ret=1, status; - char *args[6], *buf[MAXBUF]; + char *args[6], *buf[BUFSIZE]; struct termios ttyconf; struct winsize win; int n, master, slave; @@ -119,9 +118,9 @@ /* allocate memory as needed, and create the command line */ args[0] = CVS_BINARY; args[1] = emalloc(sizeof(char)*4); /* only for "-zX" */ - sprintf(args[1], "-z%d", GGET(compressionLevel)); + snprintf(args[1], (sizeof(char)*4),"-z%d", GGET(compressionLevel)); args[2] = emalloc(sizeof(char)*1024); /* to be on the safe side */ - sprintf(args[2], "-d:pserver:[EMAIL PROTECTED]:%s", GGET(userName), GGET(host), GGET(cvsRoot)); + snprintf(args[2], (sizeof(char
Re: [PHP-CVS] cvs: non-pecl /simple_cvs simple_cvs.c
On Mon, 19 Apr 2004, Andi Gutmans wrote: > At 12:42 PM 4/19/2004 +0200, Derick Rethans wrote: > >On Mon, 19 Apr 2004, Shie Erlich wrote: > > > > > shie Mon Apr 19 06:35:07 2004 EDT > > > > > > Modified files: > > > /non-pecl/simple_cvs simple_cvs.c > > > Log: > > > fixed: free(NULL) doesn't behave as the manpage says it does > > > >free(NULL) (c library function) is a no-op, but efree(NULL) (zend > >memory alloc thingy) will crash. > > Yeah. I think we shouldn't add that additional if() to efree() and prefer > to leave it as-is. Right, it helps debugging things. Derick -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-CVS] cvs: non-pecl /simple_cvs simple_cvs.c
At 12:42 PM 4/19/2004 +0200, Derick Rethans wrote: On Mon, 19 Apr 2004, Shie Erlich wrote: > shie Mon Apr 19 06:35:07 2004 EDT > > Modified files: > /non-pecl/simple_cvs simple_cvs.c > Log: > fixed: free(NULL) doesn't behave as the manpage says it does free(NULL) (c library function) is a no-op, but efree(NULL) (zend memory alloc thingy) will crash. Yeah. I think we shouldn't add that additional if() to efree() and prefer to leave it as-is. Andi -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-CVS] cvs: non-pecl /simple_cvs simple_cvs.c
On Mon, 19 Apr 2004, Shie Erlich wrote: > shie Mon Apr 19 06:35:07 2004 EDT > > Modified files: > /non-pecl/simple_cvs simple_cvs.c > Log: > fixed: free(NULL) doesn't behave as the manpage says it does free(NULL) (c library function) is a no-op, but efree(NULL) (zend memory alloc thingy) will crash. regards, Derick -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: non-pecl /simple_cvs simple_cvs.c
shieMon Apr 19 06:35:07 2004 EDT Modified files: /non-pecl/simple_cvssimple_cvs.c Log: fixed: free(NULL) doesn't behave as the manpage says it does http://cvs.php.net/diff.php/non-pecl/simple_cvs/simple_cvs.c?r1=1.1&r2=1.2&ty=u Index: non-pecl/simple_cvs/simple_cvs.c diff -u non-pecl/simple_cvs/simple_cvs.c:1.1 non-pecl/simple_cvs/simple_cvs.c:1.2 --- non-pecl/simple_cvs/simple_cvs.c:1.1Wed Apr 14 12:42:41 2004 +++ non-pecl/simple_cvs/simple_cvs.cMon Apr 19 06:35:07 2004 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: simple_cvs.c,v 1.1 2004/04/14 16:42:41 shie Exp $ */ +/* $Id: simple_cvs.c,v 1.2 2004/04/19 10:35:07 shie Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -109,6 +109,7 @@ */ static void init_globals(zend_simple_cvs_globals *simple_cvs_globals) { +/*zend_error(E_WARNING,"init_globals");*/ simple_cvs_globals->host = NULL; simple_cvs_globals->userName = NULL; simple_cvs_globals->moduleName = NULL; @@ -123,6 +124,7 @@ */ PHP_MINIT_FUNCTION(simple_cvs) { +/*zend_error(E_WARNING,"m_init");*/ #ifdef ZTS ZEND_INIT_MODULE_GLOBALS(simple_cvs, NULL, NULL); #endif @@ -155,6 +157,7 @@ */ PHP_MSHUTDOWN_FUNCTION(simple_cvs) { +/*zend_error(E_WARNING,"m_shutdown");*/ UNREGISTER_INI_ENTRIES(); return SUCCESS; @@ -166,6 +169,7 @@ */ PHP_RINIT_FUNCTION(simple_cvs) { +/*zend_error(E_WARNING,"r_init");*/ init_globals(&simple_cvs_globals); return SUCCESS; } @@ -176,11 +180,12 @@ */ PHP_RSHUTDOWN_FUNCTION(simple_cvs) { - efree(GGET(host)); - efree(GGET(userName)); - efree(GGET(moduleName)); - efree(GGET(cvsRoot)); - efree(GGET(workingDir)); +/*zend_error(E_WARNING,"r_shutdown");*/ + if (GGET(host)) efree(GGET(host)); + if (GGET(userName)) efree(GGET(userName)); + if (GGET(moduleName)) efree(GGET(moduleName)); + if (GGET(cvsRoot)) efree(GGET(cvsRoot)); + if (GGET(workingDir)) efree(GGET(workingDir)); return SUCCESS; } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php