projects
/
citadel.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
6478a99
)
add some nullpointer checks.
author
Wilfried Goesgens
<dothebart@citadel.org>
Sat, 26 May 2012 13:53:36 +0000
(15:53 +0200)
committer
Wilfried Goesgens
<dothebart@citadel.org>
Sat, 26 May 2012 13:53:36 +0000
(15:53 +0200)
libcitadel/lib/stringbuf.c
patch
|
blob
|
history
diff --git
a/libcitadel/lib/stringbuf.c
b/libcitadel/lib/stringbuf.c
index b5bcf22f7a24d11d4b452700e1f5bdb45bc7335f..33701c634ca040a5d0d653bc130017a1d97e4202 100644
(file)
--- a/
libcitadel/lib/stringbuf.c
+++ b/
libcitadel/lib/stringbuf.c
@@
-611,7
+611,7
@@
StrBuf* _NewConstStrBuf(const char* StringConstant, size_t SizeOfStrConstant)
*/
int FlushStrBuf(StrBuf *buf)
{
*/
int FlushStrBuf(StrBuf *buf)
{
- if (
buf == NULL
)
+ if (
(buf == NULL) || (buf->buf == NULL)
)
return -1;
if (buf->ConstBuf)
return -1;
return -1;
if (buf->ConstBuf)
return -1;
@@
-2732,7
+2732,10
@@
int StrBufRFC2047encode(StrBuf **target, const StrBuf *source)
FlushStrBuf(*target);
StrBufAppendBuf(*target, source, 0);
}
FlushStrBuf(*target);
StrBufAppendBuf(*target, source, 0);
}
- return (*target)->BufUsed;
+ if (*target != 0)
+ return (*target)->BufUsed;
+ else
+ return 0;
}
if (*target == NULL)
*target = NewStrBufPlain(NULL, sizeof(headerStr) + source->BufUsed * 2);
}
if (*target == NULL)
*target = NewStrBufPlain(NULL, sizeof(headerStr) + source->BufUsed * 2);
@@
-3080,6
+3083,9
@@
void StrBufConvert(StrBuf *ConvertBuf, StrBuf *TmpBuf, void *pic)
size_t obuflen; /**< Length of output buffer */
size_t obuflen; /**< Length of output buffer */
+ if ((ConvertBuf == NULL) || (TmpBuf == NULL))
+ return;
+
/* since we're converting to utf-8, one glyph may take up to 6 bytes */
if (ConvertBuf->BufUsed * 6 >= TmpBuf->BufSize)
IncreaseBuf(TmpBuf, 0, ConvertBuf->BufUsed * 6);
/* since we're converting to utf-8, one glyph may take up to 6 bytes */
if (ConvertBuf->BufUsed * 6 >= TmpBuf->BufSize)
IncreaseBuf(TmpBuf, 0, ConvertBuf->BufUsed * 6);
@@
-3265,6
+3271,9
@@
void StrBuf_RFC822_2_Utf8(StrBuf *Target,
int i;
int illegal_non_rfc2047_encoding = 0;
int i;
int illegal_non_rfc2047_encoding = 0;
+
+ if (DecodeMe == NULL)
+ return;
/* Sometimes, badly formed messages contain strings which were simply
* written out directly in some foreign character set instead of
* using RFC2047 encoding. This is illegal but we will attempt to
/* Sometimes, badly formed messages contain strings which were simply
* written out directly in some foreign character set instead of
* using RFC2047 encoding. This is illegal but we will attempt to
@@
-3751,6
+3760,10
@@
eReadState StrBufChunkSipLine(StrBuf *LineBuf, IOBuffer *FB)
const char *aptr, *ptr, *eptr;
char *optr, *xptr;
const char *aptr, *ptr, *eptr;
char *optr, *xptr;
+ if ((FB == NULL) || (LineBuf == NULL))
+ return eReadFail;
+
+
if ((FB->Buf == NULL) || (FB->ReadWritePointer == StrBufNOTNULL)) {
FB->ReadWritePointer = StrBufNOTNULL;
return eReadFail;
if ((FB->Buf == NULL) || (FB->ReadWritePointer == StrBufNOTNULL)) {
FB->ReadWritePointer = StrBufNOTNULL;
return eReadFail;
@@
-3838,6
+3851,8
@@
eReadState StrBufCheckBuffer(IOBuffer *FB)
long IOBufferStrLength(IOBuffer *FB)
{
long IOBufferStrLength(IOBuffer *FB)
{
+ if ((FB == NULL) || (FB->Buf == NULL))
+ return 0;
if (FB->ReadWritePointer == NULL)
return StrLength(FB->Buf);
if (FB->ReadWritePointer == NULL)
return StrLength(FB->Buf);
@@
-4053,6
+4068,11
@@
int StrBufTCP_read_line(StrBuf *buf, int *fd, int append, const char **Error)
{
int len, rlen, slen;
{
int len, rlen, slen;
+ if (buf == NULL) {
+ *Error = strerror(EINVAL);
+ return -1;
+ }
+
if (!append)
FlushStrBuf(buf);
if (!append)
FlushStrBuf(buf);
@@
-4635,7
+4655,10
@@
int StrBufSipLine(StrBuf *LineBuf, const StrBuf *Buf, const char **Ptr)
const char *aptr, *ptr, *eptr;
char *optr, *xptr;
const char *aptr, *ptr, *eptr;
char *optr, *xptr;
- if ((Buf == NULL) || (*Ptr == StrBufNOTNULL)) {
+ if ((Buf == NULL) ||
+ (*Ptr == StrBufNOTNULL) ||
+ (LineBuf == NULL))
+ {
*Ptr = StrBufNOTNULL;
return 0;
}
*Ptr = StrBufNOTNULL;
return 0;
}