8c4b153
--- mtr-0.69/dns.c.CVE-2002-0497	2005-01-11 09:32:42.000000000 +0100
8c4b153
+++ mtr-0.69/dns.c	2005-02-09 18:13:12.000000000 +0100
8c4b153
@@ -877,7 +877,7 @@
8c4b153
   if (type == T_A) {
8c4b153
     dorequest(rp->hostname,type,rp->id);
8c4b153
     if (debug) {
8c4b153
-      sprintf(tempstring,"Resolver: Sent reverse authentication request for \"%s\".",
8c4b153
+      snprintf(tempstring, sizeof(tempstring), "Resolver: Sent reverse authentication request for \"%s\".",
8c4b153
 	      rp->hostname);
8c4b153
       restell(tempstring);
8c4b153
     }
8c4b153
@@ -898,7 +898,7 @@
8c4b153
     }
8c4b153
     dorequest(tempstring,type,rp->id);
8c4b153
     if (debug) {
8c4b153
-      sprintf(tempstring,"Resolver: Sent domain lookup request for \"%s\".",
8c4b153
+      snprintf(tempstring, sizeof(tempstring), "Resolver: Sent domain lookup request for \"%s\".",
8c4b153
 	      strlongip( &(rp->ip) ));
8c4b153
       restell(tempstring);
8c4b153
     }
8c4b153
@@ -934,7 +934,7 @@
8c4b153
   rp->expiretime = sweeptime + (double)ttl;
8c4b153
   untieresolve(rp);
8c4b153
   if (debug) {
8c4b153
-    sprintf(tempstring,"Resolver: Lookup successful: %s\n",rp->hostname);
8c4b153
+    snprintf(tempstring, sizeof(tempstring), "Resolver: Lookup successful: %s\n",rp->hostname);
8c4b153
     restell(tempstring);
8c4b153
   }
8c4b153
 }
8c4b153
@@ -991,7 +991,7 @@
8c4b153
   case NOERROR:
8c4b153
     if (hp->ancount) {
8c4b153
       if (debug) {
8c4b153
-	sprintf(tempstring,"Resolver: Received nameserver reply. (qd:%u an:%u ns:%u ar:%u)",
8c4b153
+	snprintf(tempstring, sizeof(tempstring), "Resolver: Received nameserver reply. (qd:%u an:%u ns:%u ar:%u)",
8c4b153
                 hp->qdcount,hp->ancount,hp->nscount,hp->arcount);
8c4b153
 	restell(tempstring);
8c4b153
       }
8c4b153
@@ -1031,14 +1031,14 @@
8c4b153
       namestring[strlen(stackstring)] = '\0';
8c4b153
       if (strcasecmp(stackstring,namestring)) {
8c4b153
 	if (debug) {
8c4b153
-	  sprintf(tempstring,"Resolver: Unknown query packet dropped. (\"%s\" does not match \"%s\")",
8c4b153
+	  snprintf(tempstring, sizeof(tempstring), "Resolver: Unknown query packet dropped. (\"%s\" does not match \"%s\")",
8c4b153
 		  stackstring,namestring);
8c4b153
 	  restell(tempstring);
8c4b153
 	}
8c4b153
 	return;
8c4b153
       }
8c4b153
       if (debug) {
8c4b153
-	sprintf(tempstring,"Resolver: Queried domain name: \"%s\"",namestring);
8c4b153
+	snprintf(tempstring, sizeof(tempstring), "Resolver: Queried domain name: \"%s\"",namestring);
8c4b153
 	restell(tempstring);
8c4b153
       }
8c4b153
       c+= r;
8c4b153
@@ -1049,7 +1049,7 @@
8c4b153
       qdatatype = sucknetword(c);
8c4b153
       qclass = sucknetword(c);
8c4b153
       if (qclass != C_IN) {
8c4b153
-	sprintf(tempstring,"Resolver error: Received unsupported query class: %u (%s)",
8c4b153
+	snprintf(tempstring, sizeof(tempstring), "Resolver error: Received unsupported query class: %u (%s)",
8c4b153
                 qclass,qclass < ClasstypeCount ? classtypes[qclass] :
8c4b153
 		classtypes[ClasstypeCount]);
8c4b153
 	restell(tempstring);
8c4b153
@@ -1063,7 +1063,7 @@
8c4b153
 	  }
8c4b153
 	break;
8c4b153
       default:
8c4b153
-	sprintf(tempstring,"Resolver error: Received unimplemented query type: %u (%s)",
8c4b153
+	snprintf(tempstring, sizeof(tempstring), "Resolver error: Received unimplemented query type: %u (%s)",
8c4b153
 		qdatatype,qdatatype < ResourcetypeCount ?
8c4b153
 		resourcetypes[qdatatype] : resourcetypes[ResourcetypeCount]);
8c4b153
 	restell(tempstring);
8c4b153
@@ -1085,7 +1085,7 @@
8c4b153
 	else
8c4b153
 	  usefulanswer = 1;
8c4b153
 	if (debug) {
8c4b153
-	  sprintf(tempstring,"Resolver: answered domain query: \"%s\"",namestring);
8c4b153
+	  snprintf(tempstring, sizeof(tempstring), "Resolver: answered domain query: \"%s\"",namestring);
8c4b153
 	  restell(tempstring);
8c4b153
 	}
8c4b153
 	c+= r;
8c4b153
@@ -1098,10 +1098,10 @@
8c4b153
 	ttl = sucknetlong(c);
8c4b153
 	rdatalength = sucknetword(c);
8c4b153
 	if (class != qclass) {
8c4b153
-	  sprintf(tempstring,"query class: %u (%s)",qclass,qclass < ClasstypeCount ?
8c4b153
+	  snprintf(tempstring, sizeof(tempstring), "query class: %u (%s)",qclass,qclass < ClasstypeCount ?
8c4b153
 		  classtypes[qclass] : classtypes[ClasstypeCount]);
8c4b153
 	  restell(tempstring);
8c4b153
-	  sprintf(tempstring,"rr class: %u (%s)",class,class < ClasstypeCount ?
8c4b153
+	  snprintf(tempstring, sizeof(tempstring), "rr class: %u (%s)",class,class < ClasstypeCount ?
8c4b153
 		  classtypes[class] : classtypes[ClasstypeCount]);
8c4b153
 	  restell(tempstring);
8c4b153
 	  restell("Resolver error: Answered class does not match queried class.");
8c4b153
@@ -1117,20 +1117,20 @@
8c4b153
 	}
8c4b153
 	if (datatype == qdatatype || datatype == T_CNAME) {
8c4b153
 	  if (debug) {
8c4b153
-	    sprintf(tempstring,"Resolver: TTL: %s",strtdiff(sendstring,ttl));
8c4b153
+	    snprintf(tempstring, sizeof(tempstring), "Resolver: TTL: %s",strtdiff(sendstring,ttl));
8c4b153
 	    restell(tempstring);
8c4b153
 	  }
8c4b153
 	  if (usefulanswer)
8c4b153
 	    switch (datatype) {
8c4b153
 	    case T_A:
8c4b153
 	      if (rdatalength != 4) {
8c4b153
-		sprintf(tempstring,"Resolver error: Unsupported rdata format for \"A\" type. (%u bytes)",
8c4b153
+		snprintf(tempstring, sizeof(tempstring), "Resolver error: Unsupported rdata format for \"A\" type. (%u bytes)",
8c4b153
 			rdatalength);
8c4b153
 		restell(tempstring);
8c4b153
 		return;
8c4b153
 	      }
8c4b153
 	      if ( addrcmp( (void *) &(rp->ip), (void *) c, af ) == 0 ) {
8c4b153
-		sprintf(tempstring,"Resolver: Reverse authentication failed: %s != ",
8c4b153
+		snprintf(tempstring, sizeof(tempstring), "Resolver: Reverse authentication failed: %s != ",
8c4b153
 			strlongip( &(rp->ip) ));
8c4b153
 		addrcpy( (void *) &alignedip, (void *) c, af );
8c4b153
 		strcat(tempstring,strlongip( &alignedip ));
8c4b153
@@ -1138,7 +1138,7 @@
8c4b153
 		res_hostipmismatch++;
8c4b153
 		failrp(rp);
8c4b153
 	      } else {
8c4b153
-		sprintf(tempstring,"Resolver: Reverse authentication complete: %s == \"%s\".",
8c4b153
+		snprintf(tempstring, sizeof(tempstring), "Resolver: Reverse authentication complete: %s == \"%s\".",
8c4b153
 			strlongip( &(rp->ip) ),nonull(rp->hostname));
8c4b153
 		restell(tempstring);
8c4b153
 		res_reversesuccess++;
8c4b153
@@ -1155,7 +1155,7 @@
8c4b153
 		return;
8c4b153
 	      }
8c4b153
 	      if (debug) {
8c4b153
-		sprintf(tempstring,"Resolver: Answered domain: \"%s\"",namestring);
8c4b153
+		snprintf(tempstring, sizeof(tempstring), "Resolver: Answered domain: \"%s\"",namestring);
8c4b153
 		restell(tempstring);
8c4b153
 	      }
8c4b153
 	      if (r > HostnameLength) {
8c4b153
@@ -1180,14 +1180,14 @@
8c4b153
 	      }
8c4b153
 	      break;
8c4b153
 	    default:
8c4b153
-	      sprintf(tempstring,"Resolver error: Received unimplemented data type: %u (%s)",
8c4b153
+	      snprintf(tempstring, sizeof(tempstring), "Resolver error: Received unimplemented data type: %u (%s)",
8c4b153
 		      datatype,datatype < ResourcetypeCount ?
8c4b153
 		      resourcetypes[datatype] : resourcetypes[ResourcetypeCount]);
8c4b153
 	      restell(tempstring);
8c4b153
 	    }
8c4b153
 	} else {
8c4b153
 	  if (debug) {
8c4b153
-	    sprintf(tempstring,"Resolver: Ignoring resource type %u. (%s)",
8c4b153
+	    snprintf(tempstring, sizeof(tempstring), "Resolver: Ignoring resource type %u. (%s)",
8c4b153
 		    datatype,datatype < ResourcetypeCount ?
8c4b153
 		    resourcetypes[datatype] : resourcetypes[ResourcetypeCount]);
8c4b153
 	    restell(tempstring);
8c4b153
@@ -1205,7 +1205,7 @@
8c4b153
     failrp(rp);
8c4b153
     break;
8c4b153
   default:
8c4b153
-    sprintf(tempstring,"Resolver: Received error response %u. (%s)",
8c4b153
+    snprintf(tempstring, sizeof(tempstring), "Resolver: Received error response %u. (%s)",
8c4b153
 	    getheader_rcode(hp),getheader_rcode(hp) < ResponsecodeCount ?
8c4b153
 	    responsecodes[getheader_rcode(hp)] : responsecodes[ResponsecodeCount]);
8c4b153
     restell(tempstring);
8c4b153
@@ -1236,13 +1236,13 @@
8c4b153
 		      (void *) &(from4->sin_addr), AF_INET ) == 0 )
8c4b153
 	  break;
8c4b153
     if (i == _res.nscount) {
8c4b153
-      sprintf(tempstring,"Resolver error: Received reply from unknown source: %s",
8c4b153
+      snprintf(tempstring, sizeof(tempstring), "Resolver error: Received reply from unknown source: %s",
8c4b153
 	      inet_ntoa(from4->sin_addr ));
8c4b153
       restell(tempstring);
8c4b153
     } else
8c4b153
       parserespacket((byte *)resrecvbuf,r);
8c4b153
   } else {
8c4b153
-    sprintf(tempstring,"Resolver: Socket error: %s",strerror(errno));
8c4b153
+    snprintf(tempstring, sizeof(tempstring), "Resolver: Socket error: %s",strerror(errno));
8c4b153
     restell(tempstring);
8c4b153
   }
8c4b153
 }
8c4b153
@@ -1271,7 +1271,7 @@
8c4b153
     case STATE_FINISHED:	/* TTL has expired */
8c4b153
     case STATE_FAILED:	/* Fake TTL has expired */
8c4b153
       if (debug) {
8c4b153
-	sprintf(tempstring,"Resolver: Cache record for \"%s\" (%s) has expired. (state: %u)  Marked for expire at: %g, time: %g.",
8c4b153
+	snprintf(tempstring, sizeof(tempstring), "Resolver: Cache record for \"%s\" (%s) has expired. (state: %u)  Marked for expire at: %g, time: %g.",
8c4b153
                 nonull(rp->hostname), strlongip( &(rp->ip) ), 
8c4b153
 		rp->state, rp->expiretime, sweeptime);
8c4b153
 	restell(tempstring);
8c4b153
@@ -1315,14 +1315,14 @@
8c4b153
     if ((rp->state == STATE_FINISHED) || (rp->state == STATE_FAILED)) {
8c4b153
       if ((rp->state == STATE_FINISHED) && (rp->hostname)) {
8c4b153
 	if (debug) {
8c4b153
-	  sprintf(tempstring,"Resolver: Used cached record: %s == \"%s\".\n",
8c4b153
+	  snprintf(tempstring, sizeof(tempstring), "Resolver: Used cached record: %s == \"%s\".\n",
8c4b153
 		  strlongip(ip),rp->hostname);
8c4b153
 	  restell(tempstring);
8c4b153
 	}
8c4b153
 	return rp->hostname;
8c4b153
       } else {
8c4b153
 	if (debug) {
8c4b153
-	  sprintf(tempstring,"Resolver: Used failed record: %s == ???\n",
8c4b153
+	  snprintf(tempstring, sizeof(tempstring), "Resolver: Used failed record: %s == ???\n",
8c4b153
 		  strlongip(ip));
8c4b153
 	  restell(tempstring);
8c4b153
 	}
8c4b153
--- mtr-0.69/split.c.CVE-2002-0497	2005-01-11 09:34:07.000000000 +0100
8c4b153
+++ mtr-0.69/split.c	2005-02-09 18:13:58.000000000 +0100
8c4b153
@@ -103,13 +103,13 @@
8c4b153
       name = dns_lookup(addr);
8c4b153
       if(name != NULL) {
8c4b153
 	/* May be we should test name's length */
8c4b153
-	sprintf(newLine, "%s %d %d %d %d %d %d", name,
8c4b153
+	snprintf(newLine, sizeof(newLine), "%s %d %d %d %d %d %d", name,
8c4b153
 		net_loss(at),
8c4b153
 		net_returned(at), net_xmit(at),
8c4b153
 		net_best(at) /1000, net_avg(at)/1000, 
8c4b153
 		net_worst(at)/1000);
8c4b153
       } else {
8c4b153
-	sprintf(newLine, "%s %d %d %d %d %d %d", 
8c4b153
+	snprintf(newLine, sizeof(newLine), "%s %d %d %d %d %d %d", 
8c4b153
 		strlongip( addr ),
8c4b153
 		net_loss(at),
8c4b153
 		net_returned(at), net_xmit(at),