Re: cvs: php4 /ext/yp yp.c
| From: | Andi Gutmans | Date: | Wed, 26 Feb 2003 20:36:48 +0000 |
| Subject: | Re: cvs: php4 /ext/yp yp.c | ||
| References: | 1 | Groups: | php.cvs |
| Request: | Send a blank email to php-cvs+get-19211@lists.php.net to get a copy of this message | ||
Please use strlcpy() instead of strncpy().
At 01:35 PM 2/24/2003 +0000, Hartmut Holzgraefe wrote:
hholzgra Mon Feb 24 08:35:06 2003 EDTModified files:/php4/ext/yp yp.cLog: "key" has to be zero-delimited Index: php4/ext/yp/yp.c diff -u php4/ext/yp/yp.c:1.34 php4/ext/yp/yp.c:1.35--- php4/ext/yp/yp.c:1.34 Fri Jan 24 11:34:18 2003 +++ php4/ext/yp/yp.c Mon Feb 24 08:35:06 2003@@ -16,7 +16,7 @@| Fredrik Ohrn | +----------------------------------------------------------------------+*/ -/* $Id: yp.c,v 1.34 2003/01/24 16:34:18 iliaa Exp $ */ +/* $Id: yp.c,v 1.35 2003/02/24 13:35:06 hholzgra Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -295,8 +295,17 @@if (!err) { - if (inkeylen) - add_assoc_stringl_ex((zval *) indata,inkey,inkeylen,inval,invallen,1); + if (inkeylen) { + char *key = malloc(inkeylen+1); + if(key) { + strncpy(key, inkey, inkeylen); + key[inkeylen] = '\0'; + add_assoc_stringl_ex((zval *) indata, key, inkeylen+1, inval, invallen, 1); + free(key); + } else { + php_error(E_WARNING, "Can't allocate %d bytes for key buffer in yp_cat()"); + } + }return 0; }-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php