summaryrefslogtreecommitdiff
path: root/bgpd/bgp_packet.c
diff options
context:
space:
mode:
Diffstat (limited to 'bgpd/bgp_packet.c')
-rw-r--r--bgpd/bgp_packet.c26
1 files changed, 17 insertions, 9 deletions
diff --git a/bgpd/bgp_packet.c b/bgpd/bgp_packet.c
index b5934fb56e..655a4745cb 100644
--- a/bgpd/bgp_packet.c
+++ b/bgpd/bgp_packet.c
@@ -709,12 +709,15 @@ void bgp_notify_send_with_data(struct peer *peer, uint8_t code,
XMALLOC(MTYPE_TMP, bgp_notify.length * 3);
for (i = 0; i < bgp_notify.length; i++)
if (first) {
- sprintf(c, " %02x", data[i]);
- strcat(bgp_notify.data, c);
+ snprintf(c, sizeof(c), " %02x",
+ data[i]);
+ strlcat(bgp_notify.data, c,
+ bgp_notify.length);
} else {
first = 1;
- sprintf(c, "%02x", data[i]);
- strcpy(bgp_notify.data, c);
+ snprintf(c, sizeof(c), "%02x", data[i]);
+ strlcpy(bgp_notify.data, c,
+ bgp_notify.length);
}
}
bgp_notify_print(peer, &bgp_notify, "sending");
@@ -1700,14 +1703,16 @@ static int bgp_notify_receive(struct peer *peer, bgp_size_t size)
XMALLOC(MTYPE_TMP, bgp_notify.length * 3);
for (i = 0; i < bgp_notify.length; i++)
if (first) {
- sprintf(c, " %02x",
+ snprintf(c, sizeof(c), " %02x",
stream_getc(peer->curr));
- strcat(bgp_notify.data, c);
+ strlcat(bgp_notify.data, c,
+ bgp_notify.length);
} else {
first = 1;
- sprintf(c, "%02x",
- stream_getc(peer->curr));
- strcpy(bgp_notify.data, c);
+ snprintf(c, sizeof(c), "%02x",
+ stream_getc(peer->curr));
+ strlcpy(bgp_notify.data, c,
+ bgp_notify.length);
}
bgp_notify.raw_data = (uint8_t *)peer->notify.data;
}
@@ -2299,6 +2304,9 @@ int bgp_process_packet(struct thread *thread)
__FUNCTION__, peer->host);
break;
default:
+ /* Suppress uninitialized variable warning */
+ mprc = 0;
+ (void)mprc;
/*
* The message type should have been sanitized before
* we ever got here. Receipt of a message with an