From: Wilfried Göesgens Date: Mon, 15 Dec 2008 19:44:43 +0000 (+0000) Subject: * sanitize offset X-Git-Tag: v7.86~1702 X-Git-Url: https://code.citadel.org/?p=citadel.git;a=commitdiff_plain;h=3658da9b20fcbbf19f8a6712a47221fa2389ca71 * sanitize offset --- diff --git a/libcitadel/lib/libcitadel.h b/libcitadel/lib/libcitadel.h index 9a5ec9a0f..76ce884d0 100644 --- a/libcitadel/lib/libcitadel.h +++ b/libcitadel/lib/libcitadel.h @@ -244,15 +244,15 @@ int StrBufTCP_read_buffered_line(StrBuf *Line, int StrBufSipLine(StrBuf *LineBuf, StrBuf *Buf, const char **Ptr); int StrBufExtract_token(StrBuf *dest, const StrBuf *Source, int parmnum, char separator); -int StrBufSub(StrBuf *dest, const StrBuf *Source, size_t Offset, size_t nChars); +int StrBufSub(StrBuf *dest, const StrBuf *Source, unsigned long Offset, size_t nChars); unsigned long StrBufExtract_unsigned_long(const StrBuf* Source, int parmnum, char separator); long StrBufExtract_long(const StrBuf* Source, int parmnum, char separator); int StrBufExtract_int(const StrBuf* Source, int parmnum, char separator); inline int StrBufNum_tokens(const StrBuf *source, char tok); int StrBufRemove_token(StrBuf *Source, int parmnum, char separator); -void StrBufAppendBufPlain(StrBuf *Buf, const char *AppendBuf, long AppendSize, size_t Offset); -void StrBufAppendBuf(StrBuf *Buf, const StrBuf *AppendBuf, size_t Offset); +void StrBufAppendBufPlain(StrBuf *Buf, const char *AppendBuf, long AppendSize, unsigned long Offset); +void StrBufAppendBuf(StrBuf *Buf, const StrBuf *AppendBuf, unsigned long Offset); void StrBufAppendPrintf(StrBuf *Buf, const char *format, ...); #ifdef SHOW_ME_VAPPEND_PRINTF /* so owe don't create an include depndency, this is just visible on demand. */ diff --git a/libcitadel/lib/stringbuf.c b/libcitadel/lib/stringbuf.c index 8fe5ab052..7a5590859 100644 --- a/libcitadel/lib/stringbuf.c +++ b/libcitadel/lib/stringbuf.c @@ -330,7 +330,7 @@ long StrBufPeek(StrBuf *Buf, const char* ptr, long nThChar, char PeekValue) * \param AppendBuf Buffer to copy at the end of our buffer * \param Offset Should we start copying from an offset? */ -void StrBufAppendBuf(StrBuf *Buf, const StrBuf *AppendBuf, size_t Offset) +void StrBufAppendBuf(StrBuf *Buf, const StrBuf *AppendBuf, unsigned long Offset) { if ((AppendBuf == NULL) || (Buf == NULL)) return; @@ -355,12 +355,12 @@ void StrBufAppendBuf(StrBuf *Buf, const StrBuf *AppendBuf, size_t Offset) * \param AppendSize number of bytes to copy; set to -1 if we should count it in advance * \param Offset Should we start copying from an offset? */ -void StrBufAppendBufPlain(StrBuf *Buf, const char *AppendBuf, long AppendSize, size_t Offset) +void StrBufAppendBufPlain(StrBuf *Buf, const char *AppendBuf, long AppendSize, unsigned long Offset) { long aps; long BufSizeRequired; - if ((AppendBuf == NULL) || (Buf == NULL)) + if ((AppendBuf == NULL) || (Buf == NULL) || (AppendSize <= 0)) return; if (AppendSize < 0 ) @@ -619,7 +619,7 @@ void StrMsgEscAppend(StrBuf *Target, StrBuf *Source, const char *PlainIn) * \param nChars number of chars to copy * \returns the number of chars copied; may be different from nChars due to the size of Source */ -int StrBufSub(StrBuf *dest, const StrBuf *Source, size_t Offset, size_t nChars) +int StrBufSub(StrBuf *dest, const StrBuf *Source, unsigned long Offset, size_t nChars) { size_t NCharsRemain; if (Offset > Source->BufUsed)