Mailinglist Archive: opensuse-bugs (6630 mails)
< Previous | Next > |
[Bug 530313] sane-backends-1.0.20-3.5: missing call to closedir
- From: bugzilla_noreply@xxxxxxxxxx
- Date: Thu, 13 Aug 2009 05:07:34 -0600
- Message-id: <20090813110734.A26B8245514@xxxxxxxxxxxxxxxxxxxxxx>
http://bugzilla.novell.com/show_bug.cgi?id=530313
User jsmeix@xxxxxxxxxx added comment
http://bugzilla.novell.com/show_bug.cgi?id=530313#c1
--- Comment #1 from Johannes Meixner <jsmeix@xxxxxxxxxx> 2009-08-13 05:07:33
MDT ---
I agree that closedir is really missing here
because there could be several directories
because the current code is
-------------------------------------------------------------
while (search_dir && search_dir[0])
{
..
if ((dir = opendir (search_dir)) == 0)
{
DBG_ERR ("cannot read directory `%s' (%s)\n", search_dir,
strerror (errno));
return SANE_FALSE;
}
..
while ((dir_entry = readdir (dir)) != NULL)
{
..
} /* while (direntry) */
..
}
-------------------------------------------------------------
which should be changed to
-------------------------------------------------------------
while (search_dir && search_dir[0])
{
..
if ((dir = opendir (search_dir)) == 0)
{
DBG_ERR ("cannot read directory `%s' (%s)\n", search_dir,
strerror (errno));
return SANE_FALSE;
}
..
while ((dir_entry = readdir (dir)) != NULL)
{
..
} /* while (direntry) */
if ((closedir(dir) != 0)
{
DBG_ERR ("cannot close directory `%s' (%s)\n", search_dir,
strerror (errno));
return SANE_FALSE;
}
..
}
-------------------------------------------------------------
to be safe even if subsequent 'dir = opendir(...)' calls
may implicitely close an already open directory stream.
--
Configure bugmail: http://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
User jsmeix@xxxxxxxxxx added comment
http://bugzilla.novell.com/show_bug.cgi?id=530313#c1
--- Comment #1 from Johannes Meixner <jsmeix@xxxxxxxxxx> 2009-08-13 05:07:33
MDT ---
I agree that closedir is really missing here
because there could be several directories
because the current code is
-------------------------------------------------------------
while (search_dir && search_dir[0])
{
..
if ((dir = opendir (search_dir)) == 0)
{
DBG_ERR ("cannot read directory `%s' (%s)\n", search_dir,
strerror (errno));
return SANE_FALSE;
}
..
while ((dir_entry = readdir (dir)) != NULL)
{
..
} /* while (direntry) */
..
}
-------------------------------------------------------------
which should be changed to
-------------------------------------------------------------
while (search_dir && search_dir[0])
{
..
if ((dir = opendir (search_dir)) == 0)
{
DBG_ERR ("cannot read directory `%s' (%s)\n", search_dir,
strerror (errno));
return SANE_FALSE;
}
..
while ((dir_entry = readdir (dir)) != NULL)
{
..
} /* while (direntry) */
if ((closedir(dir) != 0)
{
DBG_ERR ("cannot close directory `%s' (%s)\n", search_dir,
strerror (errno));
return SANE_FALSE;
}
..
}
-------------------------------------------------------------
to be safe even if subsequent 'dir = opendir(...)' calls
may implicitely close an already open directory stream.
--
Configure bugmail: http://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
< Previous | Next > |