Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed some issues found by static analyzers #2634

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Commits on Mar 6, 2024

  1. fix(dracut-util): memory leak

    Error: RESOURCE_LEAK (CWE-772):
    src/util/util.c:188: alloc_fn: Storage is returned from allocation function "strdup".
    src/util/util.c:188: var_assign: Assigning: "cmdline" = storage returned from "strdup(p)".
    src/util/util.c:209: identity_transfer: Passing "cmdline" as argument 1 to function "next_arg", which returns an offset off that argument.
    src/util/util.c:209: identity_transfer: Passing "cmdline" as argument 1 to function "next_arg", which sets "key" to an offset off that argument.
    src/util/util.c:209: identity_transfer: Passing "cmdline" as argument 1 to function "next_arg", which sets "value" to an offset off that argument.
    src/util/util.c:209: var_assign: Assigning: "cmdline" = storage returned from "next_arg(cmdline, &key, &value)".
    src/util/util.c:210: noescape: Resource "key" is not freed or pointed-to in "strcmp".
    src/util/util.c:219: leaked_storage: Variable "value" going out of scope leaks the storage it points to.
    src/util/util.c:219: leaked_storage: Variable "key" going out of scope leaks the storage it points to.
    src/util/util.c:209: identity_transfer: Passing "cmdline" as argument 1 to function "next_arg", which returns an offset off that argument.
    src/util/util.c:209: identity_transfer: Passing "cmdline" as argument 1 to function "next_arg", which sets "key" to an offset off that argument.
    src/util/util.c:209: identity_transfer: Passing "cmdline" as argument 1 to function "next_arg", which sets "value" to an offset off that argument.
    src/util/util.c:209: var_assign: Assigning: "cmdline" = storage returned from "next_arg(cmdline, &key, &value)".
    src/util/util.c:210: noescape: Resource "key" is not freed or pointed-to in "strcmp".
    src/util/util.c:219: leaked_storage: Variable "value" going out of scope leaks the storage it points to.
    src/util/util.c:219: leaked_storage: Variable "key" going out of scope leaks the storage it points to.
    src/util/util.c:238: leaked_storage: Variable "cmdline" going out of scope leaks the storage it points to.
    lnykryn committed Mar 6, 2024
    Configuration menu
    Copy the full SHA
    83ea625 View commit details
    Browse the repository at this point in the history
  2. fix(dracut-install): buffer overrun

    Error: OVERRUN (CWE-119):
    src/install/dracut-install.c:464: identity_transfer: Passing "4097UL" as argument 3 to function "readlink", which returns that argument. [Note: The source code implementation of the function has been overridden by a builtin model.]
    src/install/dracut-install.c:464: assignment: Assigning: "linksz" = "readlink(fullsrcpath, linktarget, 4097UL)". The value of "linksz" is now 4097.
    src/install/dracut-install.c:467: overrun-local: Overrunning array "linktarget" of 4097 bytes at byte offset 4097 using index "linksz" (which evaluates to 4097).
      465|           if (linksz < 0)
      466|                   return NULL;
      467|->         linktarget[linksz] = '\0';
      468|
      469|           log_debug("get_real_file: readlink('%s') returns '%s'", fullsrcpath, linktarget);
    lnykryn committed Mar 6, 2024
    Configuration menu
    Copy the full SHA
    6e7c1c0 View commit details
    Browse the repository at this point in the history
  3. fix(dracut-util): memory leak

    "Error: RESOURCE_LEAK (CWE-772):
    src/util/util.c:252: alloc_fn: Storage is returned from allocation function ""strdup"".
    src/util/util.c:252: var_assign: Assigning: ""cmdline"" = storage returned from ""strdup(p)"".
    src/util/util.c:273: identity_transfer: Passing ""cmdline"" as argument 1 to function ""next_arg"", which returns an offset off that argument.
    src/util/util.c:273: identity_transfer: Passing ""cmdline"" as argument 1 to function ""next_arg"", which sets ""key"" to an offset off that argument.
    src/util/util.c:273: identity_transfer: Passing ""cmdline"" as argument 1 to function ""next_arg"", which sets ""value"" to an offset off that argument.
    src/util/util.c:273: var_assign: Assigning: ""cmdline"" = storage returned from ""next_arg(cmdline, &key, &value)"".
    src/util/util.c:274: noescape: Resource ""key"" is not freed or pointed-to in ""strcmp"".
    src/util/util.c:289: leaked_storage: Variable ""value"" going out of scope leaks the storage it points to.
    src/util/util.c:289: leaked_storage: Variable ""key"" going out of scope leaks the storage it points to.
    src/util/util.c:273: identity_transfer: Passing ""cmdline"" as argument 1 to function ""next_arg"", which returns an offset off that argument.
    src/util/util.c:273: identity_transfer: Passing ""cmdline"" as argument 1 to function ""next_arg"", which sets ""key"" to an offset off that argument.
    src/util/util.c:273: identity_transfer: Passing ""cmdline"" as argument 1 to function ""next_arg"", which sets ""value"" to an offset off that argument.
    src/util/util.c:273: var_assign: Assigning: ""cmdline"" = storage returned from ""next_arg(cmdline, &key, &value)"".
    src/util/util.c:274: noescape: Resource ""key"" is not freed or pointed-to in ""strcmp"".
    src/util/util.c:289: leaked_storage: Variable ""value"" going out of scope leaks the storage it points to.
    src/util/util.c:289: leaked_storage: Variable ""key"" going out of scope leaks the storage it points to.
    src/util/util.c:290: leaked_storage: Variable ""cmdline"" going out of scope leaks the storage it points to.
      288|                   }
      289|           } while (cmdline[0]);
      290|->         return found_value ? EXIT_SUCCESS : EXIT_FAILURE;
      291|   }
      292|   "
    lnykryn committed Mar 6, 2024
    Configuration menu
    Copy the full SHA
    88918bf View commit details
    Browse the repository at this point in the history
  4. fix(dracut-install): memory leak

    "Error: RESOURCE_LEAK (CWE-772):
    src/install/dracut-install.c:1135: alloc_fn: Storage is returned from allocation function ""strv_split"".
    src/install/dracut-install.c:1135: var_assign: Assigning: ""firmwaredirs"" = storage returned from ""strv_split(optarg, "":"")"".
    src/install/dracut-install.c:1135: overwrite_var: Overwriting ""firmwaredirs"" in ""firmwaredirs = strv_split(optarg, "":"")"" leaks the storage that ""firmwaredirs"" points to.
     1133|                           break;
     1134|                   case ARG_FIRMWAREDIRS:
     1135|->                         firmwaredirs = strv_split(optarg, "":"");
     1136|                           break;
     1137|                   case 'f':"
    lnykryn committed Mar 6, 2024
    Configuration menu
    Copy the full SHA
    9d1742a View commit details
    Browse the repository at this point in the history