Mark Bergsma has submitted this change and it was merged.

Change subject: Handle "Var: Val" with empty " Val"s.
......................................................................


Handle "Var: Val" with empty " Val"s.

Change-Id: I38980e81f6df32ee553695cf6998c80af1f69883
---
M varnishkafka.c
1 file changed, 10 insertions(+), 2 deletions(-)

Approvals:
  Mark Bergsma: Verified; Looks good to me, approved



diff --git a/varnishkafka.c b/varnishkafka.c
index 1fafeae..70d795e 100644
--- a/varnishkafka.c
+++ b/varnishkafka.c
@@ -437,6 +437,7 @@
 
 static inline void match_assign0 (const struct tag *tag, struct logline *lp,
                                  const char *ptr, int len) {
+       assert(len >= 0);
        lp->match[tag->fmt->idx].ptr = ptr;
        lp->match[tag->fmt->idx].len = len;
 }
@@ -1375,8 +1376,15 @@
                            strncasecmp(ptr, tag->var, tag->varlen))
                                continue;
 
-                       ptr2 = t+2; /* ": " */
-                       len2 = len - (int)(ptr2-ptr);
+                       if (likely(len > tag->varlen + 1 /* ":" */)) {
+                               ptr2 = t+2; /* ": " */
+                               len2 = len - (int)(ptr2-ptr);
+                       } else {
+                               /* Empty value */
+                               len2 = 0;
+                               ptr2 = NULL;
+                       }
+
                } else {
                        ptr2 = ptr;
                        len2 = len;

-- 
To view, visit https://gerrit.wikimedia.org/r/79749
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I38980e81f6df32ee553695cf6998c80af1f69883
Gerrit-PatchSet: 1
Gerrit-Project: operations/software/varnish/varnishkafka
Gerrit-Branch: master
Gerrit-Owner: Edenhill <[email protected]>
Gerrit-Reviewer: BBlack <[email protected]>
Gerrit-Reviewer: Mark Bergsma <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to