commit 5c75de7bd690ee7ad3aa5266f453a9f8aeb26861
Author: Oswald Buddenhagen <o...@kde.org>
Date:   Sun Jul 24 20:26:10 2011 +0200

    validate maildirs more strictly
    
    now that "SyncState *" won't create fake mailboxes any more, we can make
    a full validity check again.

 src/drv_maildir.c |   17 ++++++-----------
 1 files changed, 6 insertions(+), 11 deletions(-)

diff --git a/src/drv_maildir.c b/src/drv_maildir.c
index 8b60553..92142ad 100644
--- a/src/drv_maildir.c
+++ b/src/drv_maildir.c
@@ -231,7 +231,7 @@ maildir_validate( const char *prefix, const char *box, int 
create, maildir_store
        DIR *dirp;
        struct dirent *entry;
        time_t now;
-       int i, j, bl;
+       int i, bl;
        struct stat st;
        char buf[_POSIX_PATH_MAX];
 
@@ -245,7 +245,6 @@ maildir_validate( const char *prefix, const char *box, int 
create, maildir_store
                                        maildir_invoke_bad_callback( &ctx->gen 
);
                                        return DRV_CANCELED;
                                }
-                         mkdirs:
                                for (i = 0; i < 3; i++) {
                                        memcpy( buf + bl, subdirs[i], 4 );
                                        if (mkdir( buf, 0700 )) {
@@ -264,16 +263,12 @@ maildir_validate( const char *prefix, const char *box, 
int create, maildir_store
                        return DRV_BOX_BAD;
                }
        } else {
-               for (i = j = 0; i < 3; i++) {
+               for (i = 0; i < 3; i++) {
                        memcpy( buf + bl, subdirs[i], 4 );
-                       if (!stat( buf, &st ) && S_ISDIR(st.st_mode))
-                               j++;
-               }
-               if (!j)
-                       goto mkdirs;
-               if (j != 3) {
-                       error( "Maildir error: '%.*s' is no valid mailbox\n", 
bl, buf );
-                       return DRV_BOX_BAD;
+                       if (stat( buf, &st ) || !S_ISDIR(st.st_mode)) {
+                               error( "Maildir error: '%.*s' is no valid 
mailbox\n", bl, buf );
+                               return DRV_BOX_BAD;
+                       }
                }
                memcpy( buf + bl, "tmp/", 5 );
                bl += 4;

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
isync-devel mailing list
isync-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/isync-devel

Reply via email to