about summary refs log tree commit diff
path: root/blaze822.c
diff options
context:
space:
mode:
authorChristian Neukirchen <chneukirchen@gmail.com>2016-07-29 18:26:39 +0200
committerChristian Neukirchen <chneukirchen@gmail.com>2016-07-29 18:26:39 +0200
commit4296c369f6757e8fe8938dc02053309753075971 (patch)
treef84c22837e453b54ebffc4deb1ccc55d328d978a /blaze822.c
parent65b277df16cd64aa24abd3b6c50889110d295dca (diff)
downloadmblaze-4296c369f6757e8fe8938dc02053309753075971.tar.gz
mblaze-4296c369f6757e8fe8938dc02053309753075971.tar.xz
mblaze-4296c369f6757e8fe8938dc02053309753075971.zip
blaze822: blaze822_hdr_: off-by-one for first header
Diffstat (limited to 'blaze822.c')
-rw-r--r--blaze822.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/blaze822.c b/blaze822.c
index 69f317d..3bdcbd9 100644
--- a/blaze822.c
+++ b/blaze822.c
@@ -418,10 +418,12 @@ blaze822_hdr_(struct message *mesg, const char *hdr, size_t hdrlen)
 		return 0;  // header too small for the key, probably empty
 
 	// special case: first header, no leading nul
-	if (memcmp(mesg->msg, hdr+1, hdrlen-1) == 0)
+	if (memcmp(mesg->msg, hdr+1, hdrlen-1) == 0) {
 		v = mesg->msg;
-	else
+		hdrlen--;
+	} else {
 		v = mymemmem(mesg->msg, mesg->end - mesg->msg, hdr, hdrlen);
+	}
 	if (!v)
 		return 0;
 	v += hdrlen;