From mboxrd@z Thu Jan 1 00:00:00 1970 From: Olivier Matz Subject: Re: [PATCH v1 1/1] cmdline: add any multi string mode to token string Date: Mon, 4 Apr 2016 17:57:33 +0200 Message-ID: <57028EED.9020008@6wind.com> References: <1459510581-31392-1-git-send-email-piotrx.t.azarewicz@intel.com> <57021F2E.8070306@6wind.com> <4837007523CC9A4B9414D20C13DE6E6413687FDB@IRSMSX102.ger.corp.intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Cc: "dev@dpdk.org" To: "Azarewicz, PiotrX T" Return-path: Received: from mail-lb0-f180.google.com (mail-lb0-f180.google.com [209.85.217.180]) by dpdk.org (Postfix) with ESMTP id 9404829C6 for ; Mon, 4 Apr 2016 17:57:36 +0200 (CEST) Received: by mail-lb0-f180.google.com with SMTP id qe11so167207721lbc.3 for ; Mon, 04 Apr 2016 08:57:36 -0700 (PDT) In-Reply-To: <4837007523CC9A4B9414D20C13DE6E6413687FDB@IRSMSX102.ger.corp.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" Hi Piotr, On 04/04/2016 04:11 PM, Azarewicz, PiotrX T wrote: >> Using token_len + 1 as the buffer size in the snprintf looks a bit dangerous, as >> it won't protect from overflows. >> >> See the following example: > > > That's why snprintf() should still use STR_TOKEN_SIZE. >> > Okay, I see it. > But this is a problem that we may need longer string than STR_TOKEN_SIZE in multi token case. > So what you think about adding new typedef cmdline_multi_string_t for this case? > For example: > #define STR_MULTI_TOKEN_SIZE 1024 > typedef char cmdline_multi_string_t[STR_MULTI_TOKEN_SIZE]; It should do the job, indeed. By the way, it would be nice to have an example of use. Regards, Olivier