Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 223017
Collapse All | Expand All

(-)mtr-0.73/dns.c (-24 / +24 lines)
Lines 883-889 void resendrequest(struct resolve *rp,in Link Here
883
  if (type == T_A) {
883
  if (type == T_A) {
884
    dorequest(rp->hostname,type,rp->id);
884
    dorequest(rp->hostname,type,rp->id);
885
    if (debug) {
885
    if (debug) {
886
      sprintf(tempstring,"Resolver: Sent reverse authentication request for \"%s\".",
886
      snprintf(tempstring, sizeof(tempstring), "Resolver: Sent reverse authentication request for \"%s\".",
887
	      rp->hostname);
887
	      rp->hostname);
888
      restell(tempstring);
888
      restell(tempstring);
889
    }
889
    }
Lines 904-910 void resendrequest(struct resolve *rp,in Link Here
904
    }
904
    }
905
    dorequest(tempstring,type,rp->id);
905
    dorequest(tempstring,type,rp->id);
906
    if (debug) {
906
    if (debug) {
907
      sprintf(tempstring,"Resolver: Sent domain lookup request for \"%s\".",
907
      snprintf(tempstring, sizeof(tempstring), "Resolver: Sent domain lookup request for \"%s\".",
908
	      strlongip( &(rp->ip) ));
908
	      strlongip( &(rp->ip) ));
909
      restell(tempstring);
909
      restell(tempstring);
910
    }
910
    }
Lines 940-946 void passrp(struct resolve *rp,long ttl) Link Here
940
  rp->expiretime = sweeptime + (double)ttl;
940
  rp->expiretime = sweeptime + (double)ttl;
941
  untieresolve(rp);
941
  untieresolve(rp);
942
  if (debug) {
942
  if (debug) {
943
    sprintf(tempstring,"Resolver: Lookup successful: %s\n",rp->hostname);
943
    snprintf(tempstring, sizeof(tempstring), "Resolver: Lookup successful: %s\n",rp->hostname);
944
    restell(tempstring);
944
    restell(tempstring);
945
  }
945
  }
946
}
946
}
Lines 997-1003 void parserespacket(byte *s, int l) Link Here
997
  case NOERROR:
997
  case NOERROR:
