Message ID | 1412031245-4709-1-git-send-email-mike.holmes@linaro.org |
---|---|
State | Accepted |
Commit | 0e0bcce3b624c3a5afc0cca6b4d02ae940bbe47f |
Headers | show |
ping - any comments ? On 29 September 2014 18:54, Mike Holmes <mike.holmes@linaro.org> wrote: > The buffer is not null terminated for ethreq.ifr_name if strncpy is passed > the maxsize of 16 and if netdev is not null terminated within that size. > > Signed-off-by: Mike Holmes <mike.holmes@linaro.org> > --- > platform/linux-generic/odp_packet_socket.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/platform/linux-generic/odp_packet_socket.c > b/platform/linux-generic/odp_packet_socket.c > index 279a0cb..844504a 100644 > --- a/platform/linux-generic/odp_packet_socket.c > +++ b/platform/linux-generic/odp_packet_socket.c > @@ -229,7 +229,7 @@ int setup_pkt_sock(pkt_sock_t *const pkt_sock, const > char *netdev, > > /* get MAC address */ > memset(ðreq, 0, sizeof(ethreq)); > - strncpy(ethreq.ifr_name, netdev, IFNAMSIZ); > + strncpy(ethreq.ifr_name, netdev, IFNAMSIZ-1); > err = ioctl(sockfd, SIOCGIFHWADDR, ðreq); > if (err != 0) { > perror("setup_pkt_sock() - ioctl(SIOCGIFHWADDR)"); > @@ -785,7 +785,7 @@ static int mmap_store_hw_addr(pkt_sock_mmap_t *const > pkt_sock, > > /* get MAC address */ > memset(ðreq, 0, sizeof(ethreq)); > - strncpy(ethreq.ifr_name, netdev, IFNAMSIZ); > + strncpy(ethreq.ifr_name, netdev, IFNAMSIZ-1); > ret = ioctl(pkt_sock->sockfd, SIOCGIFHWADDR, ðreq); > if (ret != 0) { > perror("store_hw_addr() - ioctl(SIOCGIFHWADDR)"); > -- > 1.9.1 > >
Merged, thanks! Maxim. On 10/02/2014 03:35 PM, Mike Holmes wrote: > ping - any comments ? > > On 29 September 2014 18:54, Mike Holmes <mike.holmes@linaro.org > <mailto:mike.holmes@linaro.org>> wrote: > > The buffer is not null terminated for ethreq.ifr_name if strncpy > is passed > the maxsize of 16 and if netdev is not null terminated within that > size. > > Signed-off-by: Mike Holmes <mike.holmes@linaro.org > <mailto:mike.holmes@linaro.org>> > --- > platform/linux-generic/odp_packet_socket.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/platform/linux-generic/odp_packet_socket.c > b/platform/linux-generic/odp_packet_socket.c > index 279a0cb..844504a 100644 > --- a/platform/linux-generic/odp_packet_socket.c > +++ b/platform/linux-generic/odp_packet_socket.c > @@ -229,7 +229,7 @@ int setup_pkt_sock(pkt_sock_t *const pkt_sock, > const char *netdev, > > /* get MAC address */ > memset(ðreq, 0, sizeof(ethreq)); > - strncpy(ethreq.ifr_name, netdev, IFNAMSIZ); > + strncpy(ethreq.ifr_name, netdev, IFNAMSIZ-1); > err = ioctl(sockfd, SIOCGIFHWADDR, ðreq); > if (err != 0) { > perror("setup_pkt_sock() - ioctl(SIOCGIFHWADDR)"); > @@ -785,7 +785,7 @@ static int mmap_store_hw_addr(pkt_sock_mmap_t > *const pkt_sock, > > /* get MAC address */ > memset(ðreq, 0, sizeof(ethreq)); > - strncpy(ethreq.ifr_name, netdev, IFNAMSIZ); > + strncpy(ethreq.ifr_name, netdev, IFNAMSIZ-1); > ret = ioctl(pkt_sock->sockfd, SIOCGIFHWADDR, ðreq); > if (ret != 0) { > perror("store_hw_addr() - ioctl(SIOCGIFHWADDR)"); > -- > 1.9.1 > > > > > -- > *Mike Holmes* > Linaro Sr Technical Manager > LNG - ODP > > > _______________________________________________ > lng-odp mailing list > lng-odp@lists.linaro.org > http://lists.linaro.org/mailman/listinfo/lng-odp
diff --git a/platform/linux-generic/odp_packet_socket.c b/platform/linux-generic/odp_packet_socket.c index 279a0cb..844504a 100644 --- a/platform/linux-generic/odp_packet_socket.c +++ b/platform/linux-generic/odp_packet_socket.c @@ -229,7 +229,7 @@ int setup_pkt_sock(pkt_sock_t *const pkt_sock, const char *netdev, /* get MAC address */ memset(ðreq, 0, sizeof(ethreq)); - strncpy(ethreq.ifr_name, netdev, IFNAMSIZ); + strncpy(ethreq.ifr_name, netdev, IFNAMSIZ-1); err = ioctl(sockfd, SIOCGIFHWADDR, ðreq); if (err != 0) { perror("setup_pkt_sock() - ioctl(SIOCGIFHWADDR)"); @@ -785,7 +785,7 @@ static int mmap_store_hw_addr(pkt_sock_mmap_t *const pkt_sock, /* get MAC address */ memset(ðreq, 0, sizeof(ethreq)); - strncpy(ethreq.ifr_name, netdev, IFNAMSIZ); + strncpy(ethreq.ifr_name, netdev, IFNAMSIZ-1); ret = ioctl(pkt_sock->sockfd, SIOCGIFHWADDR, ðreq); if (ret != 0) { perror("store_hw_addr() - ioctl(SIOCGIFHWADDR)");
The buffer is not null terminated for ethreq.ifr_name if strncpy is passed the maxsize of 16 and if netdev is not null terminated within that size. Signed-off-by: Mike Holmes <mike.holmes@linaro.org> --- platform/linux-generic/odp_packet_socket.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)