Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 5 Jun 2010 11:06:56 +0000 (UTC)
From:      Edwin Groothuis <edwin@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r208825 - head/usr.bin/calendar
Message-ID:  <201006051106.o55B6uKV004773@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: edwin
Date: Sat Jun  5 11:06:56 2010
New Revision: 208825
URL: http://svn.freebsd.org/changeset/base/208825

Log:
  Properly check the return value of chdir, even if it is a "this
  should not happen" case.
  
  Found with:   Coverity Prevent(tm)
  CID:          4932

Modified:
  head/usr.bin/calendar/io.c

Modified: head/usr.bin/calendar/io.c
==============================================================================
--- head/usr.bin/calendar/io.c	Sat Jun  5 10:16:23 2010	(r208824)
+++ head/usr.bin/calendar/io.c	Sat Jun  5 11:06:56 2010	(r208825)
@@ -226,7 +226,8 @@ opencal(void)
 			char *home = getenv("HOME");
 			if (home == NULL || *home == '\0')
 				errx(1, "cannot get home directory");
-			chdir(home);
+			if (chdir(home) != 0)
+				errx(1, "cannot enter home directory");
 			for (found = i = 0; i < sizeof(calendarHomes) /
 			    sizeof(calendarHomes[0]); i++)
 				if (chdir(calendarHomes[i]) == 0 &&



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201006051106.o55B6uKV004773>