@@ -134,6 +134,8 @@ static bool pop3_reload_config(std::shared_ptr<config_file> gxcfg = nullptr,
134134 printf (" config_file_init %s: %s\n " , opt_config_file, strerror (errno));
135135 return false ;
136136 }
137+ if (pconfig == nullptr )
138+ return false ;
137139 mlog_init (" gromox-pop3" , pconfig->get_value (" pop3_log_file" ),
138140 pconfig->get_ll (" pop3_log_level" ),
139141 pconfig->get_value (" running_identity" ));
@@ -145,6 +147,8 @@ static bool pop3_reload_config(std::shared_ptr<config_file> gxcfg = nullptr,
145147 mlog (LV_ERR, " config_file_init %s: %s" , opt_config_file, strerror (errno));
146148 return false ;
147149 }
150+ if (gxcfg == nullptr )
151+ return false ;
148152 g_haproxy_level = gxcfg->get_ll (" pop3_accept_haproxy" );
149153 if (g_haproxy_level > 0 )
150154 mlog (LV_NOTICE, " All incoming connections must be HAPROXY type %u" , g_haproxy_level);
@@ -382,11 +386,11 @@ int main(int argc, char **argv)
382386 pop3_cfg_defaults);
383387 if (opt_config_file != nullptr && g_config_file == nullptr )
384388 printf (" [resource]: config_file_init %s: %s\n " , opt_config_file, strerror (errno));
385- if (g_config_file == nullptr )
386- return EXIT_FAILURE;
387389 auto gxconfig = config_file_prg (opt_config_file, " gromox.cfg" , gromox_cfg_defaults);
388390 if (opt_config_file != nullptr && gxconfig == nullptr )
389391 mlog (LV_ERR, " %s: %s" , opt_config_file, strerror (errno));
392+ if (g_config_file == nullptr || gxconfig == nullptr )
393+ return EXIT_FAILURE; /* e.g. permission error */
390394 if (!pop3_reload_config (gxconfig, g_config_file))
391395 return EXIT_FAILURE;
392396
0 commit comments