Message ID | 1413575257-40398-1-git-send-email-mike.holmes@linaro.org |
---|---|
State | Accepted |
Commit | ee2ee879247668fcc8bb715f3513ed708d74751d |
Headers | show |
merged! Maxim. On 10/17/2014 11:47 PM, Mike Holmes wrote: > Termination of the string is not assured unless the string is > one char shorter than the buffer. > > Signed-off-by: Mike Holmes <mike.holmes@linaro.org> > --- > platform/linux-generic/odp_packet_socket.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/platform/linux-generic/odp_packet_socket.c b/platform/linux-generic/odp_packet_socket.c > index 006d7bd..da9b5a0 100644 > --- a/platform/linux-generic/odp_packet_socket.c > +++ b/platform/linux-generic/odp_packet_socket.c > @@ -219,7 +219,7 @@ int setup_pkt_sock(pkt_sock_t *const pkt_sock, const char *netdev, > > /* get if index */ > memset(ðreq, 0, sizeof(struct ifreq)); > - strncpy(ethreq.ifr_name, netdev, IFNAMSIZ); > + strncpy(ethreq.ifr_name, netdev, IFNAMSIZ-1); > err = ioctl(sockfd, SIOCGIFINDEX, ðreq); > if (err != 0) { > perror("setup_pkt_sock() - ioctl(SIOCGIFINDEX)");
diff --git a/platform/linux-generic/odp_packet_socket.c b/platform/linux-generic/odp_packet_socket.c index 006d7bd..da9b5a0 100644 --- a/platform/linux-generic/odp_packet_socket.c +++ b/platform/linux-generic/odp_packet_socket.c @@ -219,7 +219,7 @@ int setup_pkt_sock(pkt_sock_t *const pkt_sock, const char *netdev, /* get if index */ memset(ðreq, 0, sizeof(struct ifreq)); - strncpy(ethreq.ifr_name, netdev, IFNAMSIZ); + strncpy(ethreq.ifr_name, netdev, IFNAMSIZ-1); err = ioctl(sockfd, SIOCGIFINDEX, ðreq); if (err != 0) { perror("setup_pkt_sock() - ioctl(SIOCGIFINDEX)");
Termination of the string is not assured unless the string is one char shorter than the buffer. Signed-off-by: Mike Holmes <mike.holmes@linaro.org> --- platform/linux-generic/odp_packet_socket.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)