aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHellmuth Michaelis <hm@FreeBSD.org>2001-12-27 08:41:10 +0000
committerHellmuth Michaelis <hm@FreeBSD.org>2001-12-27 08:41:10 +0000
commit94530bc64ff59e2aad26c1cd3a8b2e9603547d92 (patch)
tree3d4dc6de2860f6ee46b461c82e275f0a61f729f6
parent09ec4b8de7637e056763bb694d28392fd0f6605f (diff)
downloadsrc-94530bc64ff59e2aad26c1cd3a8b2e9603547d92.tar.gz
src-94530bc64ff59e2aad26c1cd3a8b2e9603547d92.zip
Fix potential fclose nullpointer core dumps
MFC after: 1 month
Notes
Notes: svn path=/head/; revision=88527
-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 34f68d4023e8..7876f13c86a8 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 126886666a4d..74e1e6321fc3 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 3c6a4cf85867..df7d07bbac11 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");