Don't die if the value is NULL (Coverity CID 98).
[openssl.git] / crypto / conf / conf_mod.c
index 459a2d7..7c9b42f 100644 (file)
@@ -165,7 +165,7 @@ int CONF_modules_load(const CONF *cnf, const char *appname,
 int CONF_modules_load_file(const char *filename, const char *appname,
                           unsigned long flags)
        {
-       char *file;
+       char *file = NULL;
        CONF *conf = NULL;
        int ret = 0;
        conf = NCONF_new(NULL);
@@ -230,9 +230,9 @@ static int module_run(const CONF *cnf, char *name, char *value,
                {
                if (!(flags & CONF_MFLAGS_SILENT))
                        {
-                       char rcode[10];
-                       CONFerr(CONF_F_CONF_MODULES_LOAD, CONF_R_MODULE_INITIALIZATION_ERROR);
-                       sprintf(rcode, "%-8d", ret);
+                       char rcode[DECIMAL_SIZE(ret)+1];
+                       CONFerr(CONF_F_MODULE_RUN, CONF_R_MODULE_INITIALIZATION_ERROR);
+                       BIO_snprintf(rcode, sizeof rcode, "%-8d", ret);
                        ERR_add_error_data(6, "module=", name, ", value=", value, ", retcode=", rcode);
                        }
                }
@@ -254,7 +254,7 @@ static CONF_MODULE *module_load_dso(const CONF *cnf, char *name, char *value,
        path = NCONF_get_string(cnf, value, "path");
        if (!path)
                {
-               ERR_get_error();
+               ERR_clear_error();
                path = name;
                }
        dso = DSO_load(NULL, path, NULL, 0);
@@ -561,11 +561,11 @@ char *CONF_get1_default_config_file(void)
 
        if (!file)
                return NULL;
-       strcpy(file,X509_get_default_cert_area());
+       BUF_strlcpy(file,X509_get_default_cert_area(),len + 1);
 #ifndef OPENSSL_SYS_VMS
-       strcat(file,"/");
+       BUF_strlcat(file,"/",len + 1);
 #endif
-       strcat(file,OPENSSL_CONF);
+       BUF_strlcat(file,OPENSSL_CONF,len + 1);
 
        return file;
        }
@@ -576,13 +576,19 @@ char *CONF_get1_default_config_file(void)
  * be used to parse comma separated lists for example.
  */
 
-int CONF_parse_list(const char *list, int sep, int nospc,
+int CONF_parse_list(const char *list_, int sep, int nospc,
        int (*list_cb)(const char *elem, int len, void *usr), void *arg)
        {
        int ret;
        const char *lstart, *tmpend, *p;
-       lstart = list;
 
+       if(list_ == NULL)
+               {
+               CONFerr(CONF_F_CONF_PARSE_LIST, CONF_R_LIST_CANNOT_BE_NULL);
+               return 0;
+               }
+
+       lstart = list_;
        for(;;)
                {
                if (nospc)