libpsl/backport-Avoid-NULL-add-1-as-it-is-UB.patch
2024-04-15 10:56:51 +08:00

38 lines
941 B
Diff

From 21d2d5191160439544150c017216f751c2c392fd Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Tim=20R=C3=BChsen?= <tim.ruehsen@gmx.de>
Date: Sun, 16 Jan 2022 12:55:51 +0100
Subject: [PATCH] Avoid 'NULL + 1' as it is UB
---
src/psl.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/src/psl.c b/src/psl.c
index 8e7a9e8..f85a895 100644
--- a/src/psl.c
+++ b/src/psl.c
@@ -568,7 +568,7 @@ static int domain_to_punycode(const char *domain, char *out, size_t outsize)
punycode_uint input[256];
const char *label, *e;
- for (e = label = domain; e; label = e + 1) {
+ for (e = label = domain; e;) {
e = strchr(label, '.');
labellen = e ? (size_t) (e - label) : strlen(label);
@@ -596,8 +596,10 @@ static int domain_to_punycode(const char *domain, char *out, size_t outsize)
outlen += labellen;
}
- if (e)
+ if (e) {
+ label = e + 1;
out[outlen++] = '.';
+ }
out[outlen] = 0;
}
--
2.27.0