Properly check the return value of chdir, even if it is a "this

should not happen" case.

Found with:   Coverity Prevent(tm)
CID:          4932
This commit is contained in:
Edwin Groothuis 2010-06-05 11:06:56 +00:00
parent 5a73d193c4
commit 78c6c39d48
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=208825

View File

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