]> git.ozlabs.org Git - ppp.git/blobdiff - pppd/options.c
pppd/options.c: fix memory leak on error path (#441)
[ppp.git] / pppd / options.c
index f2ff59d85380cbeb339910628aff9ff706e94c8d..227e615c956154b9e14676a0e0f5f1fa58ac41fc 100644 (file)
@@ -452,9 +452,11 @@ ppp_get_path(ppp_path_t type, char *buf, size_t bufsz)
         case PPP_DIR_RUNTIME:
             path = PPP_PATH_VARRUN;
             break;
+#ifdef PPP_WITH_PLUGINS
         case PPP_DIR_PLUGIN:
             path = PPP_PATH_PLUGIN;
             break;
+#endif
         case PPP_DIR_CONF:
             path = PPP_PATH_CONFDIR;
             break;
@@ -477,10 +479,12 @@ ppp_get_filepath(ppp_path_t type, const char *name, char *buf, size_t bufsz)
         case PPP_DIR_RUNTIME:
             path = PPP_PATH_VARRUN;
             break;
+#ifdef PPP_WITH_PLUGINS
         case PPP_DIR_PLUGIN:
             path = PPP_PATH_PLUGIN;
             break;
-        case PPP_DIR_CONF:
+#endif
+       case PPP_DIR_CONF:
             path = PPP_PATH_CONFDIR;
             break;
         }
@@ -597,6 +601,7 @@ ppp_options_from_file(char *filename, int must_exist, int check_prot, int priv)
 
 err:
     fclose(f);
+    free(option_source);
     privileged_option = oldpriv;
     option_source = oldsource;
     return ret;
@@ -1795,6 +1800,8 @@ loadplugin(char **argv)
     }
     info("Plugin %s loaded.", arg);
     (*init)();
+    if (path != arg)
+       free(path);
     return 1;
 
  errclose:
@@ -1836,6 +1843,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;
@@ -1905,6 +1916,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;