From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Legacy, Allain" Subject: Re: [PATCH 5/5] cfgfile: increase local buffer size for max name and value Date: Thu, 9 Mar 2017 15:16:01 +0000 Message-ID: <70A7408C6E1BFB41B192A929744D8523968E9F02@ALA-MBC.corp.ad.wrs.com> References: <1488482971-170522-1-git-send-email-allain.legacy@windriver.com> <1488482971-170522-6-git-send-email-allain.legacy@windriver.com> <8258C19A-889A-475B-9F29-33949ABCF8EE@intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Cc: "RICHARDSON, BRUCE" , "DUMITRESCU, CRISTIAN FLORIN" , "dev@dpdk.org" , "Jolliffe, Ian" To: "WILES, ROGER" Return-path: Received: from mail5.wrs.com (mail5.windriver.com [192.103.53.11]) by dpdk.org (Postfix) with ESMTP id 8E8532B8C for ; Thu, 9 Mar 2017 16:16:03 +0100 (CET) In-Reply-To: <8258C19A-889A-475B-9F29-33949ABCF8EE@intel.com> Content-Language: en-US List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" > -----Original Message----- > From: Wiles, Keith [mailto:keith.wiles@intel.com] > Sent: Thursday, March 09, 2017 8:46 AM > Would this change still cause a failure and memory over write if the user > decides to have very large string. Does the code check the lengths to mak= e > sure they are valid and return error? >=20 The fgets() is bounded by the size of the buffer and the subsequent validat= ion will raise an error if no newline was detected within the buffer theref= ore an overly long line will result in a failure. I have added a test case= in the v2 patchset in which I have added a unit test framework for this li= brary. while (fgets(buffer, sizeof(buffer), f) !=3D NULL) { char *pos =3D NULL; size_t len =3D strnlen(buffer, sizeof(buffer)); lineno++; if ((len >=3D sizeof(buffer) - 1) && (buffer[len-1] !=3D '\n')) { printf("Error line %d - no \\n found on string. " "Check if line too long\n", lineno); goto error1; } Does that satisfy your concern and qualify for you Ack?