tag 358994 patch
thanks buddy

On Sun, May 21, 2006 at 01:27:10AM -0500, Enrico Zini wrote:
Hello,

> the problem is in the function gbcommon_calc_dir_size in
> src/gbcommon.c
> 
> The function does not seem to have any logic to prevent visiting the
> same directory twice.
> 
> The way to do it and still get accurate directory size results is to
> maintain a set of visited inodes (that one can get from s.st_ino) and
> avoiding calling gbcommon_calc_dir_size on a directory whose inode has
> already been visited.

Or to not follow symlinks.
Patch attached do this.

Cheers,
-- 
Julien Danjou
// <[EMAIL PROTECTED]>     http://julien.danjou.info
// 9A0D 5FD9 EB42 22F6 8974  C95C A462 B51E C2FE E5CD
// Don't give up.
diff -ru gnomebaker-0.5.1/src/gbcommon.c gnomebaker-0.5.1.jd/src/gbcommon.c
--- gnomebaker-0.5.1/src/gbcommon.c     2006-02-03 23:28:02.000000000 +0100
+++ gnomebaker-0.5.1.jd/src/gbcommon.c  2006-06-02 16:52:44.000000000 +0200
@@ -111,10 +111,10 @@
                        gchar* fullname = g_build_filename(dirname, name, NULL);
        
                        GB_DECLARE_STRUCT(struct stat, s);
-                       if(stat(fullname, &s) == 0)
+                       if(lstat(fullname, &s) == 0)
                        {
                                /* see if the name is actually a directory or a 
regular file */
-                               if(s.st_mode & S_IFDIR)
+                               if(S_ISDIR(s.st_mode))
                                        size += 
gbcommon_calc_dir_size(fullname);
                                else if(s.st_mode & S_IFREG)
                                        size += (guint64)s.st_size;

Attachment: signature.asc
Description: Digital signature

Reply via email to