From: Hartmut Holzgraefe Date: Mon, 24 Feb 2003 13:35:07 +0000 (+0000) Subject: "key" has to be zero-delimited X-Git-Tag: RELEASE_0_5~789 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=cfb377ce3302250e23a5f039f2580fddb1649fe7;p=php "key" has to be zero-delimited --- diff --git a/ext/yp/yp.c b/ext/yp/yp.c index 7fda2f0e04..8706ccffb2 100644 --- a/ext/yp/yp.c +++ b/ext/yp/yp.c @@ -295,8 +295,17 @@ static int php_foreach_cat (int instatus, char *inkey, int inkeylen, char *inval 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; }