projects
/
citadel.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
2f8ba8d
)
STRBUF: evaluate fails to increase the buffer
author
Wilfried Goesgens
<dothebart@citadel.org>
Sun, 21 Oct 2012 17:47:40 +0000
(19:47 +0200)
committer
Wilfried Goesgens
<dothebart@citadel.org>
Sun, 21 Oct 2012 17:47:40 +0000
(19:47 +0200)
libcitadel/lib/stringbuf.c
patch
|
blob
|
history
diff --git
a/libcitadel/lib/stringbuf.c
b/libcitadel/lib/stringbuf.c
index ba88a2f431bbfe594661dd738bc3deaba19917e3..968fe9793784d869e36f8d967439ea9e694616be 100644
(file)
--- a/
libcitadel/lib/stringbuf.c
+++ b/
libcitadel/lib/stringbuf.c
@@
-1023,16
+1023,18
@@
int StrBufSub(StrBuf *dest, const StrBuf *Source, unsigned long Offset, size_t n
}
if (Offset + nChars < Source->BufUsed)
{
}
if (Offset + nChars < Source->BufUsed)
{
- if (nChars >= dest->BufSize)
- IncreaseBuf(dest, 0, nChars + 1);
+ if ((nChars >= dest->BufSize) &&
+ (IncreaseBuf(dest, 0, nChars + 1) == -1))
+ return 0;
memcpy(dest->buf, Source->buf + Offset, nChars);
dest->BufUsed = nChars;
dest->buf[dest->BufUsed] = '\0';
return nChars;
}
NCharsRemain = Source->BufUsed - Offset;
memcpy(dest->buf, Source->buf + Offset, nChars);
dest->BufUsed = nChars;
dest->buf[dest->BufUsed] = '\0';
return nChars;
}
NCharsRemain = Source->BufUsed - Offset;
- if (NCharsRemain >= dest->BufSize)
- IncreaseBuf(dest, 0, NCharsRemain + 1);
+ if ((NCharsRemain >= dest->BufSize) &&
+ (IncreaseBuf(dest, 0, NCharsRemain + 1) == -1))
+ return 0;
memcpy(dest->buf, Source->buf + Offset, NCharsRemain);
dest->BufUsed = NCharsRemain;
dest->buf[dest->BufUsed] = '\0';
memcpy(dest->buf, Source->buf + Offset, NCharsRemain);
dest->BufUsed = NCharsRemain;
dest->buf[dest->BufUsed] = '\0';
@@
-4316,10
+4318,11
@@
int StrBufTCP_read_buffered_line(StrBuf *Line,
nSuccessLess = 0;
buf->BufUsed += rlen;
buf->buf[buf->BufUsed] = '\0';
nSuccessLess = 0;
buf->BufUsed += rlen;
buf->buf[buf->BufUsed] = '\0';
- if (buf->BufUsed + 10 > buf->BufSize) {
- IncreaseBuf(buf, 1, -1);
- }
pch = strchr(buf->buf, '\n');
pch = strchr(buf->buf, '\n');
+ if ((pch == NULL) &&
+ (buf->BufUsed + 10 > buf->BufSize) &&
+ (IncreaseBuf(buf, 1, -1) == -1))
+ return -1;
continue;
}
continue;
}