From owner-freebsd-bugs@FreeBSD.ORG Sun Sep 12 14:20:22 2004 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id E277A16A4CE for ; Sun, 12 Sep 2004 14:20:22 +0000 (GMT) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id C62A443D55 for ; Sun, 12 Sep 2004 14:20:22 +0000 (GMT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.12.11/8.12.11) with ESMTP id i8CEKMjv089663 for ; Sun, 12 Sep 2004 14:20:22 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.12.11/8.12.11/Submit) id i8CEKMsq089662; Sun, 12 Sep 2004 14:20:22 GMT (envelope-from gnats) Resent-Date: Sun, 12 Sep 2004 14:20:22 GMT Resent-Message-Id: <200409121420.i8CEKMsq089662@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Dan Lukes Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 9933B16A4CF for ; Sun, 12 Sep 2004 14:15:47 +0000 (GMT) Received: from kulesh.obluda.cz (kulesh.obluda.cz [193.179.22.243]) by mx1.FreeBSD.org (Postfix) with ESMTP id 7447F43D31 for ; Sun, 12 Sep 2004 14:15:44 +0000 (GMT) (envelope-from dan@kulesh.obluda.cz) Received: from kulesh.obluda.cz (localhost.eunet.cz [127.0.0.1]) by kulesh.obluda.cz (8.13.1/8.13.1) with ESMTP id i8CEFfUL009718 for ; Sun, 12 Sep 2004 16:15:42 +0200 (CEST) (envelope-from dan@kulesh.obluda.cz) Received: (from root@localhost) by kulesh.obluda.cz (8.13.1/8.13.1/Submit) id i8CEFffA009717; Sun, 12 Sep 2004 16:15:41 +0200 (CEST) (envelope-from dan) Message-Id: <200409121415.i8CEFffA009717@kulesh.obluda.cz> Date: Sun, 12 Sep 2004 16:15:41 +0200 (CEST) From: Dan Lukes To: FreeBSD-gnats-submit@FreeBSD.org X-Send-Pr-Version: 3.113 Subject: bin/71651: [PATCH] cron may attept to close unopened file X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: Dan Lukes List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 12 Sep 2004 14:20:23 -0000 >Number: 71651 >Category: bin >Synopsis: [PATCH] cron may attept to close unopened file >Confidential: no >Severity: serious >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Sun Sep 12 14:20:22 GMT 2004 >Closed-Date: >Last-Modified: >Originator: Dan Lukes >Release: FreeBSD 5.3-BETA3 i386 >Organization: Obludarium >Environment: System: FreeBSD kulesh.obluda.cz 5.3-BETA3 FreeBSD 5.3-BETA3 #8: Sun Sep 5 07:06:40 CEST 2004 dan@kulesh.obluda.cz:/usr/obj/usr/src/sys/Dan i386 usr.sbin/cron/lib/misc.c,v 1.11 2002/08/04 04:32:27 tjr usr.sbin/cron/cron/cron.c,v 1.15 2004/05/16 19:29:33 yar usr.sbin/cron/cron/do_command.c,v 1.22 2004/05/16 19:29:33 yar >Description: usr.sbin/cron/lib/misc.c:413: warning: 'deny' might be used uninitialized in this function It's sign of true bug. When fopen of ALLOW_FILE fail for other than ENOENT reason, then "goto out" apply then 'if (deny)' is evaluated and 'fclose(deny)' may be called athought 'deny' is uninitialized variable. I want to eliminate the following warning also, but they are "false-positives" only ...: usr.sbin/cron/cron/cron.c:165: warning: 'otzminute' might be used uninitialized in this function usr.sbin/cron/cron/cron.c:165: warning: 'otzhour' might be used uninitialized in this function usr.sbin/cron/cron/cron.c:165: warning: 'otzdom' might be used uninitialized in this function usr.sbin/cron/cron/cron.c:165: warning: 'otzmonth' might be used uninitialized in this function usr.sbin/cron/cron/cron.c:165: warning: 'otzdow' might be used uninitialized in this function usr.sbin/cron/cron/do_command.c:388: warning: 'mail' might be used uninitialized in this function >How-To-Repeat: N/A >Fix: *** usr.sbin/cron/lib/misc.c.ORIG Wed Aug 7 00:03:16 2002 --- usr.sbin/cron/lib/misc.c Sun Sep 12 15:52:00 2004 *************** *** 419,425 **** if ((allow = fopen(ALLOW_FILE, "r")) == NULL && errno != ENOENT) goto out; if ((deny = fopen(DENY_FILE, "r")) == NULL && errno != ENOENT) ! goto out; Debug(DMISC, ("allow/deny enabled, %d/%d\n", !!allow, !!deny)) #else allow = NULL; --- 419,425 ---- if ((allow = fopen(ALLOW_FILE, "r")) == NULL && errno != ENOENT) goto out; if ((deny = fopen(DENY_FILE, "r")) == NULL && errno != ENOENT) ! goto out1; Debug(DMISC, ("allow/deny enabled, %d/%d\n", !!allow, !!deny)) #else allow = NULL; *************** *** 437,446 **** isallowed = TRUE; #endif } out: if (allow) fclose(allow); - if (deny) - fclose(deny); return (isallowed); } --- 437,446 ---- isallowed = TRUE; #endif } + out1: if (deny) + fclose(deny); out: if (allow) fclose(allow); return (isallowed); } *** usr.sbin/cron/cron/cron.c.ORIG Tue May 18 22:20:13 2004 --- usr.sbin/cron/cron/cron.c Sun Sep 12 16:00:03 2004 *************** *** 162,168 **** static time_t diff = 0, /* time difference in seconds from the last offset change */ difflimit = 0; /* end point for the time zone correction */ struct tm otztm; /* time in the old time zone */ ! int otzminute, otzhour, otzdom, otzmonth, otzdow; register struct tm *tm = localtime(&TargetTime); register int minute, hour, dom, month, dow; register user *u; --- 162,170 ---- static time_t diff = 0, /* time difference in seconds from the last offset change */ difflimit = 0; /* end point for the time zone correction */ struct tm otztm; /* time in the old time zone */ ! int otzminute = otzminute, /* "init" to avoid "might be used uninitialized" warning */ ! otzhour = otzhour, otzdom = otzdom, ! otzmonth = otzmonth, otzdow = otzmonth; register struct tm *tm = localtime(&TargetTime); register int minute, hour, dom, month, dow; register user *u; *** usr.sbin/cron/cron/do_command.c.ORIG Tue May 18 22:20:13 2004 --- usr.sbin/cron/cron/do_command.c Sun Sep 12 16:04:42 2004 *************** *** 385,391 **** ch = getc(in); if (ch != EOF) { ! register FILE *mail; register int bytes = 1; int status = 0; --- 385,391 ---- ch = getc(in); if (ch != EOF) { ! register FILE *mail = mail; /* "init" to avoid "might be used uninitialized" warning */ register int bytes = 1; int status = 0; >Release-Note: >Audit-Trail: >Unformatted: