mirror of
https://github.com/curl/curl.git
synced 2026-04-14 22:31:41 +03:00
tests/server: replace banned functions with curlx_str_hex
Replace an `strtol()` and `strtoul()` call, both used in hex mode, with
`curlx_str_hex()`.
Follow-up to 45438c8d6f #18823
Closes #18837
This commit is contained in:
parent
4116e1d802
commit
eaf66f18b7
2 changed files with 15 additions and 10 deletions
|
|
@ -371,13 +371,20 @@ static void lograw(unsigned char *buffer, ssize_t len)
|
|||
static bool read_data_block(unsigned char *buffer, ssize_t maxlen,
|
||||
ssize_t *buffer_len)
|
||||
{
|
||||
curl_off_t value;
|
||||
const char *endp;
|
||||
|
||||
if(!read_stdin(buffer, 5))
|
||||
return FALSE;
|
||||
|
||||
buffer[5] = '\0';
|
||||
|
||||
/* !checksrc! disable BANNEDFUNC 1 */
|
||||
*buffer_len = (ssize_t)strtol((char *)buffer, NULL, 16);
|
||||
endp = (char *)buffer;
|
||||
if(curlx_str_hex(&endp, &value, 0xfffff)) {
|
||||
logmsg("Failed to decode buffer size");
|
||||
return FALSE;
|
||||
}
|
||||
*buffer_len = (ssize_t)value;
|
||||
if(*buffer_len > maxlen) {
|
||||
logmsg("Buffer size (%zd bytes) too small for data size error "
|
||||
"(%zd bytes)", maxlen, *buffer_len);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue