summaryrefslogtreecommitdiffstats
path: root/usr.sbin/i4b
diff options
context:
space:
mode:
authorhm <hm@FreeBSD.org>2001-12-27 08:41:10 +0000
committerhm <hm@FreeBSD.org>2001-12-27 08:41:10 +0000
commit04e8094fce906b141d822b3cff38372870a63cc2 (patch)
tree3d4dc6de2860f6ee46b461c82e275f0a61f729f6 /usr.sbin/i4b
parent05b3080b8f1af3fd361f1b1328e4208479d121fe (diff)
downloadFreeBSD-src-04e8094fce906b141d822b3cff38372870a63cc2.zip
FreeBSD-src-04e8094fce906b141d822b3cff38372870a63cc2.tar.gz
Fix potential fclose nullpointer core dumps
MFC after: 1 month
Diffstat (limited to 'usr.sbin/i4b')
-rw-r--r--usr.sbin/i4b/isdnd/log.c8
-rw-r--r--usr.sbin/i4b/isdnd/main.c9
-rw-r--r--usr.sbin/i4b/isdnd/rc_config.c30
3 files changed, 28 insertions, 19 deletions
diff --git a/usr.sbin/i4b/isdnd/log.c b/usr.sbin/i4b/isdnd/log.c
index 34f68d4..7876f13 100644
--- a/usr.sbin/i4b/isdnd/log.c
+++ b/usr.sbin/i4b/isdnd/log.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 1999 Hellmuth Michaelis. All rights reserved.
+ * Copyright (c) 1997, 2001 Hellmuth Michaelis. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -27,11 +27,9 @@
* i4b daemon - logging routines
* -----------------------------
*
- * $Id: log.c,v 1.25 2000/10/09 12:53:29 hm Exp $
- *
* $FreeBSD$
*
- * last edit-date: [Mon Dec 13 21:47:28 1999]
+ * last edit-date: [Wed Dec 26 12:49:45 2001]
*
*---------------------------------------------------------------------------*/
@@ -126,7 +124,7 @@ init_log(void)
void
finish_log(void)
{
- if(uselogfile)
+ if(uselogfile && logfp)
{
fflush(logfp);
fclose(logfp);
diff --git a/usr.sbin/i4b/isdnd/main.c b/usr.sbin/i4b/isdnd/main.c
index 1268866..74e1e63 100644
--- a/usr.sbin/i4b/isdnd/main.c
+++ b/usr.sbin/i4b/isdnd/main.c
@@ -29,7 +29,7 @@
*
* $FreeBSD$
*
- * last edit-date: [Thu Oct 18 13:57:45 2001]
+ * last edit-date: [Wed Dec 26 12:51:00 2001]
*
*---------------------------------------------------------------------------*/
@@ -775,8 +775,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 */
diff --git a/usr.sbin/i4b/isdnd/rc_config.c b/usr.sbin/i4b/isdnd/rc_config.c
index 3c6a4cf..df7d07b 100644
--- a/usr.sbin/i4b/isdnd/rc_config.c
+++ b/usr.sbin/i4b/isdnd/rc_config.c
@@ -29,7 +29,7 @@
*
* $FreeBSD$
*
- * last edit-date: [Fri Jul 20 19:16:27 2001]
+ * last edit-date: [Wed Dec 26 12:57:07 2001]
*
*---------------------------------------------------------------------------*/
@@ -86,17 +86,17 @@ configure(char *filename, int reread)
yyin = fopen(filename, "r");
- if(reread)
- {
- reset_scanner(yyin);
- }
-
- if (yyin == NULL)
+ if(yyin == NULL)
{
log(LL_ERR, "cannot fopen file [%s]", filename);
exit(1);
}
+ if(reread)
+ {
+ reset_scanner(yyin);
+ }
+
yyparse();
monitor_fixup_rights();
@@ -465,8 +465,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
@@ -474,8 +476,10 @@ cfg_setval(int keyword)
DBGL(DL_RCCF, (log(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");
@@ -516,8 +520,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
@@ -525,8 +531,10 @@ cfg_setval(int keyword)
DBGL(DL_RCCF, (log(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");
OpenPOWER on IntegriCloud