From: Wilfried Göesgens Date: Sun, 3 Jan 2010 23:44:40 +0000 (+0000) Subject: * some more input condition sanitizing X-Git-Tag: v7.86~533 X-Git-Url: https://code.citadel.org/?p=citadel.git;a=commitdiff_plain;h=fb6875c10bab571b436b20e51b21d0af426c03e3 * some more input condition sanitizing --- diff --git a/libcitadel/lib/stringbuf.c b/libcitadel/lib/stringbuf.c index 400fddbfc..6c068c580 100644 --- a/libcitadel/lib/stringbuf.c +++ b/libcitadel/lib/stringbuf.c @@ -293,7 +293,7 @@ static int IncreaseBuf(StrBuf *Buf, int KeepOriginal, int DestSize) */ void ReAdjustEmptyBuf(StrBuf *Buf, long ThreshHold, long NewSize) { - if (Buf->BufUsed > ThreshHold) { + if ((Buf != NULL) && (Buf->BufUsed > ThreshHold)) { free(Buf->buf); Buf->buf = (char*) malloc(NewSize); Buf->BufUsed = 0; @@ -310,6 +310,8 @@ void ReAdjustEmptyBuf(StrBuf *Buf, long ThreshHold, long NewSize) */ long StrBufShrinkToFit(StrBuf *Buf, int Force) { + if (Buf == NULL) + return -1; if (Force || (Buf->BufUsed + (Buf->BufUsed / 3) > Buf->BufSize)) { @@ -2174,6 +2176,9 @@ long StrBufUnescape(StrBuf *Buf, int StripBlanks) char hex[3]; long len; + if (Buf == NULL) + return -1; + while ((Buf->BufUsed > 0) && (isspace(Buf->buf[Buf->BufUsed - 1]))){ Buf->buf[Buf->BufUsed - 1] = '\0'; Buf->BufUsed --;