From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-f44.google.com (mail-wm0-f44.google.com [74.125.82.44]) by dpdk.org (Postfix) with ESMTP id 2195D56A2 for ; Wed, 4 May 2016 10:15:45 +0200 (CEST) Received: by mail-wm0-f44.google.com with SMTP id e201so176690192wme.0 for ; Wed, 04 May 2016 01:15:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=6wind-com.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=p7Sxync2XIFzj5Wj9qPJqIaIft++jk1smkEqTRtbND8=; b=ElqhNxlBfewiLHBoaVGT4ooLZcP/BIY0jS0rvg86dOOSI6Nq5Ctp2XDW+XO+SAlJSZ 0+EWCrfdJ86G6Z9zYbFYSDOsGnMkUXak7fmgl2aGzy9Itg/eZw1jRoCJ5v2M8SKhdgDC zez/BXtqkPj3XS17K0OkVSat2iXFSMlR6X6we4eLbo34knsQTmpA8IsUB/J+5XzJDPk6 n9Mtu+Nwiskw51NoG4DVSf4lP1soccE1XpVFoPKmEpjQycPZcUL7CBDfucQqw+JlJGUO jCsYtQUSW1Kjwmyg8rSnZHvr/AeTkbkxVz2M8DC+Vh2UdOp7+76u7UOSJtAVeHdup6lr SEcw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=p7Sxync2XIFzj5Wj9qPJqIaIft++jk1smkEqTRtbND8=; b=mI9EOwKASTSbdMOxBYMwasja28LRsYAh7AvPUKS7gjB46sSQP7RQHOCQHnQ00PlG19 6PwzcOJkokqcKCOmcNS6PpL8E3aK/itCajZ7b/dsKS/tiFV1RWtmkoe22wHwwPPsMrlR eUtWXnJkPz7OZinR6MeOSSmOO3jN+QKDNWWDFCqzCgrG3So9HEtNSLFI/rqf7Gq4Oiwk qbZ5emWcnF0T0AFemhzhzMzSZXgfFVXF4hqcnokQdtf0Jyydq3eW8e85T8egQMOH56/T GVTlheGWwJ+rJEOVX7RgLDIjatpggKWtovEoxfPXyVVlTZyk9weMirhAPUHzHopCdtSC 80kA== X-Gm-Message-State: AOPr4FXbWb4vEJly8ZjpKBnmH8UIuwpxlvmqi13iiU+h4Xv6o2YuXOU9smZvqHYtNLZvh+4HTpkvuqsrthWa7Z73 X-Received: by 10.28.140.12 with SMTP id o12mr28982371wmd.19.1462349744934; Wed, 04 May 2016 01:15:44 -0700 (PDT) MIME-Version: 1.0 Received: by 10.28.16.2 with HTTP; Wed, 4 May 2016 01:15:25 -0700 (PDT) In-Reply-To: <1462302927-24627-1-git-send-email-viktorin@rehivetech.com> References: <1462302927-24627-1-git-send-email-viktorin@rehivetech.com> From: David Marchand Date: Wed, 4 May 2016 10:15:25 +0200 Message-ID: To: Jan Viktorin Cc: "dev@dpdk.org" , Thomas Monjalon Content-Type: text/plain; charset=UTF-8 Subject: Re: [dpdk-dev] [PATCH] app/test: fix +/-1 error in allocation X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 04 May 2016 08:15:45 -0000 On Tue, May 3, 2016 at 9:15 PM, Jan Viktorin wrote: > A bug has been detected by valgrind: > > ==14406== Invalid write of size 1 > ==14406== by 0x86ECC76: sprintf (in /usr/lib/libc-2.23.so) > ==14406== by 0x430B0A: commands_init (in /home/jviki/Projects/dpdk/dpdk-soc/build/app/test) > ==14406== by 0x42F215: main (in /home/jviki/Projects/dpdk/dpdk-soc/build/app/test) > ==14406== Address 0x9d72ff2 is 0 bytes after a block of size 1,346 alloc'd > ==14406== at 0x78C1BD0: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) > ==14406== by 0x430AE4: commands_init (in /home/jviki/Projects/dpdk/dpdk-soc/build/app/test) > ==14406== by 0x42F215: main (in /home/jviki/Projects/dpdk/dpdk-soc/build/app/test) > ==14406== > > The commands buffer is exactly 1346 B long so there is an access just after > the buffer. The sprintf always writes '\0' at the end of the string. The '#' > separator adds 1 B more to each string. This is correct until the last string > is sprinted there. The last one is 1 B longer then expected, i.e.: > > strlen(t->command) + strlen("#") + ONE_FOR_ZERO > > Fixes: 727909c59231 ("app/test: introduce dynamic commands list") > > Signed-off-by: Jan Viktorin Good catch. Acked-by: David Marchand -- David Marchand