[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <fbfce029-7d26-75aa-2c91-cea2442922bc@nexus-software.ie>
Date: Wed, 15 Feb 2017 11:53:57 +0000
From: Bryan O'Donoghue <pure.logic@...us-software.ie>
To: "Tobin C. Harding" <me@...in.cc>, greybus-dev@...ts.linaro.org
Cc: devel@...verdev.osuosl.org,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Johan Hovold <johan@...nel.org>, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] greybus: fw-management: Replace strncpy with strlcpy
On 15/02/17 00:09, Tobin C. Harding wrote:
> Greybus currently uses strncpy() coupled with a check for '\0' on the
> last byte of various buffers. strncpy() is passed size parameter equal
> to the size of the buffer in all instances. If the source string is
> larger than the destination buffer the check catches this and, after
> logging the error, returns an error value. In one instance the
> immediate return is not required. Using strncpy() with the manual check
> adds code that could be removed by the use of strlcpy(), although truncation
> then needs to be checked.
>
> Replace calls to strncpy() with calls to strlcpy(). Replace null
> termination checks with checks for truncated string. Add log message
> if string is truncated but do not return an error code.
The strlcpy() replace should be one patch.
The not returning on truncation should be a separate patch.
Personally I don't think the flow should change re: returning errors on
string truncation but, either way you should split it up.
---
bod
Powered by blists - more mailing lists