On 15 December 2014 at 13:42, Ola Liljedahl <ola.liljed...@linaro.org> wrote: > On 15 December 2014 at 22:35, Mike Holmes <mike.hol...@linaro.org> wrote: >> Termination of the string is not assured unless the string is >> one char shorter than the buffer. >> >> Fixes coverity 83058 >> >> Signed-off-by: Mike Holmes <mike.hol...@linaro.org> >> --- >> platform/linux-generic/odp_packet_io.c | 2 +- >> 1 file changed, 1 insertion(+), 1 deletion(-) >> >> diff --git a/platform/linux-generic/odp_packet_io.c >> b/platform/linux-generic/odp_packet_io.c >> index a03eeb1..7694236 100644 >> --- a/platform/linux-generic/odp_packet_io.c >> +++ b/platform/linux-generic/odp_packet_io.c >> @@ -247,7 +247,7 @@ odp_pktio_t odp_pktio_open(const char *dev, >> odp_buffer_pool_t pool) >> return ODP_PKTIO_INVALID; >> >> done: >> - strncpy(pktio_entry->s.name, dev, IFNAMSIZ);pktio_entry->s.name >> + strncpy(pktio_entry->s.name, dev, IFNAMSIZ - 1); > strncpy() does not necessarily null-terminated the copied string (only > if there is a null-char within the copied range of characters). So > where is pktio_entry->s.name[IFNAMSIZ -1] cleared? > > We should be using something like strlcpy() instead.
It should be consistent across the whole project. In other places were strncpy is used, it is followed by code that adds 0 to last byte of target string. In this patch the following line should be added after strncpy. pktio_entry->s.name[IFNAMSIZ - 1] = 0; Also note strlcpy is BSD function. I don't see such in Linux. Thanks, Victor >> unlock_entry_classifier(pktio_entry); >> return id; >> } >> -- >> 2.1.0 >> >> >> _______________________________________________ >> lng-odp mailing list >> lng-odp@lists.linaro.org >> http://lists.linaro.org/mailman/listinfo/lng-odp > > _______________________________________________ > lng-odp mailing list > lng-odp@lists.linaro.org > http://lists.linaro.org/mailman/listinfo/lng-odp _______________________________________________ lng-odp mailing list lng-odp@lists.linaro.org http://lists.linaro.org/mailman/listinfo/lng-odp