Whamcloud - gitweb
Remove double "//" when listing attributes in the root directory or
authorTheodore Ts'o <tytso@mit.edu>
Fri, 24 Sep 2004 16:16:17 +0000 (12:16 -0400)
committerTheodore Ts'o <tytso@mit.edu>
Fri, 24 Sep 2004 16:16:17 +0000 (12:16 -0400)
when there is a trailing '/' in the directory name.  (Addresses Debian
Bug #272943)

debian/changelog
misc/ChangeLog
misc/lsattr.c

index d3d46cb..3da4cf5 100644 (file)
@@ -1,12 +1,14 @@
 e2fsprogs (1.35-8) unstable; urgency=low
 
+  * Remove double "//" when listing attributes in the root directory or
+       when there is a trailing '/' in the directory name.  (Closes: #272943)
   * Make sure the configure files are newer than configure.in the
        debian/rules file so that a dpkg-source created patch won't
        trigger an attempt rebuild of the configure script.  (Closes: #272558)
   * Make sure /usr/lib/e2initrd_helper is in the e2fsprogs package.  
        (Closes: #272698)
 
- -- Theodore Y. Ts'o <tytso@mit.edu>  Fri, 24 Sep 2004 11:51:36 -0400
+ -- Theodore Y. Ts'o <tytso@mit.edu>  Fri, 24 Sep 2004 12:12:44 -0400
 
 e2fsprogs (1.35-7) unstable; urgency=low
 
index 10af487..f35d5a8 100644 (file)
@@ -1,5 +1,9 @@
 2004-09-24  Theodore Ts'o  <tytso@mit.edu>
 
+       * lsattr.c (lsattr_dir_proc): Avoid double // when listing the
+               root directory, or when there is a trailing '/' in the
+               directory name.  (Addresses Debian Bug #272943)
+
        * Makefile.in: Make sure /usr/lib is created for when we install
                e2initrd_helper.
 
index ff3859f..093f50f 100644 (file)
@@ -125,10 +125,14 @@ static int lsattr_dir_proc (const char * dir_name, struct dirent * de,
 {
        STRUCT_STAT     st;
        char *path;
+       int dir_len = strlen(dir_name);
 
-       path = malloc(strlen (dir_name) + 1 + strlen (de->d_name) + 1);
+       path = malloc(dir_len + strlen (de->d_name) + 2);
 
-       sprintf (path, "%s/%s", dir_name, de->d_name);
+       if (dir_len && dir_name[dir_len-1] == '/')
+               sprintf (path, "%s%s", dir_name, de->d_name);
+       else
+               sprintf (path, "%s/%s", dir_name, de->d_name);
        if (LSTAT (path, &st) == -1)
                perror (path);
        else {