summaryrefslogtreecommitdiffstats
path: root/src/web_buffer.c
diff options
context:
space:
mode:
authorFederico Ceratto <federico.ceratto@gmail.com>2018-03-27 21:28:27 +0000
committerFederico Ceratto <federico.ceratto@gmail.com>2018-03-27 21:28:27 +0000
commiteb7cc2640201f168bbd9a05799fd2dbe823bb57c (patch)
tree1f88da02b7ee3c16ced7b5f7dc4aadb190766e7c /src/web_buffer.c
parentRelease v. 1.9.0+dfsg-1 to Unstable (diff)
parentNew upstream version 1.10.0+dfsg (diff)
downloadnetdata-eb7cc2640201f168bbd9a05799fd2dbe823bb57c.tar.xz
netdata-eb7cc2640201f168bbd9a05799fd2dbe823bb57c.zip
Update upstream source from tag 'upstream/1.10.0+dfsg'
Update to upstream version '1.10.0+dfsg' with Debian dir fa5485f3d9aea3038a19eff06ba33374ac5c5d7c
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, ...)