From: Bron Gondwana <br...@launde.home.brong.net> Gosh mboxlist_lookup provides a dangerous interface! --- imap/user.c | 17 +++++++++++++++-- 1 files changed, 15 insertions(+), 2 deletions(-)
diff --git a/imap/user.c b/imap/user.c index 8d439c0..5ae03d7 100644 --- a/imap/user.c +++ b/imap/user.c @@ -91,8 +91,12 @@ static int user_deleteacl(char *name, int matchlen, int maycreate, void* rock) int r; char *acl; char *rights, *nextid; + char *origacl, *aclalloc; - r = mboxlist_lookup(name, &acl, NULL); + r = mboxlist_lookup(name, &origacl, NULL); + + /* setacl re-calls mboxlist_lookup and will stomp on us */ + aclalloc = acl = xstrdup(origacl); while (!r && acl) { rights = strchr(acl, '\t'); @@ -111,6 +115,9 @@ static int user_deleteacl(char *name, int matchlen, int maycreate, void* rock) acl = nextid; } + + free(aclalloc); + return 0; } #endif @@ -370,8 +377,12 @@ int user_renameacl(char *name, char *olduser, char *newuser) int r = 0; char *acl; char *rights, *nextid; + char *origacl, *aclalloc; - r = mboxlist_lookup(name, &acl, NULL); + r = mboxlist_lookup(name, &origacl, NULL); + + /* setacl re-calls mboxlist_lookup and will stomp on us */ + aclalloc = acl = xstrdup(origacl); while (!r && acl) { rights = strchr(acl, '\t'); @@ -393,6 +404,8 @@ int user_renameacl(char *name, char *olduser, char *newuser) acl = nextid; } + free(aclalloc); + return r; } -- 1.5.6.3