svn commit: r208825 - head/usr.bin/calendar

Edwin Groothuis edwin at FreeBSD.org
Sat Jun 5 11:06:56 UTC 2010


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 &&


More information about the svn-src-all mailing list