mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-14 02:37:21 +00:00
lib: more zclient fixes; str termination, vrfs...
* Don't crash if we get a request to create an existing VRF * Ensure interface & vrf names are null terminated...again Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
This commit is contained in:
parent
229d0d4edc
commit
f17a9d0a07
@ -1714,15 +1714,23 @@ stream_failure:
|
||||
static int zclient_vrf_add(struct zclient *zclient, vrf_id_t vrf_id)
|
||||
{
|
||||
struct vrf *vrf;
|
||||
char vrfname_tmp[VRF_NAMSIZ];
|
||||
char vrfname_tmp[VRF_NAMSIZ + 1] = {};
|
||||
struct vrf_data data;
|
||||
|
||||
STREAM_GET(&data, zclient->ibuf, sizeof(struct vrf_data));
|
||||
/* Read interface name. */
|
||||
STREAM_GET(vrfname_tmp, zclient->ibuf, VRF_NAMSIZ);
|
||||
|
||||
if (strlen(vrfname_tmp) == 0)
|
||||
goto stream_failure;
|
||||
|
||||
/* Lookup/create vrf by vrf_id. */
|
||||
vrf = vrf_get(vrf_id, vrfname_tmp);
|
||||
|
||||
/* Maybe it already exists? */
|
||||
if (!vrf && vrf_get(vrf_id, NULL) != NULL)
|
||||
return 0;
|
||||
|
||||
vrf->data.l.table_id = data.l.table_id;
|
||||
memcpy(vrf->data.l.netns_name, data.l.netns_name, NS_NAMSIZ);
|
||||
/* overwrite default vrf */
|
||||
@ -1790,7 +1798,7 @@ stream_failure:
|
||||
struct interface *zebra_interface_state_read(struct stream *s, vrf_id_t vrf_id)
|
||||
{
|
||||
struct interface *ifp;
|
||||
char ifname_tmp[INTERFACE_NAMSIZ];
|
||||
char ifname_tmp[INTERFACE_NAMSIZ + 1] = {};
|
||||
|
||||
/* Read interface name. */
|
||||
STREAM_GET(ifname_tmp, s, INTERFACE_NAMSIZ);
|
||||
@ -1975,6 +1983,10 @@ static int zebra_interface_if_set_value(struct stream *s, struct interface *ifp)
|
||||
|
||||
/* Read interface's index. */
|
||||
STREAM_GETL(s, ifp_tmp.ifindex);
|
||||
|
||||
if (ifp_tmp.ifindex < 0)
|
||||
goto stream_failure;
|
||||
|
||||
STREAM_GETC(s, ifp_tmp.status);
|
||||
|
||||
/* Read interface's value. */
|
||||
@ -2304,7 +2316,7 @@ struct interface *zebra_interface_vrf_update_read(struct stream *s,
|
||||
vrf_id_t vrf_id,
|
||||
vrf_id_t *new_vrf_id)
|
||||
{
|
||||
char ifname[INTERFACE_NAMSIZ];
|
||||
char ifname[INTERFACE_NAMSIZ + 1] = {};
|
||||
struct interface *ifp;
|
||||
vrf_id_t new_id;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user