]> git.ozlabs.org Git - ppp.git/commitdiff
pppd/options.c: handle malloc failure (#425)
authorIlya Shipitsin <chipitsine@gmail.com>
Thu, 3 Aug 2023 09:32:26 +0000 (11:32 +0200)
committerGitHub <noreply@github.com>
Thu, 3 Aug 2023 09:32:26 +0000 (19:32 +1000)
Signed-off-by: Ilya Shipitsin <chipitsine@gmail.com>
pppd/options.c

index 42e39b8ea96c53950c71c69218d5a5803f2749c4..4b3e93ed1fbdc93c07d2847e58e230d837619c89 100644 (file)
@@ -1842,6 +1842,10 @@ user_setenv(char **argv)
     /* The name never changes, so allocate it with the structure */
     if (uep == NULL) {
        uep = malloc(sizeof (*uep) + (eqp-arg));
+       if (uep == NULL) {
+               novm("environment variable");
+               return 1;
+       }
        strncpy(uep->ue_name, arg, eqp-arg);
        uep->ue_name[eqp-arg] = '\0';
        uep->ue_next = NULL;
@@ -1911,6 +1915,10 @@ user_unsetenv(char **argv)
     /* The name never changes, so allocate it with the structure */
     if (uep == NULL) {
        uep = malloc(sizeof (*uep) + strlen(arg));
+       if (uep == NULL) {
+               novm("environment variable");
+               return 1;
+       }
        strcpy(uep->ue_name, arg);
        uep->ue_next = NULL;
        insp = &userenv_list;