respondd: fix incorrect use of strncpy

Fortunately, the destination buffer is always big enough, so no buffer
overflow can happen. Use memcpy instead of strncpy to make this explicit
(and slightly more efficient).
This commit is contained in:
Matthias Schiffer 2019-04-21 18:20:16 +02:00
parent 31eb441db1
commit 593b2c6266
No known key found for this signature in database
GPG Key ID: 16EF3F64CB201D9C
1 changed files with 2 additions and 2 deletions

View File

@ -612,9 +612,9 @@ static void accept_request(struct request_schedule *schedule, int sock,
}
struct request_task *new_task = malloc(sizeof(*new_task));
// input_bytes cannot be greater than REQUEST_MAXLEN-1
memcpy(new_task->request, input, input_bytes + 1);
new_task->scheduled_time = 0;
strncpy(new_task->request, input, input_bytes + 1);
new_task->request[input_bytes] = 0;
new_task->client_addr = addr;
bool is_scheduled;