strncpy() call length argument must be one less than the actual buffer
length. The final byte in buffer must be NULL, in case strncpy does
not fill it with NULL itself.
Signed-off-by: Timo Kokkonen <timo.t.kokkonen@iki.fi>
if (strstr(path, "/uncached/"))
return 0;
if (strstr(path, "/uncached/"))
return 0;
+ p1[sizeof(p1) - 1] = '\0';
+ p2[sizeof(p2) - 1] = '\0';
+
/*
* Naively assume the "uncached" string can be put after the
* first slash
/*
* Naively assume the "uncached" string can be put after the
* first slash
- strncpy(p1, path, sizeof(p1));
- strncpy(p2, p, sizeof(p2));
+ strncpy(p1, path, sizeof(p1) - 1);
+ strncpy(p2, p, sizeof(p2) - 1);
snprintf(path, len, "%s/uncached/%s", p1, p2);
return 0;
snprintf(path, len, "%s/uncached/%s", p1, p2);
return 0;