diff options
author | Jeff Morriss <jeff.morriss@ulticom.com> | 2010-11-30 22:28:34 +0000 |
---|---|---|
committer | Jeff Morriss <jeff.morriss@ulticom.com> | 2010-11-30 22:28:34 +0000 |
commit | 7009bfc74078d37c5683d7501ed7ce52160cde23 (patch) | |
tree | c5ec210b6739bc59fad327412239a00042b9c1e7 /make-manuf | |
parent | ad2730d302303b7378a2ff2cb2a087051020f4aa (diff) |
Fix https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=4102 :
Limit the length of manuf names to 8 characters in make-manuf (this matches
the (old) limit in addr_resolv.c).
Dynamically allocate memory to store the manuf name in epan/addr_resolv.c so
that we don't end up corrupting the UTF-8 if/when we need to truncate the
string.
svn path=/trunk/; revision=35082
Diffstat (limited to 'make-manuf')
-rwxr-xr-x | make-manuf | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/make-manuf b/make-manuf index b1b20f0a13..b31e14e2fd 100755 --- a/make-manuf +++ b/make-manuf @@ -13,10 +13,10 @@ # with the listing in "oui.txt", with the entries in "manuf.tmpl" taking # precedence. -# LWP is part of the standard Perl module libwww +# LWP is part of the standard Perl module libwww use Encode; -use open ':encoding(utf8)'; +use open ':encoding(utf8)'; eval "require LWP::UserAgent;"; if( $@ ) { @@ -48,7 +48,7 @@ $iab_skipped = 0; sub shorten { - my $origmanuf = shift; + my $origmanuf = shift; my $manuf = " " . $origmanuf . " "; # Remove any punctuation $manuf =~ tr/',.()/ /; @@ -60,8 +60,9 @@ sub shorten $manuf =~ s/(\w+)/\u\L$1/g; # Remove all spaces $manuf =~ s/\s+//g; - # Truncate all names to a reasonable length, say 10 characters. - $manuf = substr($manuf, 0, 10); + # Truncate all names to a reasonable length, say, 8 characters. + # If the string contains UTF-8, this may be substantially more than 8 bytes. + $manuf = substr($manuf, 0, 8); if ($manuf =~ /\Q$origmanuf\E/i) { return $manuf; @@ -85,7 +86,7 @@ sub fetch # Write out the header and populate the OUI list with our entries. -open (TMPL, "< $template") || +open (TMPL, "< $template") || die "Couldn't open template file for reading ($template)\n"; while ($line = <TMPL>) { @@ -184,7 +185,7 @@ foreach $oui (sort(keys %oui_list)) { # addresses, and then read the well-known address template file # and write it to the manuf file. -open (WKATMPL, "< $wkatmpl") || +open (WKATMPL, "< $wkatmpl") || die "Couldn't open well-known address template file for reading ($wkatmpl)\n"; # XXX - it'd be nice to get this from the Cavebear file, but inferring |