From 1479e0bdf84a8959a5edf6eb30db1a50918d6348 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Wilfried=20G=C3=B6esgens?= Date: Tue, 24 Nov 2009 20:42:48 +0000 Subject: [PATCH] * more entry checking. --- libcitadel/lib/stringbuf.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/libcitadel/lib/stringbuf.c b/libcitadel/lib/stringbuf.c index c07c412d4..389641c06 100644 --- a/libcitadel/lib/stringbuf.c +++ b/libcitadel/lib/stringbuf.c @@ -2044,6 +2044,7 @@ int StrBufTCP_read_buffered_line(StrBuf *Line, } +static const char *ErrRBLF_PreConditionFailed="StrBufTCP_read_buffered_line_fast: Wrong arguments or invalid Filedescriptor"; static const char *ErrRBLF_SelectFailed="StrBufTCP_read_buffered_line_fast: Select failed without reason"; static const char *ErrRBLF_NotEnoughSentFromServer="StrBufTCP_read_buffered_line_fast: No complete line was sent from peer"; /** @@ -2077,6 +2078,14 @@ int StrBufTCP_read_buffered_line_fast(StrBuf *Line, int IsNonBlock; struct timeval tv; + if ((Line == NULL) || + (IOBuf == NULL) || + (*fd == -1)) + { + *Error = ErrRBLF_PreConditionFailed; + return -1; + } + pos = *Pos; if ((IOBuf->BufUsed > 0) && (pos != NULL) && @@ -2182,6 +2191,7 @@ int StrBufTCP_read_buffered_line_fast(StrBuf *Line, } +static const char *ErrRBLF_BLOBPreConditionFailed="StrBufReadBLOB: Wrong arguments or invalid Filedescriptor"; /** * @ingroup StrBuf_IO * @brief Input binary data from socket @@ -2203,8 +2213,12 @@ int StrBufReadBLOB(StrBuf *Buf, int *fd, int append, long nBytes, const char **E int IsNonBlock; struct timeval tv; fd_set rfds; + if ((Buf == NULL) || (*fd == -1)) + { + *Error = ErrRBLF_BLOBPreConditionFailed; return -1; + } if (!append) FlushStrBuf(Buf); if (Buf->BufUsed + nBytes >= Buf->BufSize) @@ -2257,6 +2271,7 @@ int StrBufReadBLOB(StrBuf *Buf, int *fd, int append, long nBytes, const char **E return nRead; } +const char *ErrRBB_BLOBFPreConditionFailed = "StrBufReadBLOBBuffered: to many selects; aborting."; const char *ErrRBB_too_many_selects = "StrBufReadBLOBBuffered: to many selects; aborting."; /** * @ingroup StrBuf_BufferedIO @@ -2298,7 +2313,11 @@ int StrBufReadBLOBBuffered(StrBuf *Blob, int nSuccessLess; if ((Blob == NULL) || (*fd == -1) || (IOBuf == NULL) || (Pos == NULL)) + { + *Error = ErrRBB_BLOBFPreConditionFailed; return -1; + } + if (!append) FlushStrBuf(Blob); if (Blob->BufUsed + nBytes >= Blob->BufSize) -- 2.30.2