[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]
Re: [PATCH] allocating error handling in modstub.c
- From: HARA Hiroshi <hhara miraclelinux com>
- To: Discussion of Development and Customization of the Red Hat Linux Installer <anaconda-devel-list redhat com>
- Subject: Re: [PATCH] allocating error handling in modstub.c
- Date: Fri, 31 Aug 2007 14:16:00 +0900
Hi, again
a Caller to ourInsmodCommand will exit right after returning
ourInsmodCommand in anaconda, so additional free is not needed
currently.
but I added "free" for more safety.
thank you
HARA Hiroshi wrote:
> Hi,
>
> I added checking code after strdup and realloc
> in modstub.c
>
> thank you.
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> Anaconda-devel-list mailing list
> Anaconda-devel-list redhat com
> https://www.redhat.com/mailman/listinfo/anaconda-devel-list
--- loader2/modstubs.c 14 Aug 2007 19:23:41 -0000 1.15
+++ loader2/modstubs.c 31 Aug 2007 05:06:00 -0000
@@ -95,6 +95,12 @@
return usage();
}
+ if (!options) {
+ logMessage(ERROR, "cannot allocate memory for options: %s",
+ strerror(errno));
+ return 1;
+ }
+
while (argc > 2) {
if (!strcmp(argv[1], "-p")) {
ballPath = malloc(strlen(argv[2]) + 30);
@@ -143,6 +149,11 @@
for (i = 2; i < argc; i++) {
options = realloc(options,
strlen(options) + 1 + strlen(argv[i]) + 1);
+ if (!options) {
+ logMessage(ERROR, "cannot allocate memory for options: %s",
+ strerror(errno));
+ return 1;
+ }
strcat(options, argv[i]);
strcat(options, " ");
}
@@ -150,6 +161,7 @@
rc = init_module(modbuf, sb.st_size, options);
if (rc != 0)
logMessage(WARNING, "failed to insert module (%d)", errno);
+ free(options);
return rc;
}
[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]