summaryrefslogtreecommitdiffstats
path: root/src/web_buffer.c
diff options
context:
space:
mode:
authorFederico Ceratto <federico.ceratto@gmail.com>2018-03-27 21:28:21 +0000
committerFederico Ceratto <federico.ceratto@gmail.com>2018-03-27 21:28:21 +0000
commitd4dd00f58a502c9ca4b63e36ce6bc7a9945dc63c (patch)
treefaac99f51f182bb8c0a03e95e393d421ac9ddf42 /src/web_buffer.c
parentNew upstream version 1.9.0+dfsg (diff)
downloadnetdata-d4dd00f58a502c9ca4b63e36ce6bc7a9945dc63c.tar.xz
netdata-d4dd00f58a502c9ca4b63e36ce6bc7a9945dc63c.zip
New upstream version 1.10.0+dfsgupstream/1.10.0+dfsg
Diffstat (limited to 'src/web_buffer.c')
-rw-r--r--src/web_buffer.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/web_buffer.c b/src/web_buffer.c
index f5452452..50c76f6d 100644
--- a/src/web_buffer.c
+++ b/src/web_buffer.c
@@ -21,7 +21,7 @@ static inline void _buffer_overflow_check(BUFFER *b, const char *file, const cha
b->len = b->size;
}
- if(b->buffer[b->size] != '\0' || strcmp(&b->buffer[b->size + 1], BUFFER_OVERFLOW_EOF)) {
+ if(b->buffer[b->size] != '\0' || strcmp(&b->buffer[b->size + 1], BUFFER_OVERFLOW_EOF) != 0) {
error("BUFFER: detected overflow at line %lu, at function %s() of file '%s'.", line, function, file);
buffer_overflow_init(b);
}
@@ -160,8 +160,6 @@ void buffer_strcat(BUFFER *wb, const char *txt)
void buffer_strcat_htmlescape(BUFFER *wb, const char *txt)
{
- char b[2] = { [0] = '\0', [1] = '\0' };
-
while(*txt) {
switch(*txt) {
case '&': buffer_strcat(wb, "&amp;"); break;
@@ -171,12 +169,14 @@ void buffer_strcat_htmlescape(BUFFER *wb, const char *txt)
case '/': buffer_strcat(wb, "&#x2F;"); break;
case '\'': buffer_strcat(wb, "&#x27;"); break;
default: {
- b[0] = *txt;
- buffer_strcat(wb, b);
+ buffer_need_bytes(wb, 1);
+ wb->buffer[wb->len++] = *txt;
}
}
txt++;
}
+
+ buffer_overflow_check(wb);
}
void buffer_snprintf(BUFFER *wb, size_t len, const char *fmt, ...)