998
    if (hp->ancount) {
998
    if (hp->ancount) {
999
      if (debug) {
999
      if (debug) {
1000
	sprintf(tempstring,"Resolver: Received nameserver reply. (qd:%u an:%u ns:%u ar:%u)",
1000
	snprintf(tempstring, sizeof(tempstring), "Resolver: Received nameserver reply. (qd:%u an:%u ns:%u ar:%u)",
1001
                hp->qdcount,hp->ancount,hp->nscount,hp->arcount);
1001
                hp->qdcount,hp->ancount,hp->nscount,hp->arcount);
1002
	restell(tempstring);
1002
	restell(tempstring);
1003
      }
1003
      }
Lines 1037-1050 void parserespacket(byte *s, int l) Link Here
1037
      namestring[strlen(stackstring)] = '\0';
1037
      namestring[strlen(stackstring)] = '\0';
1038
      if (strcasecmp(stackstring,namestring)) {
1038
      if (strcasecmp(stackstring,namestring)) {
1039
	if (debug) {
1039
	if (debug) {
1040
	  sprintf(tempstring,"Resolver: Unknown query packet dropped. (\"%s\" does not match \"%s\")",
1040
	  snprintf(tempstring, sizeof(tempstring), "Resolver: Unknown query packet dropped. (\"%s\" does not match \"%s\")",
1041
		  stackstring,namestring);
1041
		  stackstring,namestring);
1042
	  restell(tempstring);
1042
	  restell(tempstring);
1043
	}
1043
	}
1044
	return;
1044
	return;
1045
      }
1045
      }
1046
      if (debug) {
1046
      if (debug) {
1047
	sprintf(tempstring,"Resolver: Queried domain name: \"%s\"",namestring);
1047
	snprintf(tempstring, sizeof(tempstring), "Resolver: Queried domain name: \"%s\"",namestring);
1048
	restell(tempstring);
1048
	restell(tempstring);
1049
      }
1049
      }
1050
      c+= r;
1050
      c+= r;
Lines 1055-1061 void parserespacket(byte *s, int l) Link Here
1055
      qdatatype = sucknetword(c);
1055
      qdatatype = sucknetword(c);
1056
      qclass = sucknetword(c);
1056
      qclass = sucknetword(c);
1057
      if (qclass != C_IN) {
1057
      if (qclass != C_IN) {
1058
	sprintf(tempstring,"Resolver error: Received unsupported query class: %u (%s)",
1058
	snprintf(tempstring, sizeof(tempstring), "Resolver error: Received unsupported query class: %u (%s)",
1059
                qclass,qclass < ClasstypeCount ? classtypes[qclass] :
1059
                qclass,qclass < ClasstypeCount ? classtypes[qclass] :
1060
		classtypes[ClasstypeCount]);
1060
		classtypes[ClasstypeCount]);
1061
	restell(tempstring);
1061
	restell(tempstring);
Lines 1069-1075 void parserespacket(byte *s, int l) Link Here
1069
	  }
1069
	  }
1070
	break;
1070
	break;
1071
      default:
1071
      default:
1072
	sprintf(tempstring,"Resolver error: Received unimplemented query type: %u (%s)",
1072
	snprintf(tempstring, sizeof(tempstring), "Resolver error: Received unimplemented query type: %u (%s)",
1073
		qdatatype,qdatatype < ResourcetypeCount ?
1073
		qdatatype,qdatatype < ResourcetypeCount ?
1074
		resourcetypes[qdatatype] : resourcetypes[ResourcetypeCount]);
1074
		resourcetypes[qdatatype] : resourcetypes[ResourcetypeCount]);
1075
	restell(tempstring);
1075
	restell(tempstring);
Lines 1091-1097 void parserespacket(byte *s, int l) Link Here
1091
	else
1091
	else
1092
	  usefulanswer = 1;
1092
	  usefulanswer = 1;
1093
	if (debug) {
1093
	if (debug) {
1094
	  sprintf(tempstring,"Resolver: answered domain query: \"%s\"",namestring);
1094
	  snprintf(tempstring, sizeof(tempstring), "Resolver: answered domain query: \"%s\"",namestring);
1095
	  restell(tempstring);
1095
	  restell(tempstring);
1096
	}
1096
	}
1097
	c+= r;
1097
	c+= r;
Lines 1104-1113 void parserespacket(byte *s, int l) Link Here
1104
	ttl = sucknetlong(c);
1104
	ttl = sucknetlong(c);
1105
	rdatalength = sucknetword(c);
1105
	rdatalength = sucknetword(c);
1106
	if (class != qclass) {
1106
	if (class != qclass) {
1107
	  sprintf(tempstring,"query class: %u (%s)",qclass,qclass < ClasstypeCount ?
1107
	  snprintf(tempstring, sizeof(tempstring), "query class: %u (%s)",qclass,qclass < ClasstypeCount ?
1108
		  classtypes[qclass] : classtypes[ClasstypeCount]);
1108
		  classtypes[qclass] : classtypes[ClasstypeCount]);
1109
	  restell(tempstring);
1109
	  restell(tempstring);
1110
	  sprintf(tempstring,"rr class: %u (%s)",class,class < ClasstypeCount ?
1110
	  snprintf(tempstring, sizeof(tempstring), "rr class: %u (%s)",class,class < ClasstypeCount ?
1111
		  classtypes[class] : classtypes[ClasstypeCount]);
1111
		  classtypes[class] : classtypes[ClasstypeCount]);
1112
	  restell(tempstring);
1112
	  restell(tempstring);
1113
	  restell("Resolver error: Answered class does not match queried class.");
1113
	  restell("Resolver error: Answered class does not match queried class.");
Lines 1123-1142 void parserespacket(byte *s, int l) Link Here
1123
	}
1123
	}
1124
	if (datatype == qdatatype || datatype == T_CNAME) {
1124
	if (datatype == qdatatype || datatype == T_CNAME) {
1125
	  if (debug) {
1125
	  if (debug) {
1126
	    sprintf(tempstring,"Resolver: TTL: %s",strtdiff(sendstring,ttl));
1126
	    snprintf(tempstring, sizeof(tempstring), "Resolver: TTL: %s",strtdiff(sendstring,ttl));
1127
	    restell(tempstring);
1127
	    restell(tempstring);
1128
	  }
1128
	  }
1129
	  if (usefulanswer)
1129
	  if (usefulanswer)
1130
	    switch (datatype) {
1130
	    switch (datatype) {
1131
	    case T_A:
1131
	    case T_A:
1132
	      if (rdatalength != 4) {
1132
	      if (rdatalength != 4) {
1133
		sprintf(tempstring,"Resolver error: Unsupported rdata format for \"A\" type. (%u bytes)",
1133
		snprintf(tempstring, sizeof(tempstring), "Resolver error: Unsupported rdata format for \"A\" type. (%u bytes)",
1134
			rdatalength);
1134
			rdatalength);
1135
		restell(tempstring);
1135
		restell(tempstring);
1136
		return;
1136
		return;
1137
	      }
1137
	      }
1138
	      if ( addrcmp( (void *) &(rp->ip), (void *) c, af ) == 0 ) {
1138
	      if ( addrcmp( (void *) &(rp->ip), (void *) c, af ) == 0 ) {
1139
		sprintf(tempstring,"Resolver: Reverse authentication failed: %s != ",
1139
		snprintf(tempstring, sizeof(tempstring), "Resolver: Reverse authentication failed: %s != ",
1140
			strlongip( &(rp->ip) ));
1140
			strlongip( &(rp->ip) ));
1141
		addrcpy( (void *) &alignedip, (void *) c, af );
1141
		addrcpy( (void *) &alignedip, (void *) c, af );
1142
		strcat(tempstring,strlongip( &alignedip ));
1142
		strcat(tempstring,strlongip( &alignedip ));
Lines 1144-1150 void parserespacket(byte *s, int l) Link Here
1144
		res_hostipmismatch++;
1144
		res_hostipmismatch++;
1145
		failrp(rp);
1145
		failrp(rp);
1146
	      } else {
1146
	      } else {
1147
		sprintf(tempstring,"Resolver: Reverse authentication complete: %s == \"%s\".",
1147
		snprintf(tempstring, sizeof(tempstring), "Resolver: Reverse authentication complete: %s == \"%s\".",
1148
			strlongip( &(rp->ip) ),nonull(rp->hostname));
1148
			strlongip( &(rp->ip) ),nonull(rp->hostname));
1149
		restell(tempstring);
1149
		restell(tempstring);
1150
		res_reversesuccess++;
1150
		res_reversesuccess++;
Lines 1161-1167 void parserespacket(byte *s, int l) Link Here
1161
		return;
1161
		return;
1162
	      }
1162
	      }
1163
	      if (debug) {
1163
	      if (debug) {
1164
		sprintf(tempstring,"Resolver: Answered domain: \"%s\"",namestring);
1164
		snprintf(tempstring, sizeof(tempstring), "Resolver: Answered domain: \"%s\"",namestring);
1165
		restell(tempstring);
1165
		restell(tempstring);
1166
	      }
1166
	      }
1167
	      if (r > HostnameLength) {
1167
	      if (r > HostnameLength) {
Lines 1186-1199 void parserespacket(byte *s, int l) Link Here
1186
	      }
1186
	      }
1187
	      break;
1187
	      break;
1188
	    default:
1188
	    default:
1189
	      sprintf(tempstring,"Resolver error: Received unimplemented data type: %u (%s)",
1189
	      snprintf(tempstring, sizeof(tempstring), "Resolver error: Received unimplemented data type: %u (%s)",
1190
		      datatype,datatype < ResourcetypeCount ?
1190
		      datatype,datatype < ResourcetypeCount ?
1191
		      resourcetypes[datatype] : resourcetypes[ResourcetypeCount]);
1191
		      resourcetypes[datatype] : resourcetypes[ResourcetypeCount]);
1192
	      restell(tempstring);
1192
	      restell(tempstring);
1193
	    }
1193
	    }
1194
	} else {
1194
	} else {
1195
	  if (debug) {
1195
	  if (debug) {
1196
	    sprintf(tempstring,"Resolver: Ignoring resource type %u. (%s)",
1196
	    snprintf(tempstring, sizeof(tempstring), "Resolver: Ignoring resource type %u. (%s)",
1197
		    datatype,datatype < ResourcetypeCount ?
1197
		    datatype,datatype < ResourcetypeCount ?
1198
		    resourcetypes[datatype] : resourcetypes[ResourcetypeCount]);
1198
		    resourcetypes[datatype] : resourcetypes[ResourcetypeCount]);
1199
	    restell(tempstring);
1199
	    restell(tempstring);
Lines 1211-1217 void parserespacket(byte *s, int l) Link Here
1211
    failrp(rp);
1211
    failrp(rp);
1212
    break;
1212
    break;
1213
  default:
1213
  default:
1214
    sprintf(tempstring,"Resolver: Received error response %u. (%s)",
1214
    snprintf(tempstring, sizeof(tempstring), "Resolver: Received error response %u. (%s)",
1215
	    getheader_rcode(hp),getheader_rcode(hp) < ResponsecodeCount ?
1215
	    getheader_rcode(hp),getheader_rcode(hp) < ResponsecodeCount ?
1216
	    responsecodes[getheader_rcode(hp)] : responsecodes[ResponsecodeCount]);
1216
	    responsecodes[getheader_rcode(hp)] : responsecodes[ResponsecodeCount]);
1217
    restell(tempstring);
1217
    restell(tempstring);
Lines 1242-1254 void dns_ack(void) Link Here
1242
		      (void *) &(from4->sin_addr), AF_INET ) == 0 )
1242
		      (void *) &(from4->sin_addr), AF_INET ) == 0 )
1243
	  break;
1243
	  break;
1244
    if (i == _res.nscount) {
1244
    if (i == _res.nscount) {
1245
      sprintf(tempstring,"Resolver error: Received reply from unknown source: %s",
1245
      snprintf(tempstring, sizeof(tempstring), "Resolver error: Received reply from unknown source: %s",
1246
	      inet_ntoa(from4->sin_addr ));
1246
	      inet_ntoa(from4->sin_addr ));
1247
      restell(tempstring);
1247
      restell(tempstring);
1248
    } else
1248
    } else
1249
      parserespacket((byte *)resrecvbuf,r);
1249
      parserespacket((byte *)resrecvbuf,r);
1250
  } else {
1250
  } else {
1251
    sprintf(tempstring,"Resolver: Socket error: %s",strerror(errno));
1251
    snprintf(tempstring, sizeof(tempstring), "Resolver: Socket error: %s",strerror(errno));
1252
    restell(tempstring);
1252
    restell(tempstring);
1253
  }
1253
  }
