aboutsummaryrefslogtreecommitdiff
path: root/puzzle
diff options
context:
space:
mode:
authorLoek Le Blansch <loek@pipeframe.xyz>2024-05-29 12:12:21 +0200
committerLoek Le Blansch <loek@pipeframe.xyz>2024-05-29 12:12:21 +0200
commit135543d37cc075b4d9924b54f98c83eda3862d1d (patch)
tree8c0a7cbacbebf0cdfcb8d627d57a88cee7d91131 /puzzle
parent0a58df884713c06720e87819522b81421a910654 (diff)
use strncmp instead of memcmp for comparing strings of unknown length
Diffstat (limited to 'puzzle')
-rw-r--r--puzzle/spec.adoc3
1 files changed, 1 insertions, 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,