mirror of
https://github.com/curl/curl.git
synced 2026-04-14 22:41:40 +03:00
checksrc: reduce directory-specific exceptions
By making them defaults, then fixing and/or reshuffling remaining exceptions as necessary. - checksrc: ban by default: `snprintf`, `vsnprintf`, `sscanf`, `strtol`. - examples: replace `strtol` with `atoi` to avoid a checksrc exception. - tests/libtest: replace `strtol` with `atol`. - tests/server: replace most `strtol` with `atol`. - tests/server: replace most `strtoul` with `atol`/`atoi`. - tests/server: drop no longer used `util_ultous`. - fix typo in checksrc rules: `vsnprint` -> `vsnprintf`. - update local exceptions. Also: - examples: ban curl printf functions. They're discouraged in user code. - examples: replace curl printf with system printf. Add `snprintf` workaround for <VS2015. - examples/synctime: fix `-Wfloat-equal`. - examples/synctime: exclude for non-Windows and non-UWP Windows. - examples/synctime: build by default. Closes #18823
This commit is contained in:
parent
fff36a360e
commit
45438c8d6f
36 changed files with 124 additions and 142 deletions
|
|
@ -376,6 +376,7 @@ static bool read_data_block(unsigned char *buffer, ssize_t maxlen,
|
|||
|
||||
buffer[5] = '\0';
|
||||
|
||||
/* !checksrc! disable BANNEDFUNC 1 */
|
||||
*buffer_len = (ssize_t)strtol((char *)buffer, NULL, 16);
|
||||
if(*buffer_len > maxlen) {
|
||||
logmsg("Buffer size (%zd bytes) too small for data size error "
|
||||
|
|
@ -1278,9 +1279,7 @@ static int test_sockfilt(int argc, char *argv[])
|
|||
else if(!strcmp("--port", argv[arg])) {
|
||||
arg++;
|
||||
if(argc > arg) {
|
||||
char *endptr;
|
||||
unsigned long ulnum = strtoul(argv[arg], &endptr, 10);
|
||||
server_port = util_ultous(ulnum);
|
||||
server_port = (unsigned short)atol(argv[arg]);
|
||||
arg++;
|
||||
}
|
||||
}
|
||||
|
|
@ -1289,15 +1288,13 @@ static int test_sockfilt(int argc, char *argv[])
|
|||
doing a passive server-style listening. */
|
||||
arg++;
|
||||
if(argc > arg) {
|
||||
char *endptr;
|
||||
unsigned long ulnum = strtoul(argv[arg], &endptr, 10);
|
||||
if((endptr != argv[arg] + strlen(argv[arg])) ||
|
||||
(ulnum < 1025UL) || (ulnum > 65535UL)) {
|
||||
int inum = atoi(argv[arg]);
|
||||
if(inum && ((inum < 1025) || (inum > 65535))) {
|
||||
fprintf(stderr, "sockfilt: invalid --connect argument (%s)\n",
|
||||
argv[arg]);
|
||||
return 0;
|
||||
}
|
||||
server_connectport = util_ultous(ulnum);
|
||||
server_connectport = (unsigned short)inum;
|
||||
arg++;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue