phpdbg: change uses of sprintf into snprintf

This commit is contained in:
Niels Dossche 2024-06-09 19:41:16 +02:00
parent 80d4d406ba
commit 4107cb2eda
2 changed files with 6 additions and 4 deletions

View file

@ -1672,9 +1672,10 @@ phpdbg_out:
if (PHPDBG_G(exec) && strcmp("Standard input code", PHPDBG_G(exec)) == SUCCESS) { /* i.e. execution context has been read from stdin - back it up */ if (PHPDBG_G(exec) && strcmp("Standard input code", PHPDBG_G(exec)) == SUCCESS) { /* i.e. execution context has been read from stdin - back it up */
phpdbg_file_source *data = zend_hash_str_find_ptr(&PHPDBG_G(file_sources), PHPDBG_G(exec), PHPDBG_G(exec_len)); phpdbg_file_source *data = zend_hash_str_find_ptr(&PHPDBG_G(file_sources), PHPDBG_G(exec), PHPDBG_G(exec_len));
backup_phpdbg_compile = zend_string_alloc(data->len + 2, 1); size_t size = data->len + 2;
backup_phpdbg_compile = zend_string_alloc(size, 1);
GC_MAKE_PERSISTENT_LOCAL(backup_phpdbg_compile); GC_MAKE_PERSISTENT_LOCAL(backup_phpdbg_compile);
sprintf(ZSTR_VAL(backup_phpdbg_compile), "?>%.*s", (int) data->len, data->buf); snprintf(ZSTR_VAL(backup_phpdbg_compile), size + 1, "?>%.*s", (int) data->len, data->buf);
} }
zend_try { zend_try {

View file

@ -503,8 +503,9 @@ PHPDBG_API int phpdbg_parse_variable_with_arg(char *input, size_t len, HashTable
keylen = spprintf(&key, 0, ZEND_ULONG_FMT, numkey); keylen = spprintf(&key, 0, ZEND_ULONG_FMT, numkey);
} }
propkey = phpdbg_get_property_key(key); propkey = phpdbg_get_property_key(key);
name = emalloc(i + keylen + 2); namelen = i + keylen + 2;
namelen = sprintf(name, "%.*s%.*s%s", (int) i, input, (int) (keylen - (propkey - key)), propkey, input[len - 1] == ']'?"]":""); name = emalloc(namelen);
namelen = snprintf(name, namelen, "%.*s%.*s%s", (int) i, input, (int) (keylen - (propkey - key)), propkey, input[len - 1] == ']'?"]":"");
if (!strkey) { if (!strkey) {
efree(key); efree(key);
} }