about summary refs log tree commit diff
path: root/blaze822.c
diff options
context:
space:
mode:
authorChristian Neukirchen <chneukirchen@gmail.com>2016-07-13 21:08:05 +0200
committerChristian Neukirchen <chneukirchen@gmail.com>2016-07-13 21:08:05 +0200
commit411c9b632adfad234aacf9724c26d19ee38c1a8b (patch)
tree6ef0269fc7937df4b12fa6acfbd4a719f12ef98a /blaze822.c
parent11c9ce78f1f8a772db2a6f82e745e6b42adf943f (diff)
downloadmblaze-411c9b632adfad234aacf9724c26d19ee38c1a8b.tar.gz
mblaze-411c9b632adfad234aacf9724c26d19ee38c1a8b.tar.xz
mblaze-411c9b632adfad234aacf9724c26d19ee38c1a8b.zip
blaze822: detect too short/empty headers
Diffstat (limited to 'blaze822.c')
-rw-r--r--blaze822.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/blaze822.c b/blaze822.c
index 6d1b643..4276323 100644
--- a/blaze822.c
+++ b/blaze822.c
@@ -404,6 +404,9 @@ blaze822_hdr_(struct message *mesg, const char *hdr, size_t hdrlen)
 {
 	char *v;
 
+	if (mesg->msg + hdrlen - 1 >= mesg->end)
+		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)
 		v = mesg->msg;