From mboxrd@z Thu Jan 1 00:00:00 1970 From: Thomas Monjalon Subject: Re: [PATCH] examples/vm_power_manager: buffer not null terminated Date: Wed, 27 Apr 2016 16:36:14 +0200 Message-ID: <2816928.LRtXO1Vhg3@xps13> References: <1460473986-3816-1-git-send-email-danielx.t.mrzyglod@intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7Bit Cc: dev@dpdk.org, alan.carew@intel.com To: Daniel Mrzyglod Return-path: Received: from mail-wm0-f41.google.com (mail-wm0-f41.google.com [74.125.82.41]) by dpdk.org (Postfix) with ESMTP id E4AF628BF for ; Wed, 27 Apr 2016 16:36:16 +0200 (CEST) Received: by mail-wm0-f41.google.com with SMTP id a17so18871014wme.0 for ; Wed, 27 Apr 2016 07:36:16 -0700 (PDT) In-Reply-To: <1460473986-3816-1-git-send-email-danielx.t.mrzyglod@intel.com> List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" 2016-04-12 17:13, Daniel Mrzyglod: > CID30691: > If the buffer is treated as a null terminated string in later operations, > a buffer overflow or over-read may occur. [...] > --- a/examples/vm_power_manager/channel_manager.c > +++ b/examples/vm_power_manager/channel_manager.c > - strncpy(new_domain->name, vm_name, sizeof(new_domain->name)); > + strncat(new_domain->name, vm_name, sizeof(new_domain->name) - > + strlen(new_domain->name) - 1); It looks to be a copy paste of a ready-to-use replacement of strncpy. Why not just do new_domain->name[sizeof(new_domain->name) - 1] = 0 ?