mirror of
https://github.com/php/php-src.git
synced 2025-08-15 13:38:49 +02:00
standard: change uses of sprintf into snprintf and zend_string_concat2
This commit is contained in:
parent
a4674654ab
commit
c151d2d135
4 changed files with 6 additions and 8 deletions
|
@ -641,7 +641,7 @@ static uint8_t *php_parserr(uint8_t *cp, uint8_t *end, querybuf *answer, int typ
|
|||
tp[0] = ':';
|
||||
tp++;
|
||||
}
|
||||
tp += sprintf((char*)tp,"%x",s);
|
||||
tp += snprintf((char*)tp, sizeof(name) - (tp - (uint8_t *) name), "%x", s);
|
||||
} else {
|
||||
if (!have_v6_break) {
|
||||
have_v6_break = 1;
|
||||
|
@ -686,7 +686,7 @@ static uint8_t *php_parserr(uint8_t *cp, uint8_t *end, querybuf *answer, int typ
|
|||
tp[0] = ':';
|
||||
tp++;
|
||||
}
|
||||
sprintf((char*)tp, "%x", cp[0] & 0xFF);
|
||||
snprintf((char*)tp, sizeof(name) - (tp - (uint8_t *) name), "%x", cp[0] & 0xFF);
|
||||
} else {
|
||||
if (!have_v6_break) {
|
||||
have_v6_break = 1;
|
||||
|
@ -711,7 +711,7 @@ static uint8_t *php_parserr(uint8_t *cp, uint8_t *end, querybuf *answer, int typ
|
|||
tp[0] = ':';
|
||||
tp++;
|
||||
}
|
||||
tp += sprintf((char*)tp,"%x",s);
|
||||
tp += snprintf((char*)tp, sizeof(name) - (tp - (uint8_t *) name),"%x",s);
|
||||
} else {
|
||||
if (!have_v6_break) {
|
||||
have_v6_break = 1;
|
||||
|
|
|
@ -282,7 +282,7 @@ static void php_parserr(PDNS_RECORD pRec, int type_to_fetch, int store, bool raw
|
|||
tp[0] = ':';
|
||||
tp++;
|
||||
}
|
||||
tp += sprintf((char*)tp,"%x", out[i]);
|
||||
tp += snprintf((char*)tp, sizeof(buf) - (tp - (char *) buf), "%x", out[i]);
|
||||
} else {
|
||||
if (!have_v6_break) {
|
||||
have_v6_break = 1;
|
||||
|
|
|
@ -201,9 +201,7 @@ static zend_string* php_password_bcrypt_hash(const zend_string *password, zend_a
|
|||
}
|
||||
ZSTR_VAL(salt)[ZSTR_LEN(salt)] = 0;
|
||||
|
||||
hash = zend_string_alloc(ZSTR_LEN(salt) + hash_format_len, 0);
|
||||
sprintf(ZSTR_VAL(hash), "%s%s", hash_format, ZSTR_VAL(salt));
|
||||
ZSTR_VAL(hash)[hash_format_len + ZSTR_LEN(salt)] = 0;
|
||||
hash = zend_string_concat2(hash_format, hash_format_len, ZSTR_VAL(salt), ZSTR_LEN(salt));
|
||||
|
||||
zend_string_release_ex(salt, 0);
|
||||
|
||||
|
|
|
@ -3846,7 +3846,7 @@ PHPAPI zend_string *php_addcslashes_str(const char *str, size_t len, const char
|
|||
case '\v': *target++ = 'v'; break;
|
||||
case '\b': *target++ = 'b'; break;
|
||||
case '\f': *target++ = 'f'; break;
|
||||
default: target += sprintf(target, "%03o", (unsigned char) c);
|
||||
default: target += snprintf(target, 4, "%03o", (unsigned char) c);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue