isdnd(8): Fix some NULL dereferences.
authorSascha Wildner <saw@online.de>
Wed, 15 Jul 2009 10:56:15 +0000 (12:56 +0200)
committerSascha Wildner <saw@online.de>
Wed, 15 Jul 2009 10:56:15 +0000 (12:56 +0200)
Taken-from: FreeBSD

usr.sbin/i4b/isdnd/log.c
usr.sbin/i4b/isdnd/main.c
usr.sbin/i4b/isdnd/rc_config.c

index 29583dc..40731cd 100644 (file)
@@ -126,7 +126,7 @@ init_log(void)
 void
 finish_log(void)
 {
-       if(uselogfile)
+       if(uselogfile && logfp)
        {
                fflush(logfp);
                fclose(logfp);
index 8cde0ee..2747730 100644 (file)
@@ -776,8 +776,11 @@ reopenfiles(int dummy)
        {
                /* close file */
 
-               fflush(acctfp);
-               fclose(acctfp);
+               if(acctfp)
+               {
+                       fflush(acctfp);
+                       fclose(acctfp);
+               }
 
                /* if user specified a suffix, rename the old file */
 
index 9043295..3a3d83e 100644 (file)
@@ -76,17 +76,17 @@ configure(char *filename, int reread)
 
        yyin = fopen(filename, "r");
 
-       if(reread)
-       {
-               reset_scanner(yyin);
-       }
-       
-       if (yyin == NULL)
+       if(yyin == NULL)
        {
                dolog(LL_ERR, "cannot fopen file [%s]", filename);
                exit(1);
        }
 
+       if(reread)
+       {
+               reset_scanner(yyin);
+       }
+       
        yyparse();
        
        monitor_fixup_rights();
@@ -455,8 +455,10 @@ cfg_setval(int keyword)
                                                fclose(fp);
                                                fp = fopen(yylval.str, "w");
                                                if(fp != NULL)
+                                               {
                                                        fprintf(fp, "%d %d %d", (int)time(NULL), (int)time(NULL), 0);
-                                               fclose(fp);
+                                                       fclose(fp);
+                                               }
                                        }
                                }
                                else
@@ -464,8 +466,10 @@ cfg_setval(int keyword)
                                        DBGL(DL_RCCF, (dolog(LL_DBG, "entry %d: creating budget-callbacksfile %s", entrycount, yylval.str)));
                                        fp = fopen(yylval.str, "w");
                                        if(fp != NULL)
+                                       {
                                                fprintf(fp, "%d %d %d", (int)time(NULL), (int)time(NULL), 0);
-                                       fclose(fp);
+                                               fclose(fp);
+                                       }
                                }
 
                                fp = fopen(yylval.str, "r");
@@ -506,8 +510,10 @@ cfg_setval(int keyword)
                                                fclose(fp);
                                                fp = fopen(yylval.str, "w");
                                                if(fp != NULL)
+                                               {
                                                        fprintf(fp, "%d %d %d", (int)time(NULL), (int)time(NULL), 0);
-                                               fclose(fp);
+                                                       fclose(fp);
+                                               }
                                        }
                                }
                                else
@@ -515,8 +521,10 @@ cfg_setval(int keyword)
                                        DBGL(DL_RCCF, (dolog(LL_DBG, "entry %d: creating budget-calloutsfile %s", entrycount, yylval.str)));
                                        fp = fopen(yylval.str, "w");
                                        if(fp != NULL)
+                                       {
                                                fprintf(fp, "%d %d %d", (int)time(NULL), (int)time(NULL), 0);
-                                       fclose(fp);
+                                               fclose(fp);
+                                       }
                                }
 
                                fp = fopen(yylval.str, "r");