Messages in this thread | | | Date | Fri, 24 Jan 2014 12:28:37 +0000 | From | Al Viro <> | Subject | Re: [PATCH] dcache: error out on failures to store terminating NUL |
| |
On Fri, Jan 24, 2014 at 01:17:46PM +0100, Denys Vlasenko wrote: > A number of routines wasn't checking that the initial call > to prepend "\0" to result buffer doesn't fail. > > Coredump code was seeing d_path() with zero-sized buffer > to erroneously return bogus data (non-error pointer > pointing before buffer start). > > Users report that this change fixes it.
NAK. Again, this is not dealing with overflows - it's basic sanity check on arguments. Choose which level should that be done at and just do it there. As in "if (!buflen) return -ENAMETOOLONG;". > char *cwd = page + PATH_MAX; > int buflen = PATH_MAX; > > - prepend(&cwd, &buflen, "\0", 1); > - error = prepend_path(&pwd, &root, &cwd, &buflen); > + error = prepend(&cwd, &buflen, "\0", 1); > + if (!error) > + error = prepend_path(&pwd, &root, &cwd, &buflen);
Ah, yes - the dreadful case of zero PATH_MAX...
| |