Browse Source

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).
pull/222/head
Matthias Schiffer 3 years ago
parent
commit
593b2c6266
No known key found for this signature in database GPG Key ID: 16EF3F64CB201D9C
  1. 4
      net/respondd/src/respondd.c

4
net/respondd/src/respondd.c

@ -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;

Loading…
Cancel
Save