[dpdk-dev] [PATCH 5/5] cfgfile: increase local buffer size for max name and value
Wiles, Keith
keith.wiles at intel.com
Thu Mar 9 16:23:16 CET 2017
> On Mar 9, 2017, at 9:16 AM, Legacy, Allain <Allain.Legacy at windriver.com> wrote:
>
>> -----Original Message-----
>> From: Wiles, Keith [mailto:keith.wiles at 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 make
>> sure they are valid and return error?
>>
>
> The fgets() is bounded by the size of the buffer and the subsequent validation will raise an error if no newline was detected within the buffer therefore 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 library.
>
> while (fgets(buffer, sizeof(buffer), f) != NULL) {
> char *pos = NULL;
> size_t len = strnlen(buffer, sizeof(buffer));
> lineno++;
> if ((len >= sizeof(buffer) - 1) && (buffer[len-1] != '\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?
Acked-by: Keith Wiles <keith.wiles at intel.com>
Regards,
Keith
More information about the dev
mailing list