summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 8192bfc)
raw | patch | inline | side by side (parent: 8192bfc)
author | Florian Forster <octo@collectd.org> | |
Thu, 9 Nov 2017 15:18:33 +0000 (16:18 +0100) | ||
committer | Florian Forster <octo@collectd.org> | |
Thu, 9 Nov 2017 15:18:33 +0000 (16:18 +0100) |
* Remove legacy rindex() with the POSIX strrchr().
* Check return value of strrchr().
* Chose non-arbitrary buffer size.
* Use sstrncpy() instead of strcpy().
* Check return value of strrchr().
* Chose non-arbitrary buffer size.
* Use sstrncpy() instead of strcpy().
src/varnish.c | patch | blob | history |
diff --git a/src/varnish.c b/src/varnish.c
index d105b025a62922f332a754403411f3d5e449956d..08260dc27fe5c28e2a7eb58c6b7350735aa9a827 100644 (file)
--- a/src/varnish.c
+++ b/src/varnish.c
conf = priv;
#if HAVE_VARNISH_V5
- char namebuff[100];
- char *c;
+ char namebuff[DATA_MAX_NAME_LEN];
- c = rindex(pt->name, '.');
- strcpy(namebuff, c + 1);
+ char const *c = strrchr(pt->name, '.');
+ if (c == NULL) {
+ return EINVAL;
+ }
+ sstrncpy(namebuff, c + 1, sizeof(namebuff));
name = namebuff;
#elif HAVE_VARNISH_V4