From patchwork Mon Sep 29 22:54:05 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Holmes X-Patchwork-Id: 38111 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f198.google.com (mail-lb0-f198.google.com [209.85.217.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 9EF7E202DB for ; Mon, 29 Sep 2014 22:54:35 +0000 (UTC) Received: by mail-lb0-f198.google.com with SMTP id 10sf10441006lbg.9 for ; Mon, 29 Sep 2014 15:54:34 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:date:message-id:subject :precedence:list-id:list-unsubscribe:list-archive:list-post :list-help:list-subscribe:mime-version:errors-to:sender :x-original-sender:x-original-authentication-results:mailing-list :content-type:content-transfer-encoding; bh=I8HQULAR/6fx3rFFljGjw+7rxvold3Lz/8kfaHwVhbo=; b=RjOPBLRxpHjE3+d/Yyg6Wv6JyQg/+PfMT58C5VXUYe0eclA7gENRzHP2vHt4SPXdLc mbk5g5LsPck4ObIaK8DbXaEuAs6Ae1T+HhGVt7EvNgfcXmECRxHGGma2nwdER5Vxvo1P TjVFjPqnmYsxzVQxuwozF8DSGU8h1nI0nec1+mkKRiDOcy0liGaujn4t2/Px7K82DgcW sDwgBT5LL9rlvT0cFDJNxjEvpdjEwAYoIsy5Q/hd8d7nNSIoY638jWP9tKTc1InjDVhx fPxG4CxdzJABULT5cd6XoNlX1UuOEOjLJpnpH+/bxx8ViWs3O9QF0VyGBrNHLHx4d3Er g/Bg== X-Gm-Message-State: ALoCoQnAPhZl6JFlPhmuSUaUwBVvXKoPBfIbLjpbBmdhDAq1wTHv71tf8BpOogvS1eTPg8KdUoZi X-Received: by 10.152.19.131 with SMTP id f3mr6272416lae.0.1412031274329; Mon, 29 Sep 2014 15:54:34 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.1.40 with SMTP id 8ls637346laj.65.gmail; Mon, 29 Sep 2014 15:54:34 -0700 (PDT) X-Received: by 10.112.78.98 with SMTP id a2mr38845128lbx.48.1412031274159; Mon, 29 Sep 2014 15:54:34 -0700 (PDT) Received: from mail-la0-f41.google.com (mail-la0-f41.google.com [209.85.215.41]) by mx.google.com with ESMTPS id o3si20079225laj.62.2014.09.29.15.54.34 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 29 Sep 2014 15:54:34 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.41 as permitted sender) client-ip=209.85.215.41; Received: by mail-la0-f41.google.com with SMTP id pn19so3630597lab.14 for ; Mon, 29 Sep 2014 15:54:34 -0700 (PDT) X-Received: by 10.112.75.233 with SMTP id f9mr5978535lbw.102.1412031273989; Mon, 29 Sep 2014 15:54:33 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.130.169 with SMTP id of9csp255307lbb; Mon, 29 Sep 2014 15:54:33 -0700 (PDT) X-Received: by 10.140.49.71 with SMTP id p65mr67065346qga.54.1412031272843; Mon, 29 Sep 2014 15:54:32 -0700 (PDT) Received: from ip-10-35-177-41.ec2.internal (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTPS id j4si15097595qgf.81.2014.09.29.15.54.31 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Mon, 29 Sep 2014 15:54:32 -0700 (PDT) Received-SPF: none (google.com: lng-odp-bounces@lists.linaro.org does not designate permitted sender hosts) client-ip=54.225.227.206; Received: from localhost ([127.0.0.1] helo=ip-10-35-177-41.ec2.internal) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1XYjpt-0007TJ-Md; Mon, 29 Sep 2014 22:54:29 +0000 Received: from mail-qg0-f47.google.com ([209.85.192.47]) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1XYjpn-0007TC-4k for lng-odp@lists.linaro.org; Mon, 29 Sep 2014 22:54:23 +0000 Received: by mail-qg0-f47.google.com with SMTP id i50so2534774qgf.20 for ; Mon, 29 Sep 2014 15:54:17 -0700 (PDT) X-Received: by 10.224.75.73 with SMTP id x9mr56670647qaj.63.1412031257834; Mon, 29 Sep 2014 15:54:17 -0700 (PDT) Received: from fedora1.holmesfamily.ws ([98.221.136.245]) by mx.google.com with ESMTPSA id v44sm8809480qgv.31.2014.09.29.15.54.17 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 29 Sep 2014 15:54:17 -0700 (PDT) From: Mike Holmes To: lng-odp@lists.linaro.org Date: Mon, 29 Sep 2014 18:54:05 -0400 Message-Id: <1412031245-4709-1-git-send-email-mike.holmes@linaro.org> X-Mailer: git-send-email 1.9.1 X-Topics: patch Subject: [lng-odp] [PATCH] odp_packet_socket.c: Replace strncpy size with size -1 for terminator X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , MIME-Version: 1.0 Errors-To: lng-odp-bounces@lists.linaro.org Sender: lng-odp-bounces@lists.linaro.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: mike.holmes@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.41 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 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 --- 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)");