From 11997d3b579966f9c69c2315cab60cc8f5893605 Mon Sep 17 00:00:00 2001 From: Stelian Pop Date: Mon, 9 Jun 2008 13:25:40 +0000 Subject: [PATCH] Fix EA restore in debug mode. --- CHANGES | 4 +++- restore/xattr.c | 14 +++++++------- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/CHANGES b/CHANGES index f7c414b..ead4a44 100644 --- a/CHANGES +++ b/CHANGES @@ -1,4 +1,4 @@ -$Id: CHANGES,v 1.293 2008/06/04 19:27:47 stelian Exp $ +$Id: CHANGES,v 1.294 2008/06/09 13:25:40 stelian Exp $ Changes between versions 0.4b41 and 0.4b42 (released xxxxxxxxxxxxxxx) ===================================================================== @@ -48,6 +48,8 @@ Changes between versions 0.4b41 and 0.4b42 (released xxxxxxxxxxxxxxx) restore. Many thanks to Kenneth Porter for the bug report and the testing of the fix. +11. Fix EA restoration in debug mode (Sourceforge bug #1986216). + Changes between versions 0.4b40 and 0.4b41 (released January 2, 2006) ===================================================================== diff --git a/restore/xattr.c b/restore/xattr.c index 2bb88d0..4d24a6f 100644 --- a/restore/xattr.c +++ b/restore/xattr.c @@ -29,7 +29,7 @@ #ifndef lint static const char rcsid[] = - "$Id: xattr.c,v 1.4 2007/02/22 20:12:50 stelian Exp $"; + "$Id: xattr.c,v 1.5 2008/06/09 13:25:40 stelian Exp $"; #endif /* not lint */ #include @@ -547,6 +547,7 @@ xattr_walk(char *buffer, int (*xattr_cb)(char *, char *, int, int, void *), void for (entry = FIRST_ENTRY(buffer); !IS_LAST_ENTRY(entry); entry = EXT2_XATTR_NEXT(entry)) { char name[XATTR_MAXSIZE], value[XATTR_MAXSIZE]; + int size; int off; int convertacl = 0; int convertcon = 0; @@ -583,20 +584,19 @@ xattr_walk(char *buffer, int (*xattr_cb)(char *, char *, int, int, void *), void off = strlen(name); memcpy(name + off, entry->e_name, entry->e_name_len); name[off + entry->e_name_len] = '\0'; + size = entry->e_value_size; - memcpy(value, buffer + VALUE_OFFSET(buffer, entry), entry->e_value_size); + memcpy(value, buffer + VALUE_OFFSET(buffer, entry), size); if (convertacl) { struct posix_acl *acl; - int size; - acl = ext3_acl_from_disk(value, entry->e_value_size); + acl = ext3_acl_from_disk(value, size); if (!acl) return FAIL; size = posix_acl_to_xattr(acl, value, XATTR_MAXSIZE); if (size < 0) return FAIL; - entry->e_value_size = size; free(acl); } @@ -621,14 +621,14 @@ xattr_walk(char *buffer, int (*xattr_cb)(char *, char *, int, int, void *), void return FAIL; } - entry->e_value_size = strlen(con) + 1; + size = strlen(con) + 1; value[0] = 0; strncat(value, con, sizeof value); freecon(con); } #endif - if (xattr_cb(name, value, entry->e_value_size, convertcon, private) != GOOD) + if (xattr_cb(name, value, size, convertcon, private) != GOOD) return FAIL; } -- 2.39.5