diff --git a/hw/xfree86/common/xf86Config.c b/hw/xfree86/common/xf86Config.c index e98db459b4..0bf7769f3e 100644 --- a/hw/xfree86/common/xf86Config.c +++ b/hw/xfree86/common/xf86Config.c @@ -202,7 +202,10 @@ xf86ValidateFontPath(char *path) continue; } else { - XNFasprintf(&p1, "%s%s", dir_elem, DIR_FILE); + if (asprintf(&p1, "%s%s", dir_elem, DIR_FILE) == -1) { + xf86ErrorF("malloc failed\n"); + continue; + } flag = stat(p1, &stat_buf); if (flag == 0) if (!S_ISREG(stat_buf.st_mode)) diff --git a/hw/xfree86/common/xf86Configure.c b/hw/xfree86/common/xf86Configure.c index b94ee7a08a..c7adf57807 100644 --- a/hw/xfree86/common/xf86Configure.c +++ b/hw/xfree86/common/xf86Configure.c @@ -205,14 +205,17 @@ configureScreenSection(int screennum) { int i; int depths[] = { 1, 4, 8, 15, 16, 24 /*, 32 */ }; - char *tmp; + char *tmp = NULL; parsePrologue(XF86ConfScreenPtr, XF86ConfScreenRec); - XNFasprintf(&tmp, "Screen%d", screennum); + if (asprintf(&tmp, "Screen%d", screennum) == -1) + return NULL; ptr->scrn_identifier = tmp; - XNFasprintf(&tmp, "Monitor%d", screennum); + if (asprintf(&tmp, "Monitor%d", screennum) == -1) + return NULL; ptr->scrn_monitor_str = tmp; - XNFasprintf(&tmp, "Card%d", screennum); + if (asprintf(&tmp, "Card%d", screennum) == -1) + return NULL; ptr->scrn_device_str = tmp; for (i = 0; i < ARRAY_SIZE(depths); i++) { @@ -368,7 +371,7 @@ configureLayoutSection(void) } for (scrnum = 0; scrnum < nDevToConfig; scrnum++) { - char *tmp; + char *tmp = NULL; XF86ConfAdjacencyPtr aptr = calloc(1, sizeof(XF86ConfAdjacencyRec)); assert(aptr); @@ -376,7 +379,7 @@ configureLayoutSection(void) aptr->adj_x = 0; aptr->adj_y = 0; aptr->adj_scrnum = scrnum; - XNFasprintf(&tmp, "Screen%d", scrnum); + asprintf(&tmp, "Screen%d", scrnum); aptr->adj_screen_str = tmp; if (scrnum == 0) { aptr->adj_where = CONF_ADJ_ABSOLUTE; @@ -384,7 +387,8 @@ configureLayoutSection(void) } else { aptr->adj_where = CONF_ADJ_RIGHTOF; - XNFasprintf(&tmp, "Screen%d", scrnum - 1); + tmp = NULL; + asprintf(&tmp, "Screen%d", scrnum - 1); aptr->adj_refscreen = tmp; } ptr->lay_adjacency_lst = @@ -443,10 +447,11 @@ configureFilesSection(void) static XF86ConfMonitorPtr configureMonitorSection(int screennum) { - char *tmp; + char *tmp = NULL; parsePrologue(XF86ConfMonitorPtr, XF86ConfMonitorRec); - XNFasprintf(&tmp, "Monitor%d", screennum); + if (asprintf(&tmp, "Monitor%d", screennum) == -1) + return NULL; ptr->mon_identifier = tmp; ptr->mon_vendor = XNFstrdup("Monitor Vendor"); ptr->mon_modelname = XNFstrdup("Monitor Model"); @@ -492,10 +497,12 @@ configureDDCMonitorSection(int screennum) parsePrologue(XF86ConfMonitorPtr, XF86ConfMonitorRec); - XNFasprintf(&tmp, "Monitor%d", screennum); + if (asprintf(&tmp, "Monitor%d", screennum) == -1) + return NULL; ptr->mon_identifier = tmp; ptr->mon_vendor = XNFstrdup(ConfiguredMonitor->vendor.name); - XNFasprintf(&ptr->mon_modelname, "%x", ConfiguredMonitor->vendor.prod_id); + if (asprintf(&ptr->mon_modelname, "%x", ConfiguredMonitor->vendor.prod_id) == -1) + FatalError("malloc failed\n"); /* features in centimetres, we want millimetres */ mon_width = 10 * ConfiguredMonitor->features.hsize; @@ -866,8 +873,11 @@ DoShowOptions(void) xf86DriverList[i]->driverName); continue; } - XNFasprintf(&pSymbol, "%sModuleData", - xf86DriverList[i]->driverName); + if (asprintf(&pSymbol, "%sModuleData", + xf86DriverList[i]->driverName) == -1) { + ErrorF("(EE) malloc failed\n"); + continue; + } initData = LoaderSymbol(pSymbol); if (initData) { XF86ModuleVersionInfo *vers = initData->vers; diff --git a/hw/xfree86/common/xf86pciBus.c b/hw/xfree86/common/xf86pciBus.c index 62648efafc..10afea69ca 100644 --- a/hw/xfree86/common/xf86pciBus.c +++ b/hw/xfree86/common/xf86pciBus.c @@ -1444,14 +1444,15 @@ xf86PciConfigureNewDev(void *busData, struct pci_device *pVideo, GDevRec * GDev, int *chipset) { char busnum[8]; - char *tmp; + char *tmp = NULL; pVideo = (struct pci_device *) busData; snprintf(busnum, sizeof(busnum), "%d", pVideo->bus); - XNFasprintf(&tmp, "PCI:%s:%d:%d", - busnum, pVideo->dev, pVideo->func); + if (asprintf(&tmp, "PCI:%s:%d:%d", + busnum, pVideo->dev, pVideo->func) == -1) + FatalError("malloc failed\n"); GDev->busID = tmp; GDev->chipID = pVideo->device_id; diff --git a/hw/xfree86/common/xf86platformBus.c b/hw/xfree86/common/xf86platformBus.c index 19588d76c6..0e8e7d1a33 100644 --- a/hw/xfree86/common/xf86platformBus.c +++ b/hw/xfree86/common/xf86platformBus.c @@ -286,8 +286,9 @@ xf86platformProbe(void) if (cl->modulepath && xf86ModPathFrom != X_CMDLINE) { old_path = path; - XNFasprintf(&path, "%s,%s", cl->modulepath, - path ? path : xf86ModulePath); + if (asprintf(&path, "%s,%s", cl->modulepath, + path ? path : xf86ModulePath) == -1) + FatalError("malloc failed\n"); free(old_path); LogMessageVerb(X_CONFIG, 1, "OutputClass \"%s\" ModulePath extended to \"%s\"\n", cl->identifier, path); diff --git a/hw/xfree86/common/xf86sbusBus.c b/hw/xfree86/common/xf86sbusBus.c index c31edd4c4e..5bf3e2222f 100644 --- a/hw/xfree86/common/xf86sbusBus.c +++ b/hw/xfree86/common/xf86sbusBus.c @@ -717,7 +717,7 @@ void xf86SbusConfigureNewDev(void *busData, sbusDevicePtr sBus, GDevRec * GDev) { char *promPath = NULL; - char *tmp; + char *tmp = NULL; sBus = (sbusDevicePtr) busData; GDev->identifier = sBus->descr; @@ -726,11 +726,11 @@ xf86SbusConfigureNewDev(void *busData, sbusDevicePtr sBus, GDevRec * GDev) sparcPromClose(); } if (promPath) { - XNFasprintf(&tmp, "SBUS:%s", promPath); + asprintf(&tmp, "SBUS:%s", promPath); free(promPath); } else { - XNFasprintf(&tmp, "SBUS:fb%d", sBus->fbNum); + asprintf(&tmp, "SBUS:fb%d", sBus->fbNum); } GDev->busID = tmp; }