From 135543d37cc075b4d9924b54f98c83eda3862d1d Mon Sep 17 00:00:00 2001 From: Loek Le Blansch Date: Wed, 29 May 2024 12:12:21 +0200 Subject: use strncmp instead of memcmp for comparing strings of unknown length --- puzzle/spec.adoc | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/puzzle/spec.adoc b/puzzle/spec.adoc index 9f36556..fbd1033 100644 --- a/puzzle/spec.adoc +++ b/puzzle/spec.adoc @@ -58,8 +58,7 @@ Example C code: #include "puzbus.h" void pb_cmd_magic_handler(const char * data, size_t sz) { - if (sz != sizeof(pb_magic_msg)) return; - if (memcmp(buf, pb_magic_msg, sizeof(pb_magic_msg)) != 0) return; + if (strncmp(buf, pb_magic_msg, sizeof(pb_magic_msg)) != 0) return; const char res[] = { PB_CMD_MAGIC, -- cgit v1.2.3