From 28f9de4b41efcb87cdd33b0dbaefd6dfc29d1fac Mon Sep 17 00:00:00 2001 From: Daniel Willmann Date: Tue, 20 Aug 2024 17:45:08 +0200 Subject: [PATCH] ogs_fqdn_parse: Write the terminating NULL byte even if the APN is empty Enter the while loop even if length == 1 (with len being 0) so that the terminating NULL byte is written to dst. --- lib/proto/types.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/proto/types.c b/lib/proto/types.c index 5fd491d83..1b6b7d486 100644 --- a/lib/proto/types.c +++ b/lib/proto/types.c @@ -416,7 +416,7 @@ int ogs_fqdn_parse(char *dst, const char *src, int length) int i = 0, j = 0; uint8_t len = 0; - while (i+1 < length) { + while (i+1 <= length) { len = src[i++]; if ((j + len + 1) > length) { ogs_error("Invalid FQDN encoding[j:%d+len:%d] + 1 > length[%d]",