On Sun, Oct 02, 2005 at 12:11:06PM -0300, Felipe Almeida Lessa wrote:
> update-menus searches for menu entries on various directories. However,
> when run by a normal user (e.g. not root), all of the directories seen
> must either non-existent or readable (e.g. not "chmod a-r $dir"). When a
> directory exists *and* is not readable it segfaults.
> 
> For example:
> 1) If I don't have the directory ~/.menu, it goes thru the rest of the
> process successfully.
> 2) If I have it empty, it also succeds.
> 3) If I have it with any number of entries, all fine.
> 4) If I have but with no read permission (---, --x, -w- or -wx), it
> segfaults:
> $ LC_ALL=C update-menus -v
> update-menus[15506]: Update-menus is run by user.
> update-menus[15506]: Dpkg is not locking dpkg status area, good.
> update-menus[15506]: Reading installed packages list...
> update-menus[15506]: Reading menu-entry files in /home/felipe/.menu/.
> Segmentation fault

Hello Felipe,

I plan to commit the attached patch to Debian menu CVS,
it should fix this bug, now, it skips the directory.

Thanks to have discovered this problem!
-- 
Bill. <[EMAIL PROTECTED]>

Imagine a large red swirl here. 
Index: update-menus/update-menus.cc
===================================================================
RCS file: /cvsroot/menu/menu/update-menus/update-menus.cc,v
retrieving revision 1.46
diff -u -r1.46 update-menus.cc
--- update-menus/update-menus.cc        21 Jun 2005 19:43:38 -0000      1.46
+++ update-menus/update-menus.cc        2 Oct 2005 16:47:17 -0000
@@ -68,12 +68,12 @@
  */
 DIR *open_dir_check(const string& dirname)
 {
-  struct stat st;
+  DIR *dir = opendir(dirname.c_str());
 
-  if (stat(dirname.c_str(), &st) || (!S_ISDIR (st.st_mode)))
+  if (!dir)
       throw dir_error_read();
 
-  return opendir(dirname.c_str());
+  return dir;
 }
 
 /** Checks whether a file is executable */

Reply via email to