diff options
author | David Cantrell <dcantrell@redhat.com> | 2008-08-27 16:02:25 -1000 |
---|---|---|
committer | David Cantrell <dcantrell@redhat.com> | 2008-08-27 16:21:34 -1000 |
commit | 880f136dd1194c4f8cff51eb3a315eb0e3331b09 (patch) | |
tree | b6467173c5627581e72f9849016d45e20815f92a /isys/imount.c | |
parent | be2ccb12394e1b25564aac3ebca36d45108999c1 (diff) | |
download | anaconda-880f136dd1194c4f8cff51eb3a315eb0e3331b09.tar.gz anaconda-880f136dd1194c4f8cff51eb3a315eb0e3331b09.tar.xz anaconda-880f136dd1194c4f8cff51eb3a315eb0e3331b09.zip |
Fix err handling in doMultiMount()
err is a double pointer, so make sure we set it, clear it, and
populate it correctly when calling doPwMount().
Diffstat (limited to 'isys/imount.c')
-rw-r--r-- | isys/imount.c | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/isys/imount.c b/isys/imount.c index 9ae5e6d3d..8ba1e668d 100644 --- a/isys/imount.c +++ b/isys/imount.c @@ -112,10 +112,19 @@ int doPwMount(char *dev, char *where, char *fs, char *options, char **err) { close(pipefd[1]); if (err != NULL) { + if (*err && **err) { + free(*err); + *err = NULL; + } + while ((rc = read(pipefd[0], &buf, 4096)) > 1) { - i += rc; - *err = realloc(*err, i+1); - *err = strncat(*err, buf, rc); + i += rc + 1; + + if ((*err = realloc(*err, i)) == NULL) { + abort(); + } + + *err = strncpy(*err, buf, rc); } } @@ -138,8 +147,10 @@ int doMultiMount(char *dev, char *where, char **fstypes, char *options, char **e * get rid of it now. We only want to preserve the error from the last * fstype. */ - if (err && *err) + if (err && *err && **err) { free(*err); + *err = NULL; + } retval = doPwMount(dev, where, fstypes[i], options, err); if (!retval) |