eBPF-based security platform
upatch: keep the terminator of a type name and of a signed name
Daniel Borkmann9af24ddb70d6
diff --git a/util/upatch.c b/util/upatch.cindex 06606814..8c07d20a 100644--- a/util/upatch.c+++ b/util/upatch.c@@ -228,7 +228,8 @@ static void parse_signed_sections(struct shirudo_upatch *u)switch (tag) {case SHIRUDO_UPATCH_SECTION_NAME:bit = 1;- if (len != SHIRUDO_UPATCH_NAME_MAX)+ if (len != SHIRUDO_UPATCH_NAME_MAX ||+ !memchr(data + off, '\0', len))goto reject;u->signed_name = (const char *)data + off;break;diff --git a/util/upatch_rodata.c b/util/upatch_rodata.cindex 1ef28775..4c180cbf 100644--- a/util/upatch_rodata.c+++ b/util/upatch_rodata.c@@ -467,10 +467,10 @@ static int append_type_name(const struct btf *btf, __u32 id, char *buf,if (kind == BTF_KIND_PTR) {if (append_type_name(btf, t->type, buf, cap, off, depth + 1))return -EINVAL;- if (*off + 2 > cap)+ n = strsprintf(buf + *off, cap - *off, " *");+ if (n < 0)return -ENOSPC;- memcpy(buf + *off, " *", 2);- *off += 2;+ *off += (size_t)n;return 0;}if (name && name[0]) {