ipconfig invokes undefined behaviour
Subsystems (3)
PATCH 1/1 ipconfig invokes undefined behaviour
strcpy is undefined if src and dest overlap. That's clearly possible here with a sufficiently deep path on the server. Use memmove instead.
Signed-off-by Matthew Wilcox <[email protected]>
Index: ./net/ipv4/ipconfig.c
===================================================================
RCS file: /var/cvs/linux-2.6/net/ipv4/ipconfig.c,v retrieving revision 1.12
net/ipv4/ipconfig.c +1 -1
@@ -1232,7 +1232,7 @@ u32 __init root_nfs_parse_addr(char *namif (*cp ==':' ) *cp++ ='\0' ; addr =in_aton (name); -strcpy (name, cp); +memmove (name, cp,strlen (cp) +1 ); }else addr =INADDR_NONE ;
Signature · 6 lines
"Next the statesmen will invent cheap lies, putting the blame upon the nation that is attacked, and every man will be glad of those conscience-soothing falsities, and will diligently study them, and refuse to examine any refutations of them; and thus he will by and by convince himself that the war is just, and will thank God for the better sleep he enjoys after this process of grotesque self-deception." -- Mark Twain
David S. Miller
maintainerQuoted 4 lines · On Sun, 6 Feb 2005 04:47:44 +0000 Matthew Wilcox <[email protected]> wrote:
strcpy is undefined if src and dest overlap. That's clearly possible here with a sufficiently deep path on the server. Use memmove instead.
Signed-off-by Matthew Wilcox <[email protected]>
Thanks a lot Matthew, applied to both 2.4.x and 2.6.x