mirror of
https://github.com/FRRouting/frr.git
synced 2025-04-30 13:37:17 +02:00
lib: remove strncpy()
use
`checkpatch` has sufficiently annoyed me to fix this. Includes free overflow guard in CSV code. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
This commit is contained in:
parent
84fd92c80e
commit
4606612abe
|
@ -573,7 +573,7 @@ void csv_decode(csv_t *csv, char *inbuf)
|
||||||
log_error("field str malloc failed\n");
|
log_error("field str malloc failed\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
strncpy(rec->record, buf, pos - buf + 1);
|
memcpy(rec->record, buf, MIN(pos - buf + 1, csv->buflen - 1));
|
||||||
}
|
}
|
||||||
rec->rec_len = pos - buf + 1;
|
rec->rec_len = pos - buf + 1;
|
||||||
/* decode record into fields */
|
/* decode record into fields */
|
||||||
|
|
|
@ -3,9 +3,7 @@
|
||||||
* Copyright (C) 2015 Cumulus Networks, Inc.
|
* Copyright (C) 2015 Cumulus Networks, Inc.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
#include <zebra.h>
|
||||||
#include "config.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
@ -450,7 +448,7 @@ ptm_lib_handle_t *ptm_lib_register(char *client_name, ptm_cmd_cb cmd_cb,
|
||||||
hdl = calloc(1, sizeof(*hdl));
|
hdl = calloc(1, sizeof(*hdl));
|
||||||
|
|
||||||
if (hdl) {
|
if (hdl) {
|
||||||
strncpy(hdl->client_name, client_name, PTMLIB_MAXNAMELEN - 1);
|
strlcpy(hdl->client_name, client_name, sizeof(hdl->client_name));
|
||||||
hdl->cmd_cb = cmd_cb;
|
hdl->cmd_cb = cmd_cb;
|
||||||
hdl->notify_cb = notify_cb;
|
hdl->notify_cb = notify_cb;
|
||||||
hdl->response_cb = response_cb;
|
hdl->response_cb = response_cb;
|
||||||
|
|
Loading…
Reference in a new issue