Hi,

I see that savestr is used in a few locations.  I don't see any need for
this, it's just a lousy replacement for strdup.

For what it's worth, the LBL traceroute segfault + root exploit about 4
months ago was caused by buggy (the source is same..) savestr.

The patch attached will remove savestr().  savestr.[ch] and other bits
(FILES, INSTALL, Makefile.in) could be removed then, too.

-- 
Pekka Savola                  "Tell me of difficulties surmounted,
Netcore Oy                    not those you stumble over and fall"
Systems. Networks. Security.   -- Robert Jordan: A Crown of Swords
diff -uNr tcpdump/addrtoname.c tcpdump.savestr/addrtoname.c
--- tcpdump/addrtoname.c        Sat Oct  7 08:33:25 2000
+++ tcpdump.savestr/addrtoname.c        Sun Dec 31 17:17:25 2000
@@ -56,7 +56,6 @@
 #include "interface.h"
 #include "addrtoname.h"
 #include "llc.h"
-#include "savestr.h"
 #include "setsignal.h"
 
 /* Forwards */
@@ -208,7 +207,7 @@
                        if (hp) {
                                char *dotp;
 
-                               p->name = savestr(hp->h_name);
+                               p->name = strdup(hp->h_name);
                                if (Nflag) {
                                        /* Remove domain qualifications */
                                        dotp = strchr(p->name, '.');
@@ -219,7 +218,7 @@
                        }
                }
        }
-       p->name = savestr(intoa(addr));
+       p->name = strdup(intoa(addr));
        return (p->name);
 }
 
@@ -271,7 +270,7 @@
                        if (hp) {
                                char *dotp;
 
-                               p->name = savestr(hp->h_name);
+                               p->name = strdup(hp->h_name);
                                if (Nflag) {
                                        /* Remove domain qualifications */
                                        dotp = strchr(p->name, '.');
@@ -283,7 +282,7 @@
                }
        }
        cp = (char *)inet_ntop(AF_INET6, &addr, ntop_buf, sizeof(ntop_buf));
-       p->name = savestr(cp);
+       p->name = strdup(cp);
        return (p->name);
 }
 #endif /* INET6 */
@@ -407,7 +406,7 @@
        if (!nflag) {
                char buf[128];
                if (ether_ntohost(buf, (struct ether_addr *)ep) == 0) {
-                       tp->e_name = savestr(buf);
+                       tp->e_name = strdup(buf);
                        return (tp->e_name);
                }
        }
@@ -423,7 +422,7 @@
                *cp++ = hex[*ep++ & 0xf];
        }
        *cp = '\0';
-       tp->e_name = savestr(buf);
+       tp->e_name = strdup(buf);
        return (tp->e_name);
 }
 
@@ -449,7 +448,7 @@
        *cp++ = hex[port >> 4 & 0xf];
        *cp++ = hex[port & 0xf];
        *cp++ = '\0';
-       tp->name = savestr(buf);
+       tp->name = strdup(buf);
        return (tp->name);
 }
 
@@ -476,7 +475,7 @@
                *cp++ = hex[*pi++ & 0xf];
        }
        *cp = '\0';
-       tp->p_name = savestr(buf);
+       tp->p_name = strdup(buf);
        return (tp->p_name);
 }
 
@@ -495,7 +494,7 @@
        tp->nxt = newhnamemem();
 
        snprintf(buf, sizeof(buf), "sap %02x", sap & 0xff);
-       tp->name = savestr(buf);
+       tp->name = strdup(buf);
        return (tp->name);
 }
 
@@ -539,7 +538,7 @@
        tp->nxt = newhnamemem();
 
        (void)snprintf(buf, sizeof(buf), "%u", i);
-       tp->name = savestr(buf);
+       tp->name = strdup(buf);
        return (tp->name);
 }
 
@@ -558,7 +557,7 @@
        tp->nxt = newhnamemem();
 
        (void)snprintf(buf, sizeof(buf), "%u", i);
-       tp->name = savestr(buf);
+       tp->name = strdup(buf);
        return (tp->name);
 }
 
@@ -584,9 +583,9 @@
                        table = table->nxt;
                if (nflag) {
                        (void)snprintf(buf, sizeof(buf), "%d", port);
-                       table->name = savestr(buf);
+                       table->name = strdup(buf);
                } else
-                       table->name = savestr(sv->s_name);
+                       table->name = strdup(sv->s_name);
                table->addr = port;
                table->nxt = newhnamemem();
        }
@@ -635,7 +634,7 @@
 
                memcpy((char *)&protoid[3], (char *)&etype, 2);
                tp = lookup_protoid(protoid);
-               tp->p_name = savestr(eproto_db[i].s);
+               tp->p_name = strdup(eproto_db[i].s);
        }
 }
 
@@ -677,7 +676,7 @@
        if (fp != NULL) {
                while ((ep = pcap_next_etherent(fp)) != NULL) {
                        tp = lookup_emem(ep->addr);
-                       tp->e_name = savestr(ep->name);
+                       tp->e_name = strdup(ep->name);
                }
                (void)fclose(fp);
        }
@@ -693,7 +692,7 @@
 #ifdef HAVE_ETHER_NTOHOST
                 /* Use yp/nis version of name if available */
                 if (ether_ntohost(name, (struct ether_addr *)el->addr) == 0) {
-                        tp->e_name = savestr(name);
+                        tp->e_name = strdup(name);
                        continue;
                }
 #endif
diff -uNr tcpdump/print-atalk.c tcpdump.savestr/print-atalk.c
--- tcpdump/print-atalk.c       Mon Oct 30 08:22:14 2000
+++ tcpdump.savestr/print-atalk.c       Sun Dec 31 17:18:13 2000
@@ -46,7 +46,6 @@
 #include "ethertype.h"
 #include "extract.h"                   /* must come after interface.h */
 #include "appletalk.h"
-#include "savestr.h"
 
 static struct tok type2str[] = {
        { ddpRTMP,              "rtmp" },
@@ -542,7 +541,7 @@
                                ;
                        tp->addr = i3;
                        tp->nxt = newhnamemem();
-                       tp->name = savestr(nambuf);
+                       tp->name = strdup(nambuf);
                }
                fclose(fp);
        }
@@ -559,7 +558,7 @@
                        tp->nxt = newhnamemem();
                        (void)snprintf(nambuf, sizeof(nambuf), "%s.%d",
                            tp2->name, athost);
-                       tp->name = savestr(nambuf);
+                       tp->name = strdup(nambuf);
                        return (tp->name);
                }
 
@@ -571,7 +570,7 @@
        else
                (void)snprintf(nambuf, sizeof(nambuf), "%d.%d", atnet >> 8,
                    atnet & 0xff);
-       tp->name = savestr(nambuf);
+       tp->name = strdup(nambuf);
 
        return (tp->name);
 }
diff -uNr tcpdump/print-decnet.c tcpdump.savestr/print-decnet.c
--- tcpdump/print-decnet.c      Thu Sep 28 09:42:57 2000
+++ tcpdump.savestr/print-decnet.c      Sun Dec 31 17:18:32 2000
@@ -753,7 +753,7 @@
 
        dna.a_len = sizeof(short);
        memcpy((char *)dna.a_addr, (char *)&dnaddr, sizeof(short));
-       return (savestr(dnet_htoa(&dna)));
+       return (strdup(dnet_htoa(&dna)));
 #else
        return(dnnum_string(dnaddr));   /* punt */
 #endif

Reply via email to