summaryrefslogtreecommitdiffstats
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
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.
-rw-r--r--isys/devices.c34
-rw-r--r--isys/imount.c25
-rw-r--r--isys/isys.c14
-rw-r--r--loader2/cdinstall.c56
-rw-r--r--loader2/copy.c42
-rw-r--r--loader2/driverdisk.c26
-rw-r--r--loader2/driverselect.c26
-rw-r--r--loader2/hardware.c6
-rw-r--r--loader2/hdinstall.c62
-rw-r--r--loader2/kickstart.c8
-rw-r--r--loader2/lang.c5
-rw-r--r--loader2/loader.c101
-rw-r--r--loader2/method.c8
-rw-r--r--loader2/net.c58
-rw-r--r--loader2/nfsinstall.c129
-rw-r--r--loader2/urlinstall.c58
-rw-r--r--loader2/urls.c11
17 files changed, 503 insertions, 166 deletions
diff --git a/isys/devices.c b/isys/devices.c
index 2e3760ecc..e312a43e9 100644
--- a/isys/devices.c
+++ b/isys/devices.c
@@ -50,7 +50,6 @@ struct device **getDevices(enum deviceType type) {
struct device **ret = NULL;
struct device *new;
int numdevices = 0;
- int rc;
if (type & (DEVICE_DISK | DEVICE_CDROM)) {
DIR *dir;
@@ -120,7 +119,13 @@ struct device **getDevices(enum deviceType type) {
new = calloc(1, sizeof(struct device));
new->device = strdup(ent->d_name);
/* FIXME */
- rc = asprintf(&new->description,"Storage device %s",new->device);
+ if (asprintf(&new->description, "Storage device %s",
+ new->device) == -1) {
+ fprintf(stderr, "%s: %d: %s\n", __func__, __LINE__,
+ strerror(errno));
+ fflush(stderr);
+ abort();
+ }
new->type = devtype;
if (caps & GENHD_FL_REMOVABLE) {
new->priv.removable = 1;
@@ -175,16 +180,29 @@ storagedone:
if (fd != -1) {
if (read(fd, buf, 64) > 0) {
int i;
- for (i = (strlen(buf)-1); isspace(buf[i]); i--) buf[i] = '\0';
+ for (i = (strlen(buf)-1); isspace(buf[i]); i--)
+ buf[i] = '\0';
new->priv.hwaddr = strdup(buf);
}
}
- if (new->priv.hwaddr)
- rc = asprintf(&new->description, "Ethernet device %s - %s",
- new->device, new->priv.hwaddr);
- else
- rc = asprintf(&new->description, "Ethernet device %s", new->device);
+ if (new->priv.hwaddr) {
+ if (asprintf(&new->description, "Ethernet device %s - %s",
+ new->device, new->priv.hwaddr) == -1) {
+ fprintf(stderr, "%s: %d: %s\n", __func__, __LINE__,
+ strerror(errno));
+ fflush(stderr);
+ abort();
+ }
+ } else {
+ if (asprintf(&new->description, "Ethernet device %s",
+ new->device) == -1) {
+ fprintf(stderr, "%s: %d: %s\n", __func__, __LINE__,
+ strerror(errno));
+ fflush(stderr);
+ abort();
+ }
+ }
ret = realloc(ret, (numdevices+2) * sizeof(struct device));
ret[numdevices] = new;
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);
}
diff --git a/isys/isys.c b/isys/isys.c
index 31786df1e..f33872c99 100644
--- a/isys/isys.c
+++ b/isys/isys.c
@@ -601,12 +601,16 @@ static PyObject * doDhcpNetDevice(PyObject * s, PyObject * args) {
/* if we lack a user-provided dhcpclass, construct the default */
if ((dhcpclass == NULL) || (strlen(dhcpclass) == 0)) {
- if (uname(&kv) == -1)
+ if (uname(&kv) == -1) {
dhcpclass = "anaconda";
- else {
- int ret;
- ret = asprintf(&dhcpclass, "anaconda-%s %s %s",
- kv.sysname, kv.release, kv.machine);
+ } else {
+ if (asprintf(&dhcpclass, "anaconda-%s %s %s",
+ kv.sysname, kv.release, kv.machine) == -1) {
+ fprintf(stderr, "%s: %d: %s\n", __func__, __LINE__,
+ strerror(errno));
+ fflush(stderr);
+ abort();
+ }
}
}
diff --git a/loader2/cdinstall.c b/loader2/cdinstall.c
index e1460c886..59a487077 100644
--- a/loader2/cdinstall.c
+++ b/loader2/cdinstall.c
@@ -138,11 +138,16 @@ static char * mediaCheckCdrom(char *cddriver) {
/* Used by mountCdromStage2() */
static void wrongCDMessage(void) {
char *buf = NULL;
- int i;
- i = asprintf(&buf, (_("The %s disc was not found "
+
+ if (asprintf(&buf, (_("The %s disc was not found "
"in any of your drives. Please insert "
"the %s disc and press %s to retry."),
- getProductName(), getProductName(), _("OK")));
+ getProductName(), getProductName(), _("OK"))) == -1) {
+ logMessage(CRITICAL, "%s: %d: %s", __func__, __LINE__,
+ strerror(errno));
+ abort();
+ }
+
newtWinMessage(_("Error"), _("OK"), buf);
free(buf);
}
@@ -180,7 +185,13 @@ static void queryCDMediaCheck(char *dev, char *location) {
continue;
}
- rc = asprintf(&stage2loc, "%s/images/stage2.img", location);
+ if (asprintf(&stage2loc, "%s/images/stage2.img",
+ location) == -1) {
+ logMessage(CRITICAL, "%s: %d: %s", __func__, __LINE__,
+ strerror(errno));
+ abort();
+ }
+
if (!access(stage2loc, R_OK)) {
free(stage2loc);
umount(location);
@@ -206,7 +217,7 @@ static void queryCDMediaCheck(char *dev, char *location) {
*/
static char *setupCdrom(char *location, struct loaderData_s *loaderData,
int interactive, int mediaCheck) {
- int i, r, rc;
+ int i, rc;
int stage2inram = 0;
char *buf, *stage2loc, *stage2img;
struct device ** devices;
@@ -218,7 +229,11 @@ static char *setupCdrom(char *location, struct loaderData_s *loaderData,
return NULL;
}
- r = asprintf(&stage2loc, "%s/images/stage2.img", location);
+ if (asprintf(&stage2loc, "%s/images/stage2.img", location) == -1) {
+ logMessage(CRITICAL, "%s: %d: %s", __func__, __LINE__,
+ strerror(errno));
+ abort();
+ }
/* JKFIXME: ASSERT -- we have a cdrom device when we get here */
do {
@@ -229,7 +244,12 @@ static char *setupCdrom(char *location, struct loaderData_s *loaderData,
continue;
if (strncmp("/dev/", devices[i]->device, 5)) {
- r = asprintf(&tmp, "/dev/%s", devices[i]->device);
+ if (asprintf(&tmp, "/dev/%s", devices[i]->device) == -1) {
+ logMessage(CRITICAL, "%s: %d: %s", __func__, __LINE__,
+ strerror(errno));
+ abort();
+ }
+
free(devices[i]->device);
devices[i]->device = tmp;
}
@@ -271,13 +291,12 @@ static char *setupCdrom(char *location, struct loaderData_s *loaderData,
umount(location);
}
- r = asprintf(&buf, "cdrom://%s:%s",
- devices[i]->device, location);
-
- if (r == -1)
- return NULL;
- else
- return buf;
+ if (asprintf(&buf, "cdrom://%s:%s",
+ devices[i]->device, location) == -1) {
+ logMessage(CRITICAL, "%s: %d: %s", __func__, __LINE__,
+ strerror(errno));
+ abort();
+ }
}
/* this wasnt the CD we were looking for, clean up and */
@@ -288,12 +307,15 @@ static char *setupCdrom(char *location, struct loaderData_s *loaderData,
if (interactive) {
char * buf;
- int i;
- i = asprintf(&buf, _("The %s disc was not found in any of your "
+ if (asprintf(&buf, _("The %s disc was not found in any of your "
"CDROM drives. Please insert the %s disc "
"and press %s to retry."),
- getProductName(), getProductName(), _("OK"));
+ getProductName(), getProductName(), _("OK")) == -1) {
+ logMessage(CRITICAL, "%s: %d: %s", __func__, __LINE__,
+ strerror(errno));
+ abort();
+ }
ejectCdrom(cddev);
rc = newtWinChoice(_("Disc Not Found"),
diff --git a/loader2/copy.c b/loader2/copy.c
index 735202876..4bfc62cd0 100644
--- a/loader2/copy.c
+++ b/loader2/copy.c
@@ -38,7 +38,7 @@ int copyDirectory(char * from, char * to, void (*warnFn)(char *),
struct dirent * ent;
int fd, outfd;
char buf[4096];
- int i, x;
+ int i;
struct stat sb;
char filespec[256];
char filespec2[256];
@@ -48,8 +48,14 @@ int copyDirectory(char * from, char * to, void (*warnFn)(char *),
if (!(dir = opendir(from))) {
if (errorFn) {
- x = asprintf(&msg, N_("Failed to read directory %s: %s"), from,
- strerror(errno));
+ if (asprintf(&msg, N_("Failed to read directory %s: %s"), from,
+ strerror(errno)) == -1) {
+ fprintf(stderr, "%s: %d: %s\n", __func__, __LINE__,
+ strerror(errno));
+ fflush(stderr);
+ abort();
+ }
+
errorFn(msg);
free(msg);
}
@@ -77,8 +83,14 @@ int copyDirectory(char * from, char * to, void (*warnFn)(char *),
link[i] = '\0';
if (symlink(link, filespec2)) {
if (warnFn) {
- x = asprintf(&msg, "Failed to symlink %s to %s: %s",
- filespec2, link, strerror(errno));
+ if (asprintf(&msg, "Failed to symlink %s to %s: %s",
+ filespec2, link, strerror(errno)) == -1) {
+ fprintf(stderr, "%s: %d: %s\n", __func__, __LINE__,
+ strerror(errno));
+ fflush(stderr);
+ abort();
+ }
+
warnFn(msg);
free(msg);
}
@@ -87,8 +99,14 @@ int copyDirectory(char * from, char * to, void (*warnFn)(char *),
fd = open(filespec, O_RDONLY);
if (fd == -1) {
if (errorFn) {
- x = asprintf(&msg, "Failed to open %s: %s", filespec,
- strerror(errno));
+ if (asprintf(&msg, "Failed to open %s: %s", filespec,
+ strerror(errno)) == -1) {
+ fprintf(stderr, "%s: %d: %s\n", __func__, __LINE__,
+ strerror(errno));
+ fflush(stderr);
+ abort();
+ }
+
errorFn(msg);
free(msg);
}
@@ -99,8 +117,14 @@ int copyDirectory(char * from, char * to, void (*warnFn)(char *),
outfd = open(filespec2, O_RDWR | O_TRUNC | O_CREAT, 0644);
if (outfd == -1) {
if (warnFn) {
- x = asprintf(&msg, "Failed to create %s: %s", filespec2,
- strerror(errno));
+ if (asprintf(&msg, "Failed to create %s: %s", filespec2,
+ strerror(errno)) == -1) {
+ fprintf(stderr, "%s: %d: %s\n", __func__, __LINE__,
+ strerror(errno));
+ fflush(stderr);
+ abort();
+ }
+
warnFn(msg);
free(msg);
}
diff --git a/loader2/driverdisk.c b/loader2/driverdisk.c
index 9672e59d9..a703d3a49 100644
--- a/loader2/driverdisk.c
+++ b/loader2/driverdisk.c
@@ -103,7 +103,8 @@ static void copyErrorFn (char *msg) {
static int loadDriverDisk(struct loaderData_s *loaderData, char *mntpt) {
moduleInfoSet modInfo = loaderData->modInfo;
char file[200], dest[200];
- char * title;
+ char *title;
+ char *fwdir = NULL;
struct moduleBallLocation * location;
struct stat sb;
static int disknum = 0;
@@ -143,11 +144,18 @@ static int loadDriverDisk(struct loaderData_s *loaderData, char *mntpt) {
location = malloc(sizeof(struct moduleBallLocation));
location->title = strdup(title);
- ret = asprintf(&location->path, "/tmp/DD-%d/modules.cgz", disknum);
location->version = version;
- char *fwdir = NULL;
- ret = asprintf(&fwdir, "/tmp/DD-%d/firmware", disknum);
+ if (asprintf(&location->path, "/tmp/DD-%d/modules.cgz", disknum) == -1) {
+ logMessage(CRITICAL, "%s: %d: %s", __func__, __LINE__, strerror(errno));
+ abort();
+ }
+
+ if (asprintf(&fwdir, "/tmp/DD-%d/firmware", disknum) == -1) {
+ logMessage(CRITICAL, "%s: %d: %s", __func__, __LINE__, strerror(errno));
+ abort();
+ }
+
if (!access(fwdir, R_OK|X_OK)) {
add_fw_search_dir(loaderData, fwdir);
stop_fw_loader(loaderData);
@@ -346,8 +354,14 @@ int loadDriverFromMedia(int class, struct loaderData_s *loaderData,
case DEV_INSERT: {
char * buf;
- rc = asprintf(&buf, _("Insert your driver disk into /dev/%s "
- "and press \"OK\" to continue."), device);
+ if (asprintf(&buf,
+ _("Insert your driver disk into /dev/%s "
+ "and press \"OK\" to continue."), device) == -1) {
+ logMessage(CRITICAL, "%s: %d: %s", __func__, __LINE__,
+ strerror(errno));
+ abort();
+ }
+
rc = newtWinChoice(_("Insert Driver Disk"), _("OK"), _("Back"),
buf);
free(buf);
diff --git a/loader2/driverselect.c b/loader2/driverselect.c
index 2ee228680..fb6ab4f62 100644
--- a/loader2/driverselect.c
+++ b/loader2/driverselect.c
@@ -26,6 +26,7 @@
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
+#include <errno.h>
#include "modules.h"
#include "moduleinfo.h"
@@ -62,10 +63,15 @@ static int getManualModuleArgs(struct moduleInfo * mod, char *** moduleArgs) {
}
f = newtForm(NULL, NULL, 0);
- i = asprintf(&buf, _("Please enter any parameters which you wish to pass "
- "to the %s module separated by spaces. If you don't "
- "know what parameters to supply, skip this screen "
- "by pressing the \"OK\" button."), mod->moduleName);
+ if (asprintf(&buf,
+ _("Please enter any parameters which you wish to pass "
+ "to the %s module separated by spaces. If you don't "
+ "know what parameters to supply, skip this screen "
+ "by pressing the \"OK\" button."), mod->moduleName) == -1) {
+ logMessage(CRITICAL, "%s: %d: %s", __func__, __LINE__, strerror(errno));
+ abort();
+ }
+
text = newtTextboxReflowed(-1, -1, buf, 60, 0, 10, 0);
entry = newtEntry(-1, -1, argsEntry, 50, (const char **) &argsEntry,
NEWT_ENTRY_SCROLL);
@@ -205,10 +211,14 @@ int chooseManualDriver(int class, struct loaderData_s *loaderData) {
for (i = 0; i < numSorted; i++) {
char *buf = NULL;
- int j;
- j = asprintf(&buf, "%s (%s)",
- modInfo->moduleList[sortedOrder[i].index].description,
- modInfo->moduleList[sortedOrder[i].index].moduleName);
+
+ if (asprintf(&buf, "%s (%s)",
+ modInfo->moduleList[sortedOrder[i].index].description,
+ modInfo->moduleList[sortedOrder[i].index].moduleName) == -1) {
+ logMessage(CRITICAL, "%s: %d: %s", __func__, __LINE__,
+ strerror(errno));
+ abort();
+ }
newtListboxAppendEntry(listbox, buf,
INT_TO_POINTER(sortedOrder[i].index));
diff --git a/loader2/hardware.c b/loader2/hardware.c
index 8aff62f42..b980f60a1 100644
--- a/loader2/hardware.c
+++ b/loader2/hardware.c
@@ -84,7 +84,11 @@ static int detectHardware() {
close(fd);
if (timeout) {
- rc = asprintf(&args[2],"--timeout=%d",timeout);
+ if (asprintf(&args[2],"--timeout=%d",timeout) == -1) {
+ logMessage(CRITICAL, "%s: %d: %s", __func__, __LINE__,
+ strerror(errno));
+ abort();
+ }
}
rc = execv("/sbin/udevsettle",args);
diff --git a/loader2/hdinstall.c b/loader2/hdinstall.c
index 1f0ea6985..e71465c1f 100644
--- a/loader2/hdinstall.c
+++ b/loader2/hdinstall.c
@@ -56,7 +56,7 @@ extern uint64_t flags;
/* given a partition device and directory, tries to mount hd install image */
static char * setupIsoImages(char * device, char * dirName, char * location) {
- int rc;
+ int rc = 0;
char *url = NULL, *dirspec, *updpath, *path;
char *typetry[] = {"ext3", "ext2", "vfat", NULL};
char **type;
@@ -73,17 +73,37 @@ static char * setupIsoImages(char * device, char * dirName, char * location) {
if (!type)
return NULL;
- rc = asprintf(&dirspec, "/mnt/isodir%.*s", (int) (strrchr(dirName, '/') - dirName), dirName);
- rc = asprintf(&path, "/mnt/isodir%s", dirName);
+ if (asprintf(&dirspec, "/mnt/isodir%.*s",
+ (int) (strrchr(dirName, '/') - dirName), dirName) == -1) {
+ logMessage(CRITICAL, "%s: %d: %s", __func__, __LINE__,
+ strerror(errno));
+ abort();
+ }
+
+ if (asprintf(&path, "/mnt/isodir%s", dirName) == -1) {
+ logMessage(CRITICAL, "%s: %d: %s", __func__, __LINE__,
+ strerror(errno));
+ abort();
+ }
if (path) {
logMessage(INFO, "Path to stage2 image is %s", path);
- rc = asprintf(&updpath, "%s/updates.img", dirspec);
+ if (asprintf(&updpath, "%s/updates.img", dirspec) == -1) {
+ logMessage(CRITICAL, "%s: %d: %s", __func__, __LINE__,
+ strerror(errno));
+ abort();
+ }
+
logMessage(INFO, "Looking for updates for HD in %s", updpath);
copyUpdatesImg(updpath);
- rc = asprintf(&updpath, "%s/product.img", dirspec);
+ if (asprintf(&updpath, "%s/product.img", dirspec) == -1) {
+ logMessage(CRITICAL, "%s: %d: %s", __func__, __LINE__,
+ strerror(errno));
+ abort();
+ }
+
logMessage(INFO, "Looking for product for HD in %s", updpath);
copyProductImg(updpath);
@@ -97,8 +117,13 @@ static char * setupIsoImages(char * device, char * dirName, char * location) {
umountLoopback("/mnt/runtime", "/dev/loop0");
goto err;
} else {
- rc = asprintf(&url, "hd:%s:%s:/%s", device, *type,
- dirName ? dirName : ".");
+ if (asprintf(&url, "hd:%s:%s:/%s", device, *type,
+ dirName ? dirName : ".") == -1) {
+ logMessage(CRITICAL, "%s: %d: %s", __func__, __LINE__,
+ strerror(errno));
+ abort();
+ }
+
return url;
}
} else {
@@ -213,12 +238,17 @@ char * mountHardDrive(struct installMethod * method,
}
/* now find out which partition has the stage2 image*/
- rc = asprintf(&buf, _("What partition and directory on that "
- "partition hold the installation images "
- "for %s? If you don't see the disk drive "
- "you're using listed here, press F2 to "
- "configure additional devices."),
- getProductName());
+ if (asprintf(&buf, _("What partition and directory on that "
+ "partition hold the installation images "
+ "for %s? If you don't see the disk drive "
+ "you're using listed here, press F2 to "
+ "configure additional devices."),
+ getProductName()) == -1) {
+ logMessage(CRITICAL, "%s: %d: %s", __func__, __LINE__,
+ strerror(errno));
+ abort();
+ }
+
text = newtTextboxReflowed(-1, -1, buf, 62, 5, 5, 0);
free(buf);
@@ -308,7 +338,11 @@ char * mountHardDrive(struct installMethod * method,
else
stage2img = "stage2.img";
- rc = asprintf(&dir, "%s/%s", dir, stage2img);
+ if (asprintf(&dir, "%s/%s", dir, stage2img) == -1) {
+ logMessage(CRITICAL, "%s: %d: %s", __func__, __LINE__,
+ strerror(errno));
+ abort();
+ }
url = setupIsoImages(selpart, dir, location);
if (!url) {
diff --git a/loader2/kickstart.c b/loader2/kickstart.c
index 96c2f5e46..3eb5780c1 100644
--- a/loader2/kickstart.c
+++ b/loader2/kickstart.c
@@ -303,7 +303,6 @@ int getKickstartFromBlockDevice(char *device, char *path) {
void getHostPathandLogin(char * ksSource, char **host, char ** file, char ** login, char ** password, char * ip) {
char *tmp;
- int i;
*host = strdup(ksSource);
tmp = strchr(*host, '/');
@@ -325,7 +324,12 @@ void getHostPathandLogin(char * ksSource, char **host, char ** file, char ** log
*/
if ((*file) && (((*file)[strlen(*file) - 1] == '/') ||
((*file)[strlen(*file) - 1] == '\0'))) {
- i = asprintf(file, "%s%s-kickstart", *file, ip);
+ if (asprintf(file, "%s%s-kickstart", *file, ip) == -1) {
+ logMessage(CRITICAL, "%s: %d: %s", __func__, __LINE__,
+ strerror(errno));
+ abort();
+ }
+
logMessage(DEBUGLVL, "getHostandPath file(2): |%s|", *file);
}
diff --git a/loader2/lang.c b/loader2/lang.c
index cbae953d4..8e2267dd3 100644
--- a/loader2/lang.c
+++ b/loader2/lang.c
@@ -263,7 +263,10 @@ static int setupLanguage(int choice, int forced) {
newtDrawRootText(0, 0, buf);
char *fmt = FL_RESCUE(flags) ? _(topLineWelcomeRescue) : _(topLineWelcome);
- i = asprintf(&buf, fmt, getProductName(), getProductArch());
+ if (asprintf(&buf, fmt, getProductName(), getProductArch()) == -1) {
+ logMessage(CRITICAL, "%s: %d: %s", __func__, __LINE__, strerror(errno));
+ abort();
+ }
newtDrawRootText(0, 0, buf);
free(buf);
diff --git a/loader2/loader.c b/loader2/loader.c
index 6edcd36fc..30510557f 100644
--- a/loader2/loader.c
+++ b/loader2/loader.c
@@ -148,7 +148,7 @@ void doShell(void) {
}
void doGdbserver(struct loaderData_s *loaderData) {
- int child, rc, fd;
+ int child, fd;
char *pid;
struct networkDeviceConfig netCfg;
@@ -163,7 +163,11 @@ void doGdbserver(struct loaderData_s *loaderData) {
return;
}
- rc = asprintf(&pid, "%d", loaderPid);
+ if (asprintf(&pid, "%d", loaderPid) == -1) {
+ logMessage(CRITICAL, "%s: %d: %s", __func__, __LINE__,
+ strerror(errno));
+ abort();
+ }
if (!(child = fork())) {
logMessage(INFO, "starting gdbserver: %s %s %s %s",
@@ -193,11 +197,14 @@ void doGdbserver(struct loaderData_s *loaderData) {
void startNewt(void) {
if (!newtRunning) {
char *buf;
- int ignore;
char *arch = getProductArch();
-
- ignore = asprintf(&buf, _("Welcome to %s for %s"), getProductName(),
- arch);
+
+ if (asprintf(&buf, _("Welcome to %s for %s"), getProductName(),
+ arch) == -1) {
+ logMessage(CRITICAL, "%s: %d: %s", __func__, __LINE__,
+ strerror(errno));
+ abort();
+ }
newtInit();
newtCls();
@@ -437,7 +444,11 @@ void loadUpdates(struct loaderData_s *loaderData) {
if (dir == -1)
stage = UPD_DEVICE;
else {
- rc = asprintf(&part, "/dev/%s", device);
+ if (asprintf(&part, "/dev/%s", device) == -1) {
+ logMessage(CRITICAL, "%s: %d: %s", __func__, __LINE__,
+ strerror(errno));
+ abort();
+ }
stage = UPD_PROMPT;
}
@@ -465,8 +476,13 @@ void loadUpdates(struct loaderData_s *loaderData) {
}
case UPD_PROMPT:
- rc = asprintf(&buf, _("Insert your updates disk into %s and "
- "press \"OK\" to continue."), part);
+ if (asprintf(&buf, _("Insert your updates disk into %s and "
+ "press \"OK\" to continue."), part) == -1) {
+ logMessage(CRITICAL, "%s: %d: %s", __func__, __LINE__,
+ strerror(errno));
+ abort();
+ }
+
rc = newtWinChoice(_("Updates Disk"), _("OK"), _("Back"), buf);
free(buf);
@@ -1038,13 +1054,22 @@ static void parseCmdLineFlags(struct loaderData_s * loaderData,
if (!strncasecmp(argv[i], "vesa", 4)) {
if (asprintf(&extraArgs[numExtraArgs],
- "--xdriver=vesa") == -1)
- return;
+ "--xdriver=vesa") == -1) {
+ logMessage(CRITICAL, "%s: %d: %s", __func__, __LINE__,
+ strerror(errno));
+ abort();
+ }
+
logMessage(WARNING, "\"vesa\" command line argument is deprecated. use \"xdriver=vesa\".");
} else {
- if (asprintf(&extraArgs[numExtraArgs],"--%s",argv[i]) == -1)
- return;
+ if (asprintf(&extraArgs[numExtraArgs],"--%s",
+ argv[i]) == -1) {
+ logMessage(CRITICAL, "%s: %d: %s", __func__, __LINE__,
+ strerror(errno));
+ abort();
+ }
}
+
numExtraArgs += 1;
if (numExtraArgs > (MAX_EXTRA_ARGS - 2)) {
@@ -1089,9 +1114,14 @@ static int checkFrameBuffer() {
static void checkForRam(void) {
if (totalMemory() < MIN_RAM) {
char *buf;
- int i;
- i = asprintf(&buf, _("You do not have enough RAM to install %s "
- "on this machine."), getProductName());
+
+ if (asprintf(&buf, _("You do not have enough RAM to install %s "
+ "on this machine."), getProductName()) == -1) {
+ logMessage(CRITICAL, "%s: %d: %s", __func__, __LINE__,
+ strerror(errno));
+ abort();
+ }
+
startNewt();
newtWinMessage(_("Error"), _("OK"), buf);
free(buf);
@@ -1156,9 +1186,14 @@ static char *doLoaderMain(struct loaderData_s *loaderData,
* for the stage2= parameter based on that.
*/
char *tmp;
- int rc;
- rc = asprintf(&tmp, "%s/images/stage2.img", loaderData->instRepo);
+ if (asprintf(&tmp, "%s/images/stage2.img",
+ loaderData->instRepo) == -1) {
+ logMessage(CRITICAL, "%s: %d: %s", __func__, __LINE__,
+ strerror(errno));
+ abort();
+ }
+
logMessage(INFO, "no stage2= given, assuming %s", tmp);
setStage2LocFromCmdline(tmp, loaderData);
free(tmp);
@@ -1537,12 +1572,22 @@ static void migrate_runtime_directory(char * dirname) {
char * runtimedir;
int ret;
- ret = asprintf(&runtimedir, "/mnt/runtime%s", dirname);
+ if (asprintf(&runtimedir, "/mnt/runtime%s", dirname) == -1) {
+ logMessage(CRITICAL, "%s: %d: %s", __func__, __LINE__,
+ strerror(errno));
+ abort();
+ }
+
if (!access(runtimedir, X_OK)) {
if (unlink(dirname) == -1) {
char * olddir;
- ret = asprintf(&olddir, "%s_old", dirname);
+ if (asprintf(&olddir, "%s_old", dirname) == -1) {
+ logMessage(CRITICAL, "%s: %d: %s", __func__, __LINE__,
+ strerror(errno));
+ abort();
+ }
+
ret = rename(dirname, olddir);
free(olddir);
}
@@ -1618,11 +1663,15 @@ static int anaconda_trace_init(void) {
static void add_to_path_env(const char *env, const char *val)
{
char *oldenv, *newenv;
- int rc;
oldenv = getenv(env);
if (oldenv) {
- rc = asprintf(&newenv, "%s:%s", val, oldenv);
+ if (asprintf(&newenv, "%s:%s", val, oldenv) == -1) {
+ logMessage(CRITICAL, "%s: %d: %s", __func__, __LINE__,
+ strerror(errno));
+ abort();
+ }
+
oldenv = strdupa(newenv);
free(newenv);
newenv = oldenv;
@@ -1902,12 +1951,16 @@ int main(int argc, char ** argv) {
path = getenv("PATH");
while (path && path[0]) {
- int ret, n = strcspn(path, ":");
+ int n = strcspn(path, ":");
char c, *binpath;
c = path[n];
path[n] = '\0';
- ret = asprintf(&binpath, "%s/anaconda", path);
+ if (asprintf(&binpath, "%s/anaconda", path) == -1) {
+ logMessage(CRITICAL, "%s: %d: %s", __func__, __LINE__,
+ strerror(errno));
+ abort();
+ }
path[n] = c;
if (!access(binpath, X_OK)) {
diff --git a/loader2/method.c b/loader2/method.c
index 66dff42cb..6dc938344 100644
--- a/loader2/method.c
+++ b/loader2/method.c
@@ -78,7 +78,6 @@ int umountLoopback(char * mntpoint, char * device) {
int mountLoopback(char *fsystem, char *mntpoint, char *device) {
char *opts;
- int rc;
if (device == NULL) {
logMessage(ERROR, "no loopback device given");
@@ -90,7 +89,12 @@ int mountLoopback(char *fsystem, char *mntpoint, char *device) {
return LOADER_ERROR;
}
- rc = asprintf(&opts, "ro,loop=%s", device);
+ if (asprintf(&opts, "ro,loop=%s", device) == -1) {
+ logMessage(CRITICAL, "%s: %d: %s", __func__, __LINE__,
+ strerror(errno));
+ abort();
+ }
+
if (doPwMount(fsystem, mntpoint, "iso9660", opts)) {
if (doPwMount(fsystem, mntpoint, "ext2", opts)) {
if (doPwMount(fsystem, mntpoint, "squashfs", opts)) {
diff --git a/loader2/net.c b/loader2/net.c
index e191f990b..cf42be430 100644
--- a/loader2/net.c
+++ b/loader2/net.c
@@ -285,11 +285,16 @@ static int getWirelessConfig(struct networkDeviceConfig *cfg, char * ifname) {
essid = get_essid(ifname);
}
- rc = asprintf(&buf, _("%s is a wireless network adapter. Please "
- "provide the ESSID and encryption key needed "
- "to access your wireless network. If no key "
- "is needed, leave this field blank and the "
- "install will continue."), ifname);
+ if (asprintf(&buf, _("%s is a wireless network adapter. Please "
+ "provide the ESSID and encryption key needed "
+ "to access your wireless network. If no key "
+ "is needed, leave this field blank and the "
+ "install will continue."), ifname) == -1) {
+ logMessage(CRITICAL, "%s: %d: %s", __func__, __LINE__,
+ strerror(errno));
+ abort();
+ }
+
do {
struct newtWinEntry entry[] = { { N_("ESSID"), &essid, 0 },
{ N_("Encryption Key"), &wepkey, 0 },
@@ -941,7 +946,7 @@ int configureTCPIP(char * device, struct networkDeviceConfig * cfg,
int manualNetConfig(char * device, struct networkDeviceConfig * cfg,
struct networkDeviceConfig * newCfg,
struct intfconfig_s * ipcomps, struct netconfopts * opts) {
- int i, rows, pos, prefix, cidr, q, have[2], stack[2];
+ int i, rows, pos, prefix, cidr, have[2], stack[2];
char *buf = NULL;
char ret[48];
ip_addr_t *tip;
@@ -1058,10 +1063,19 @@ int manualNetConfig(char * device, struct networkDeviceConfig * cfg,
newtEntrySet(ipcomps->ipv6Entry, ret, 1);
}
- if (cfg->dev.set & PUMP_INTFINFO_HAS_IPV6_PREFIX)
- q = asprintf(&buf, "%d", cfg->dev.ipv6_prefixlen);
- else if (newCfg->dev.set & PUMP_INTFINFO_HAS_IPV6_PREFIX)
- q = asprintf(&buf, "%d", newCfg->dev.ipv6_prefixlen);
+ if (cfg->dev.set & PUMP_INTFINFO_HAS_IPV6_PREFIX) {
+ if (asprintf(&buf, "%d", cfg->dev.ipv6_prefixlen) == -1) {
+ logMessage(CRITICAL, "%s: %d: %s", __func__, __LINE__,
+ strerror(errno));
+ abort();
+ }
+ } else if (newCfg->dev.set & PUMP_INTFINFO_HAS_IPV6_PREFIX) {
+ if (asprintf(&buf, "%d", newCfg->dev.ipv6_prefixlen) == -1) {
+ logMessage(CRITICAL, "%s: %d: %s", __func__, __LINE__,
+ strerror(errno));
+ abort();
+ }
+ }
if (buf) {
newtEntrySet(ipcomps->cidr6Entry, buf, 1);
@@ -1120,11 +1134,16 @@ int manualNetConfig(char * device, struct networkDeviceConfig * cfg,
/* main window layout */
grid = newtCreateGrid(1, 3);
- i = asprintf(&buf, _("Enter the IPv4 and/or the IPv6 address and prefix "
- "(address / prefix). For IPv4, the dotted-quad "
- "netmask or the CIDR-style prefix are acceptable. "
- "The gateway and name server fields must be valid IPv4 "
- "or IPv6 addresses."));
+ if (asprintf(&buf,
+ _("Enter the IPv4 and/or the IPv6 address and prefix "
+ "(address / prefix). For IPv4, the dotted-quad "
+ "netmask or the CIDR-style prefix are acceptable. "
+ "The gateway and name server fields must be valid IPv4 "
+ "or IPv6 addresses.")) == -1) {
+ logMessage(CRITICAL, "%s: %d: %s", __func__, __LINE__, strerror(errno));
+ abort();
+ }
+
text = newtTextboxReflowed(-1, -1, buf, 52, 0, 10, 0);
newtGridSetField(grid, 0, 0, NEWT_GRID_COMPONENT, text,
@@ -1416,10 +1435,13 @@ char *doDhcp(struct networkDeviceConfig *dev) {
logMessage(ERROR, "failure running uname() in doDhcp()");
class = "anaconda";
} else {
- int ret;
+ if (asprintf(&class, "anaconda-%s %s %s",
+ kv.sysname, kv.release, kv.machine) == -1) {
+ logMessage(CRITICAL, "%s: %d: %s", __func__, __LINE__,
+ strerror(errno));
+ abort();
+ }
- ret = asprintf(&class, "anaconda-%s %s %s",
- kv.sysname, kv.release, kv.machine);
logMessage(DEBUGLVL, "sending %s as dhcp vendor-class", class);
}
}
diff --git a/loader2/nfsinstall.c b/loader2/nfsinstall.c
index 132465b98..68568d9a6 100644
--- a/loader2/nfsinstall.c
+++ b/loader2/nfsinstall.c
@@ -29,6 +29,7 @@
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
+#include <errno.h>
#include "copy.h"
#include "loader.h"
@@ -58,13 +59,24 @@ int nfsGetSetup(char ** hostptr, char ** dirptr) {
entries[0].text = _("NFS server name:");
entries[0].value = &newServer;
entries[0].flags = NEWT_FLAG_SCROLL;
- rc = asprintf(&entries[1].text, _("%s directory:"), getProductName());
+
+ if (asprintf(&entries[1].text, _("%s directory:"),
+ getProductName()) == -1) {
+ logMessage(CRITICAL, "%s: %d: %s", __func__, __LINE__, strerror(errno));
+ abort();
+ }
+
entries[1].value = &newDir;
entries[1].flags = NEWT_FLAG_SCROLL;
entries[2].text = NULL;
entries[2].value = NULL;
- rc = asprintf(&buf, _("Please enter the server name and path to your %s "
- "images."), getProductName());
+
+ if (asprintf(&buf, _("Please enter the server name and path to your %s "
+ "images."), getProductName()) == -1) {
+ logMessage(CRITICAL, "%s: %d: %s", __func__, __LINE__, strerror(errno));
+ abort();
+ }
+
rc = newtWinEntries(_("NFS Setup"), buf, 60, 5, 15,
24, entries, _("OK"), _("Back"), NULL);
free(buf);
@@ -106,10 +118,18 @@ char * mountNfsImage(struct installMethod * method,
host = ((struct nfsInstallData *)loaderData->stage2Data)->host;
directory = ((struct nfsInstallData *)loaderData->stage2Data)->directory;
- if (((struct nfsInstallData *) loaderData->stage2Data)->mountOpts == NULL)
+ if (((struct nfsInstallData *)
+ loaderData->stage2Data)->mountOpts == NULL) {
mountOpts = strdup("ro");
- else
- rc = asprintf(&mountOpts, "ro,%s", ((struct nfsInstallData *) loaderData->stage2Data)->mountOpts);
+ } else {
+ if (asprintf(&mountOpts, "ro,%s",
+ ((struct nfsInstallData *)
+ loaderData->stage2Data)->mountOpts) == -1) {
+ logMessage(CRITICAL, "%s: %d: %s", __func__, __LINE__,
+ strerror(errno));
+ abort();
+ }
+ }
logMessage(INFO, "host is %s, dir is %s, opts are '%s'", host, directory, mountOpts);
@@ -136,8 +156,14 @@ char * mountNfsImage(struct installMethod * method,
* stage2 image, fix that up now.
*/
substr = strstr(directory, ".img");
- if (!substr || (substr && *(substr+4) != '\0'))
- rc = asprintf(&directory, "%s/images/%s", directory, stage2img);
+ if (!substr || (substr && *(substr+4) != '\0')) {
+ if (asprintf(&directory, "%s/images/%s", directory,
+ stage2img) == -1) {
+ logMessage(CRITICAL, "%s: %d: %s", __func__, __LINE__,
+ strerror(errno));
+ abort();
+ }
+ }
}
stage = NFS_STAGE_MOUNT;
@@ -156,8 +182,14 @@ char * mountNfsImage(struct installMethod * method,
break;
}
- rc = asprintf(&fullPath, "%s:%.*s", host, (int) (strrchr(directory, '/')-directory),
- directory);
+ if (asprintf(&fullPath, "%s:%.*s", host,
+ (int) (strrchr(directory, '/')-directory),
+ directory) == -1) {
+ logMessage(CRITICAL, "%s: %d: %s", __func__, __LINE__,
+ strerror(errno));
+ abort();
+ }
+
logMessage(INFO, "mounting nfs path %s", fullPath);
if (FL_TESTING(flags)) {
@@ -168,7 +200,12 @@ char * mountNfsImage(struct installMethod * method,
stage = NFS_STAGE_NFS;
if (!doPwMount(fullPath, "/mnt/stage2", "nfs", mountOpts)) {
- rc = asprintf(&buf, "/mnt/stage2/%s", strrchr(directory, '/'));
+ if (asprintf(&buf, "/mnt/stage2/%s",
+ strrchr(directory, '/')) == -1) {
+ logMessage(CRITICAL, "%s: %d: %s", __func__, __LINE__,
+ strerror(errno));
+ abort();
+ }
if (!access(buf, R_OK)) {
logMessage(INFO, "can access %s", buf);
@@ -176,7 +213,14 @@ char * mountNfsImage(struct installMethod * method,
if (rc == 0) {
stage = NFS_STAGE_UPDATES;
- rc = asprintf(&url, "nfs:%s:%s", host, directory);
+
+ if (asprintf(&url, "nfs:%s:%s", host,
+ directory) == -1) {
+ logMessage(CRITICAL, "%s: %d: %s", __func__,
+ __LINE__, strerror(errno));
+ abort();
+ }
+
free(buf);
break;
} else {
@@ -199,9 +243,13 @@ char * mountNfsImage(struct installMethod * method,
break;
}
- rc = asprintf(&buf, _("That directory does not seem to "
- "contain a %s installation tree."),
- getProductName());
+ if (asprintf(&buf, _("That directory does not seem to "
+ "contain a %s installation tree."),
+ getProductName()) == -1) {
+ logMessage(CRITICAL, "%s: %d: %s", __func__, __LINE__,
+ strerror(errno));
+ abort();
+ }
newtWinMessage(_("Error"), _("OK"), buf);
free(buf);
@@ -214,12 +262,12 @@ char * mountNfsImage(struct installMethod * method,
case NFS_STAGE_UPDATES: {
char *buf;
- int rc;
- rc = asprintf(&buf, "%.*s/RHupdates", (int) (strrchr(fullPath, '/')-fullPath),
- fullPath);
- if (rc == -1) {
- logMessage(CRITICAL, "Couldn't create RHupdates path, aborting");
+ if (asprintf(&buf, "%.*s/RHupdates",
+ (int) (strrchr(fullPath, '/')-fullPath),
+ fullPath) == -1) {
+ logMessage(CRITICAL, "%s: %d: %s", __func__, __LINE__,
+ strerror(errno));
abort();
}
@@ -298,7 +346,6 @@ int getFileFromNfs(char * url, char * dest, struct loaderData_s * loaderData) {
char * host = NULL, *path = NULL, * file = NULL, * opts = NULL;
char * chk = NULL, *ip = NULL;
int failed = 0;
- int i;
struct networkDeviceConfig netCfg;
if (kickstartNetworkUp(loaderData, &netCfg)) {
@@ -321,11 +368,23 @@ int getFileFromNfs(char * url, char * dest, struct loaderData_s * loaderData) {
tip = &(netCfg.dev.nextServer);
if (!(netCfg.dev.set & PUMP_INTFINFO_HAS_BOOTFILE)) {
inet_ntop(tip->sa_family, IP_ADDR(tip), ret, IP_STRLEN(tip));
- i = asprintf(&url, "%s:%s", ret, "/kickstart/");
+
+ if (asprintf(&url, "%s:%s", ret, "/kickstart/") == -1) {
+ logMessage(CRITICAL, "%s: %d: %s", __func__, __LINE__,
+ strerror(errno));
+ abort();
+ }
+
logMessage(ERROR, "bootp: no bootfile received");
} else {
inet_ntop(tip->sa_family, IP_ADDR(tip), ret, IP_STRLEN(tip));
- i = asprintf(&url, "%s:%s", ret, netCfg.dev.bootFile);
+
+ if (asprintf(&url, "%s:%s", ret, netCfg.dev.bootFile) == -1) {
+ logMessage(CRITICAL, "%s: %d: %s", __func__, __LINE__,
+ strerror(errno));
+ abort();
+ }
+
logMessage(INFO, "bootp: bootfile is %s", netCfg.dev.bootFile);
}
}
@@ -358,10 +417,19 @@ int getFileFromNfs(char * url, char * dest, struct loaderData_s * loaderData) {
*file++ ='\0';
chk = host + strlen(host)-1;
- if (*chk == '/' || *path == '/')
- i = asprintf(&host, "%s%s", host, path);
- else
- i = asprintf(&host, "%s/%s", host, path);
+ if (*chk == '/' || *path == '/') {
+ if (asprintf(&host, "%s%s", host, path) == -1) {
+ logMessage(CRITICAL, "%s: %d: %s", __func__, __LINE__,
+ strerror(errno));
+ abort();
+ }
+ } else {
+ if (asprintf(&host, "%s/%s", host, path) == -1) {
+ logMessage(CRITICAL, "%s: %d: %s", __func__, __LINE__,
+ strerror(errno));
+ abort();
+ }
+ }
}
logMessage(INFO, "file location: nfs:%s/%s", host, file);
@@ -369,7 +437,12 @@ int getFileFromNfs(char * url, char * dest, struct loaderData_s * loaderData) {
if (!doPwMount(host, "/tmp/mnt", "nfs", opts)) {
char * buf;
- i = asprintf(&buf, "/tmp/mnt/%s", file);
+ if (asprintf(&buf, "/tmp/mnt/%s", file) == -1) {
+ logMessage(CRITICAL, "%s: %d: %s", __func__, __LINE__,
+ strerror(errno));
+ abort();
+ }
+
if (copyFile(buf, dest)) {
logMessage(ERROR, "failed to copy file to %s", dest);
failed = 1;
diff --git a/loader2/urlinstall.c b/loader2/urlinstall.c
index ad06d3a6c..a16a4e87a 100644
--- a/loader2/urlinstall.c
+++ b/loader2/urlinstall.c
@@ -29,6 +29,7 @@
#include <string.h>
#include <sys/mount.h>
#include <unistd.h>
+#include <errno.h>
#include "../isys/iface.h"
@@ -59,12 +60,15 @@ static int loadSingleUrlImage(struct iurlinfo * ui, char *path,
if (ui->protocol == URL_METHOD_HTTP) {
char *arch = getProductArch();
char *name = getProductName();
- int q;
- q = asprintf(&ehdrs, "User-Agent: anaconda/%s\r\n"
+ if (asprintf(&ehdrs, "User-Agent: anaconda/%s\r\n"
"X-Anaconda-Architecture: %s\r\n"
"X-Anaconda-System-Release: %s\r\n",
- VERSION, arch, name);
+ VERSION, arch, name) == -1) {
+ logMessage(CRITICAL, "%s: %d: %s", __func__, __LINE__,
+ strerror(errno));
+ abort();
+ }
}
fd = urlinstStartTransfer(ui, path, ehdrs);
@@ -117,7 +121,12 @@ static int loadUrlImages(struct iurlinfo * ui) {
/* grab the updates.img before stage2.img so that we minimize our
* ramdisk usage */
- rc = asprintf(&buf, "%s/%s", path, "updates.img");
+ if (asprintf(&buf, "%s/%s", path, "updates.img") == -1) {
+ logMessage(CRITICAL, "%s: %d: %s", __func__, __LINE__,
+ strerror(errno));
+ abort();
+ }
+
if (!loadSingleUrlImage(ui, buf,
"/tmp/updates-disk.img", "/tmp/update-disk",
"/dev/loop7", 1)) {
@@ -135,7 +144,12 @@ static int loadUrlImages(struct iurlinfo * ui) {
/* grab the product.img before stage2.img so that we minimize our
* ramdisk usage */
- rc = asprintf(&buf, "%s/%s", path, "product.img");
+ if (asprintf(&buf, "%s/%s", path, "product.img") == -1) {
+ logMessage(CRITICAL, "%s: %d: %s", __func__, __LINE__,
+ strerror(errno));
+ abort();
+ }
+
if (!loadSingleUrlImage(ui, buf,
"/tmp/product-disk.img", "/tmp/product-disk",
"/dev/loop7", 1)) {
@@ -148,7 +162,12 @@ static int loadUrlImages(struct iurlinfo * ui) {
free(buf);
- rc = asprintf(&dest, "/tmp/stage2.img");
+ if (asprintf(&dest, "/tmp/stage2.img") == -1) {
+ logMessage(CRITICAL, "%s: %d: %s", __func__, __LINE__,
+ strerror(errno));
+ abort();
+ }
+
rc = loadSingleUrlImage(ui, ui->prefix, dest, "/mnt/runtime", "/dev/loop0", 0);
free(dest);
@@ -166,7 +185,6 @@ char *mountUrlImage(struct installMethod *method, char *location,
struct loaderData_s *loaderData) {
struct iurlinfo ui;
char *url = NULL;
- int rc;
enum { URL_STAGE_MAIN, URL_STAGE_FETCH,
URL_STAGE_DONE } stage = URL_STAGE_MAIN;
@@ -223,7 +241,12 @@ char *mountUrlImage(struct installMethod *method, char *location,
stage2img = "stage2.img";
}
- rc = asprintf(&ui.prefix, "%s/images/%s", ui.prefix, stage2img);
+ if (asprintf(&ui.prefix, "%s/images/%s", ui.prefix,
+ stage2img) == -1) {
+ logMessage(CRITICAL, "%s: %d: %s", __func__,
+ __LINE__, strerror(errno));
+ abort();
+ }
}
}
@@ -308,17 +331,20 @@ int getFileFromUrl(char * url, char * dest,
if (proto == URL_METHOD_HTTP) {
char *arch = getProductArch();
char *name = getProductName();
- int q;
- q = asprintf(&ehdrs, "User-Agent: anaconda/%s\r\n"
+ if (asprintf(&ehdrs, "User-Agent: anaconda/%s\r\n"
"X-Anaconda-Architecture: %s\r\n"
"X-Anaconda-System-Release: %s\r\n",
- VERSION, arch, name);
+ VERSION, arch, name) == -1) {
+ logMessage(CRITICAL, "%s: %d: %s", __func__, __LINE__,
+ strerror(errno));
+ abort();
+ }
}
if (proto == URL_METHOD_HTTP && FL_KICKSTART_SEND_MAC(flags)) {
/* find all ethernet devices and make a header entry for each one */
- int i, q;
+ int i;
char *dev, *mac, *tmpstr;
struct device **devices;
@@ -328,8 +354,12 @@ int getFileFromUrl(char * url, char * dest,
mac = iface_mac2str(dev);
if (mac) {
- q = asprintf(&tmpstr, "X-RHN-Provisioning-MAC-%d: %s %s\r\n",
- i, dev, mac);
+ if (asprintf(&tmpstr, "X-RHN-Provisioning-MAC-%d: %s %s\r\n",
+ i, dev, mac) == -1) {
+ logMessage(CRITICAL, "%s: %d: %s", __func__, __LINE__,
+ strerror(errno));
+ abort();
+ }
if (!ehdrs) {
ehdrs = strdup(tmpstr);
diff --git a/loader2/urls.c b/loader2/urls.c
index 8dd81bc2a..1f9a55e62 100644
--- a/loader2/urls.c
+++ b/loader2/urls.c
@@ -277,7 +277,6 @@ int urlMainSetupPanel(struct iurlinfo * ui) {
newtGrid buttons, grid;
char * chptr;
char * buf = NULL;
- int r;
/* Populate the UI with whatever initial value we've got. */
if (ui && ui->prefix)
@@ -285,8 +284,14 @@ int urlMainSetupPanel(struct iurlinfo * ui) {
buttons = newtButtonBar(_("OK"), &okay, _("Back"), &cancel, NULL);
- r = asprintf(&buf, _("Please enter the URL containing the %s images on your server."),
- getProductName());
+ if (asprintf(&buf,
+ _("Please enter the URL containing the %s images on your server."),
+ getProductName()) == -1) {
+ logMessage(CRITICAL, "%s: %d: %s", __func__, __LINE__,
+ strerror(errno));
+ abort();
+ }
+
reflowedText = newtReflowText(buf, 47, 5, 5, &width, &height);
free(buf);