mirror of
https://github.com/morgan9e/UxPlay
synced 2026-04-15 00:34:05 +09:00
replace sprintf by snprintf (silence warning by macOS compiler)
This commit is contained in:
@@ -276,14 +276,19 @@ http_request_get_header_string(http_request_t *request, char **header_str)
|
||||
assert(str);
|
||||
*header_str = str;
|
||||
char *p = str;
|
||||
int n = sizeof(str);
|
||||
for (int i = 0; i < request->headers_size; i++) {
|
||||
sprintf(p,"%s", request->headers[i]);
|
||||
p += strlen(request->headers[i]);
|
||||
int hlen = strlen(request->headers[i]);
|
||||
snprintf(p, n, "%s", request->headers[i]);
|
||||
n -= hlen;
|
||||
p += hlen;
|
||||
if (i%2 == 0) {
|
||||
sprintf(p, ": ");
|
||||
p +=2;
|
||||
snprintf(p, n, ": ");
|
||||
n -= 2;
|
||||
p += 2;
|
||||
} else {
|
||||
sprintf(p, "\n");
|
||||
snprintf(p, n, "\n");
|
||||
n--;
|
||||
p++;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user