Re: [PATCH] allocating error handling in modstub.c

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx
> 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;
 }

[Index of Archives]     [Kickstart]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]
  Powered by Linux