]> granicus.if.org Git - shadow/commitdiff
Integrate review comments from Julien Cristau
authornekral-guest <nekral-guest@5a98b0ae-9ef6-0310-add3-de5d479b70d7>
Sun, 5 Sep 2010 15:34:42 +0000 (15:34 +0000)
committernekral-guest <nekral-guest@5a98b0ae-9ef6-0310-add3-de5d479b70d7>
Sun, 5 Sep 2010 15:34:42 +0000 (15:34 +0000)
* libmisc/copydir.c: Missing parenthesis in comment.
* libmisc/chowndir.c: Fixed memory leak on failed realloc().
* libmisc/chowndir.c: Make sure the buffer for the path is large
enough.
* libmisc/remove_tree.c: Remove check for NULL before free().

ChangeLog
libmisc/chowndir.c
libmisc/copydir.c
libmisc/remove_tree.c

index 24dc6bb4b4a693e6db172f62dcf84ef99e461343..69acbf195e0dba07ce15bab4b6068e3d4ac9cdd4 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2010-09-05  Nicolas François  <nicolas.francois@centraliens.net>
+
+       Integrate review comments from Julien Cristau
+       * libmisc/copydir.c: Missing parenthesis in comment.
+       * libmisc/chowndir.c: Fixed memory leak on failed realloc().
+       * libmisc/chowndir.c: Make sure the buffer for the path is large
+       enough.
+       * libmisc/remove_tree.c: Remove check for NULL before free().
+
 2010-08-29  Nicolas François  <nicolas.francois@centraliens.net>
 
        * man/po/fr.po: Fix 2 fuzzy strings.
index b297350991063601d89da006d82db79f57734c7a..e2469af6ab6caff8ce6e6f763aa85e41546c86cb 100644 (file)
@@ -96,6 +96,7 @@ int chown_tree (const char *root,
        }
 
        while ((ent = readdir (dir))) {
+               size_t ent_name_len;
                uid_t tmpuid = (uid_t) -1;
                gid_t tmpgid = (gid_t) -1;
 
@@ -113,13 +114,15 @@ int chown_tree (const char *root,
                 * destination files.
                 */
 
-               if (strlen (root) + strlen (ent->d_name) + 2 > new_name_len) {
-                       new_name = realloc (new_name, new_name_len + 1024);
-                       if (NULL == new_name) {
+               ent_name_len = strlen (root) + strlen (ent->d_name) + 2;
+               if (ent_name_len > new_name_len) {
+                       char *tmp = realloc (new_name, ent_name_len);
+                       if (NULL == tmp) {
                                rc = -1;
                                break;
                        }
-                       new_name_len += 1024;
+                       new_name = tmp;
+                       new_name_len = ent_name_len;
                }
 
                (void) snprintf (new_name, new_name_len, "%s/%s", root, ent->d_name);
index 85155ae4ac0ff292f0f4f0b52efb3380356fd67f..5c6c059492b6c6be101e307127c7bca2a9dfe230 100644 (file)
@@ -273,7 +273,7 @@ static /*@exposed@*/ /*@null@*/struct link_name *check_link (const char *name, c
  *     as it goes.
  *
  *     When reset_selinux is enabled, extended attributes (and thus
- *     SELinux attributes are not copied.
+ *     SELinux attributes) are not copied.
  *
  *     old_uid and new_uid are used to set the ownership of the copied
  *     files. Unless old_uid is set to -1, only the files owned by
index a1be00eb94d9fb8f62d179226a8c5e79c7b9a15b..b2794ab404dc1c03a19ee816099137885f3eed66 100644 (file)
@@ -88,9 +88,7 @@ int remove_tree (const char *root, bool remove_root)
                 * Make the filename for the current entry.
                 */
 
-               if (NULL != new_name) {
-                       free (new_name);
-               }
+               free (new_name);
                new_name = (char *) malloc (new_len);
                if (NULL == new_name) {
                        err = -1;