1254
}
1254
}
Lines 1277-1283 void dns_events(double *sinterval) Link Here
1277
    case STATE_FINISHED:	/* TTL has expired */
1277
    case STATE_FINISHED:	/* TTL has expired */
1278
    case STATE_FAILED:	/* Fake TTL has expired */
1278
    case STATE_FAILED:	/* Fake TTL has expired */
1279
      if (debug) {
1279
      if (debug) {
1280
	sprintf(tempstring,"Resolver: Cache record for \"%s\" (%s) has expired. (state: %u)  Marked for expire at: %g, time: %g.",
1280
	snprintf(tempstring, sizeof(tempstring), "Resolver: Cache record for \"%s\" (%s) has expired. (state: %u)  Marked for expire at: %g, time: %g.",
1281
                nonull(rp->hostname), strlongip( &(rp->ip) ), 
1281
                nonull(rp->hostname), strlongip( &(rp->ip) ), 
1282
		rp->state, rp->expiretime, sweeptime);
1282
		rp->state, rp->expiretime, sweeptime);
1283
	restell(tempstring);
1283
	restell(tempstring);
Lines 1321-1334 char *dns_lookup2(ip_t * ip) Link Here
1321
    if ((rp->state == STATE_FINISHED) || (rp->state == STATE_FAILED)) {
1321
    if ((rp->state == STATE_FINISHED) || (rp->state == STATE_FAILED)) {
1322
      if ((rp->state == STATE_FINISHED) && (rp->hostname)) {
1322
      if ((rp->state == STATE_FINISHED) && (rp->hostname)) {
1323
	if (debug) {
1323
	if (debug) {
1324
	  sprintf(tempstring,"Resolver: Used cached record: %s == \"%s\".\n",
1324
	  snprintf(tempstring, sizeof(tempstring), "Resolver: Used cached record: %s == \"%s\".\n",
1325
		  strlongip(ip),rp->hostname);
1325
		  strlongip(ip),rp->hostname);
1326
	  restell(tempstring);
1326
	  restell(tempstring);
1327
	}
1327
	}
1328
	return rp->hostname;
1328
	return rp->hostname;
1329
      } else {
1329
      } else {
1330
	if (debug) {
1330
	if (debug) {
1331
	  sprintf(tempstring,"Resolver: Used failed record: %s == ???\n",
1331
	  snprintf(tempstring, sizeof(tempstring), "Resolver: Used failed record: %s == ???\n",
1332
		  strlongip(ip));
1332
		  strlongip(ip));
1333
	  restell(tempstring);
1333
	  restell(tempstring);
1334
	}
1334
	}

Return to bug 223017