summaryrefslogtreecommitdiffstats
path: root/isys/imount.c
diff options
context:
space:
mode:
authorDavid Cantrell <dcantrell@redhat.com>2008-06-27 05:18:17 -1000
committerDavid Cantrell <dcantrell@redhat.com>2008-06-27 05:18:17 -1000
commit539fc605f9402830860bf2276f6b790bceef6fc6 (patch)
tree49863a7fde8eab8b7bbc8309cb957190284be002 /isys/imount.c
parent83389b2effe828debfbbcbebf87dbfd2cc12e361 (diff)
downloadanaconda-539fc605f9402830860bf2276f6b790bceef6fc6.tar.gz
anaconda-539fc605f9402830860bf2276f6b790bceef6fc6.tar.xz
anaconda-539fc605f9402830860bf2276f6b790bceef6fc6.zip
Check return value of asprintf() consistently
For instances where the asprintf() was ignored, wrap it in a test to check if it failed. If it failed, log a message and abort. There may be some instances where abort may not be what we want to do, however, we were ignoring the return value completely so if we did get a failure, it would just SIGSEGV. Now it will SIGABRT instead.
Diffstat (limited to 'isys/imount.c')
-rw-r--r--isys/imount.c25
1 files changed, 19 insertions, 6 deletions
diff --git a/isys/imount.c b/isys/imount.c
index 89a528709..3277a6e6a 100644
--- a/isys/imount.c
+++ b/isys/imount.c
@@ -43,17 +43,30 @@ int doPwMount(char *dev, char *where, char *fs, char *options) {
}
if (strstr(fs, "nfs")) {
- if (options)
- rc = asprintf(&opts, "%s,nolock", options);
- else
+ if (options) {
+ if (asprintf(&opts, "%s,nolock", options) == -1) {
+ fprintf(stderr, "%s: %d: %s\n", __func__, __LINE__,
+ strerror(errno));
+ fflush(stderr);
+ abort();
+ }
+ } else {
opts = strdup("nolock");
+ }
device = strdup(dev);
} else {
if ((options && strstr(options, "bind") == NULL) &&
- strncmp(dev, "LABEL=", 6) && strncmp(dev, "UUID=", 5) && *dev != '/')
- rc = asprintf(&device, "/dev/%s", dev);
- else
+ strncmp(dev, "LABEL=", 6) && strncmp(dev, "UUID=", 5) &&
+ *dev != '/') {
+ if (asprintf(&device, "/dev/%s", dev) == -1) {
+ fprintf(stderr, "%s: %d: %s\n", __func__, __LINE__,
+ strerror(errno));
+ fflush(stderr);
+ abort();
+ }
+ } else {
device = strdup(dev);
+ }
if (options)
opts = strdup(options);
}