summaryrefslogtreecommitdiffstats
path: root/libxtables/xtables.c
diff options
context:
space:
mode:
authorPhil Sutter <phil@nwl.cc>2019-12-05 13:57:18 +0100
committerPhil Sutter <phil@nwl.cc>2019-12-06 12:12:08 +0100
commitf7d3dbb82e7ed94ccbf10cf70a3c7b3f3aaef1a1 (patch)
treea4448c3bbd2ace81e937aad8b2f67e60b7c80388 /libxtables/xtables.c
parent28c16371cdad16707674450b59919e3d97185694 (diff)
libxtables: Avoid buffer overrun in xtables_compatible_revision()
The function is exported and accepts arbitrary strings as input. Calling strcpy() without length checks is not OK.
Diffstat (limited to 'libxtables/xtables.c')
-rw-r--r--libxtables/xtables.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/libxtables/xtables.c b/libxtables/xtables.c
index 895f6988..777c2b08 100644
--- a/libxtables/xtables.c
+++ b/libxtables/xtables.c
@@ -856,7 +856,8 @@ int xtables_compatible_revision(const char *name, uint8_t revision, int opt)
xtables_load_ko(xtables_modprobe_program, true);
- strcpy(rev.name, name);
+ strncpy(rev.name, name, XT_EXTENSION_MAXNAMELEN - 1);
+ rev.name[XT_EXTENSION_MAXNAMELEN - 1] = '\0';
rev.revision = revision;
max_rev = getsockopt(sockfd, afinfo->ipproto, opt, &rev, &s);