Re: [PATCH v2] tile: avoid errors from truncating long strings in mpipe gxio

2014-08-11 Thread Randy Dunlap
On 08/11/14 13:43, Rickard Strandqvist wrote: > 2014-08-07 8:43 GMT+02:00 Randy Dunlap : >> On 08/06/14 11:16, Chris Metcalf wrote: >>> Using strncpy() will just silently truncate long strings; we should >>> instead return an appropriate error. Using strlcpy() would suffer from >>> the same proble

Re: [PATCH v2] tile: avoid errors from truncating long strings in mpipe gxio

2014-08-11 Thread Rickard Strandqvist
2014-08-07 8:43 GMT+02:00 Randy Dunlap : > On 08/06/14 11:16, Chris Metcalf wrote: >> Using strncpy() will just silently truncate long strings; we should >> instead return an appropriate error. Using strlcpy() would suffer from >> the same problem. Instead, use strnlen()+memcpy(), and add an >> e

new generic strscpy API? (was Re: [PATCH v2] tile: avoid errors from truncating long strings in mpipe gxio)

2014-08-07 Thread Chris Metcalf
On 8/7/2014 2:43 AM, Randy Dunlap wrote: On 08/06/14 11:16, Chris Metcalf wrote: Using strncpy() will just silently truncate long strings; we should instead return an appropriate error. Using strlcpy() would suffer from the same problem. Instead, use strnlen()+memcpy(), and add an error-checki

Re: [PATCH v2] tile: avoid errors from truncating long strings in mpipe gxio

2014-08-06 Thread Randy Dunlap
On 08/06/14 11:16, Chris Metcalf wrote: > Using strncpy() will just silently truncate long strings; we should > instead return an appropriate error. Using strlcpy() would suffer from > the same problem. Instead, use strnlen()+memcpy(), and add an > error-checking step to make sure the lengths are

Re: [PATCH v2] tile: avoid errors from truncating long strings in mpipe gxio

2014-08-06 Thread Rickard Strandqvist
2014-08-06 20:16 GMT+02:00 Chris Metcalf : > Using strncpy() will just silently truncate long strings; we should > instead return an appropriate error. Using strlcpy() would suffer from > the same problem. Instead, use strnlen()+memcpy(), and add an > error-checking step to make sure the lengths

[PATCH v2] tile: avoid errors from truncating long strings in mpipe gxio

2014-08-06 Thread Chris Metcalf
Using strncpy() will just silently truncate long strings; we should instead return an appropriate error. Using strlcpy() would suffer from the same problem. Instead, use strnlen()+memcpy(), and add an error-checking step to make sure the lengths are reasonable. I called the convenience wrapper s