* StrBufPlain(): secure input arguments; don't strlen(NULL)
authorWilfried Göesgens <willi@citadel.org>
Tue, 23 Mar 2010 22:19:22 +0000 (22:19 +0000)
committerWilfried Göesgens <willi@citadel.org>
Tue, 23 Mar 2010 22:19:22 +0000 (22:19 +0000)
libcitadel/lib/stringbuf.c

index be4da4eb4e90c6b3cbf48fd70c098d3b2500be7a..b96f227697baa79bae078dcf18ce13a23bfbdaba 100644 (file)
@@ -425,6 +425,12 @@ int StrBufPlain(StrBuf *Buf, const char* ptr, int nChars)
        size_t Siz = Buf->BufSize;
        size_t CopySize;
 
+       if (Buf == NULL)
+               return -1;
+       if (ptr == NULL) {
+               FlushStrBuf(Buf);
+               return -1;
+       }
        if (nChars < 0)
                CopySize = strlen(ptr);
        else