diff options
author | Jeff Layton <jlayton@redhat.com> | 2010-03-22 08:03:38 -0400 |
---|---|---|
committer | Jeff Layton <jlayton@redhat.com> | 2010-03-22 08:03:38 -0400 |
commit | 7fae11e1a1ddb0c2fe2a7cc419bea073c82eb79e (patch) | |
tree | f3bc15c33bd2dcd94bf6e29e4cb454d8579351a3 /mount.cifs.c | |
parent | 1cd520efdfc49bfdcd411c345f7ac190684a698a (diff) | |
download | cifs-utils-7fae11e1a1ddb0c2fe2a7cc419bea073c82eb79e.tar.gz cifs-utils-7fae11e1a1ddb0c2fe2a7cc419bea073c82eb79e.tar.bz2 cifs-utils-7fae11e1a1ddb0c2fe2a7cc419bea073c82eb79e.zip |
mount.cifs: fix error handling when duplicating options string
Signed-off-by: Jeff Layton <jlayton@redhat.com>
Diffstat (limited to 'mount.cifs.c')
-rw-r--r-- | mount.cifs.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/mount.cifs.c b/mount.cifs.c index b30056c..273cbbd 100644 --- a/mount.cifs.c +++ b/mount.cifs.c @@ -57,6 +57,9 @@ #define MAX_UNC_LEN 1024 +/* I believe that the kernel limits options data to a page */ +#define MAX_OPTIONS_LEN 4096 + #ifndef SAFE_FREE #define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0) #endif @@ -1224,8 +1227,10 @@ int main(int argc, char ** argv) #endif break; case 'o': - orgoptions = strdup(optarg); - break; + orgoptions = strndup(optarg, MAX_OPTIONS_LEN); + if (!orgoptions) + exit(EX_SYSERR); + break; case 'r': /* mount readonly */ flags |= MS_RDONLY; break; |