* sanitize offset
authorWilfried Göesgens <willi@citadel.org>
Mon, 15 Dec 2008 19:44:43 +0000 (19:44 +0000)
committerWilfried Göesgens <willi@citadel.org>
Mon, 15 Dec 2008 19:44:43 +0000 (19:44 +0000)
libcitadel/lib/libcitadel.h
libcitadel/lib/stringbuf.c

index 9a5ec9a0f99004e4fe5b22466c1b4f5327384031..76ce884d00a8fc05f8782a29bb8496c0934aca99 100644 (file)
@@ -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. */
index 8fe5ab0529ab2788556f32bb90e5d5ac7deceb7e..7a559085928f4a03b487a11ffb8ff9748622aef3 100644 (file)
@@ -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)