* StrBufSanitizeEmailRecipientVector () fix null pointer accesses
authorWilfried Göesgens <willi@citadel.org>
Sat, 24 Jul 2010 10:30:45 +0000 (10:30 +0000)
committerWilfried Göesgens <willi@citadel.org>
Sat, 24 Jul 2010 10:30:45 +0000 (10:30 +0000)
libcitadel/lib/stringbuf.c

index 861c1d2f991b10e06c42a4b17bf0b43fae67db83..250b3109c4b57f97fdbceac74ac6cae2e576cc0a 100644 (file)
@@ -2582,19 +2582,24 @@ StrBuf *StrBufSanitizeEmailRecipientVector(const StrBuf *Recp,
                        }
                }
 
-
-               if (UserStart != NULL)
+               if ((UserStart != NULL) && (UserEnd != NULL))
+                       StrBufPlain(UserName, UserStart, UserEnd - UserStart);
+               else if ((UserStart != NULL) && (UserEnd == NULL))
                        StrBufPlain(UserName, UserStart, UserEnd - UserStart);
                else
                        FlushStrBuf(UserName);
-               if (EmailStart != NULL)
+
+               if ((EmailStart != NULL) && (EmailEnd != NULL))
                        StrBufPlain(EmailAddress, EmailStart, EmailEnd - EmailStart);
+               else if ((EmailStart != NULL) && (EmailEnd == NULL))
+                       StrBufPlain(EmailAddress, EmailStart, EmailEnd - pche);
                else 
                        FlushStrBuf(EmailAddress);
 
                AddRecipient(Target, UserName, EmailAddress, EncBuf);
 
-
+               if (pch == NULL)
+                       break;
                
                if ((pch != NULL) && (*pch == ','))
                        pch ++;