]> git.ipfire.org Git - thirdparty/iptables.git/commitdiff
libxtables: Avoid buffer overrun in xtables_compatible_revision()
authorPhil Sutter <phil@nwl.cc>
Thu, 5 Dec 2019 12:57:18 +0000 (13:57 +0100)
committerPhil Sutter <phil@nwl.cc>
Fri, 6 Dec 2019 11:12:08 +0000 (12:12 +0100)
The function is exported and accepts arbitrary strings as input. Calling
strcpy() without length checks is not OK.

libxtables/xtables.c

index 895f6988eaf57048d54458274728a5ce9d318234..777c2b08e9896850cd0285a3246581acf2e5e188 100644 (file)
@@ -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);