diff options
-rw-r--r-- | epan/addr_resolv.c | 20 | ||||
-rwxr-xr-x | make-manuf | 15 |
2 files changed, 20 insertions, 15 deletions
diff --git a/epan/addr_resolv.c b/epan/addr_resolv.c index 684962574e..99ccfe6183 100644 --- a/epan/addr_resolv.c +++ b/epan/addr_resolv.c @@ -138,7 +138,6 @@ #define ENAME_MANUF "manuf" #define ENAME_SERVICES "services" -#define MAXMANUFLEN 9 /* max vendor name length with ending '\0' */ #define HASHETHSIZE 2048 #define HASHHOSTSIZE 2048 #define HASHIPXNETSIZE 256 @@ -213,7 +212,7 @@ typedef struct hashipxnet { typedef struct hashmanuf { struct hashmanuf *next; guint8 addr[3]; - char name[MAXMANUFLEN]; + char *name; } hashmanuf_t; #define HASHETHER_STATUS_UNRESOLVED 1 @@ -1015,7 +1014,7 @@ se_solve_address_to_name(const address *addr) * ethers files parsing (see ethers(4)). * * The manuf file has the same format as ethers(4) except that names are - * truncated to MAXMANUFLEN-1 characters and that an address contains + * truncated to MAXMANUFLEN-1 (8) characters and that an address contains * only 3 bytes (instead of 6). * * Notes: @@ -1299,18 +1298,24 @@ hash_eth_wka(const guint8 *addr, unsigned int mask) } static hashmanuf_t * -manuf_hash_new_entry(const guint8 *addr, gchar *name) { +manuf_hash_new_entry(const guint8 *addr, gchar *name) +{ hashmanuf_t *mtp; mtp = (hashmanuf_t *)g_malloc(sizeof(hashmanuf_t)); memcpy(mtp->addr, addr, sizeof(mtp->addr)); - g_strlcpy(mtp->name, name, MAXMANUFLEN); + /* The length of this name is limited (in the number of UTF-8 characters, + * not bytes) in make-manuf. That doesn't mean a user can't put a longer + * name in their personal manuf file, though... + */ + mtp->name = g_strdup(name); mtp->next = NULL; return mtp; } /* manuf_hash_new_entry */ static hashwka_t * -wka_hash_new_entry(const guint8 *addr, gchar *name) { +wka_hash_new_entry(const guint8 *addr, gchar *name) +{ hashwka_t *wtp; wtp = (hashwka_t *)g_malloc(sizeof(hashwka_t)); @@ -2952,8 +2957,7 @@ get_manuf_name(const guint8 *addr) } if (!(gbl_resolv_flags & RESOLV_MAC) || ((mtp = manuf_name_lookup(addr)) == NULL)) { - cur=ep_alloc(MAXMANUFLEN); - g_snprintf(cur, MAXMANUFLEN, "%02x:%02x:%02x", addr[0], addr[1], addr[2]); + cur=ep_strdup_printf("%02x:%02x:%02x", addr[0], addr[1], addr[2]); return cur; } 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 |