Messages in this thread |  | | Subject | Re: [PATCH] nfs: Don't deref potentially NULL pointer returned by strsep | | From | Chuck Lever <> | | Date | Sun, 3 Jul 2011 10:09:32 -0400 |
| |
On Jul 3, 2011, at 3:40 AM, Jesper Juhl wrote:
> In fs/nfs/nfsroot.c:root_nfs_parse_options() we call strsep(), which > may return NULL, but we do not test the return value before > dereferencing the pointer. > > Signed-off-by: Jesper Juhl <jj@chaosbits.net> > --- > fs/nfs/nfsroot.c | 2 ++ > 1 files changed, 2 insertions(+), 0 deletions(-) > > Compile tested only. > > diff --git a/fs/nfs/nfsroot.c b/fs/nfs/nfsroot.c > index c4744e1..b6ac860 100644 > --- a/fs/nfs/nfsroot.c > +++ b/fs/nfs/nfsroot.c > @@ -191,6 +191,8 @@ static int __init root_nfs_parse_options(char *incoming, char *exppath, > * Set the NFS remote path > */ > p = strsep(&incoming, ","); > + if (!p) > + return -1;
strsep() may return NULL only if the value of "incoming" is NULL. But callers ensure that "incoming" always contains the address of a fixed buffer. Thus if strsep() returns NULL here there is some kind of programming error; it's not the result of invalid input.
Do you have a reproducible test case to make this fail?
> if (*p != '\0' && strcmp(p, "default") != 0) > if (root_nfs_copy(exppath, p, exppathlen)) > return -1;
-- Chuck Lever chuck[dot]lever[at]oracle[dot]com
|  |