Dolda2000 GitWeb
/
icmp-dn.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
GITified repo.
[icmp-dn.git]
/
src
/
idnlookup.c
diff --git
a/src/idnlookup.c
b/src/idnlookup.c
index
e97f62f
..
4866c81
100644
(file)
--- a/
src/idnlookup.c
+++ b/
src/idnlookup.c
@@
-31,33
+31,11
@@
#include <sys/types.h>
#include <sys/poll.h>
#include <sys/time.h>
#include <sys/types.h>
#include <sys/poll.h>
#include <sys/time.h>
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
-struct icmphdr {
- u_int8_t type;
- u_int8_t code;
- u_int16_t checksum;
-};
-
-struct reqhdr {
- u_int8_t type;
- u_int8_t code;
- u_int16_t checksum;
- u_int16_t id;
- u_int16_t seq;
-};
-
-struct rephdr {
- u_int8_t type;
- u_int8_t code;
- u_int16_t checksum;
- u_int16_t id;
- u_int16_t seq;
- int32_t ttl;
-
-};
-
-#define ICMP_NAMEREQ 37
-#define ICMP_NAMEREP 38
+#include "icmpdefs.h"
unsigned char buf[65536];
unsigned char buf[65536];
@@
-75,6
+53,10
@@
void printdn(FILE *f, unsigned char *dnbuf, size_t size, int onlyfirst)
fprintf(stderr, "domain name decompression not implemented, aborting\n");
exit(1);
}
fprintf(stderr, "domain name decompression not implemented, aborting\n");
exit(1);
}
+ if((int)*p + (p - dnbuf) >= size) {
+ fprintf(stderr, "malformed domain name\n");
+ return;
+ }
fprintf(f, "%.*s", (int)*p, p + 1);
p += 1 + (int)*p;
if(*p != 0)
fprintf(f, "%.*s", (int)*p, p + 1);
p += 1 + (int)*p;
if(*p != 0)
@@
-175,7
+157,10
@@
int main(int argc, char **argv)
memset(&aihint, 0, sizeof(aihint));
aihint.ai_socktype = SOCK_RAW;
aihint.ai_protocol = IPPROTO_ICMP;
memset(&aihint, 0, sizeof(aihint));
aihint.ai_socktype = SOCK_RAW;
aihint.ai_protocol = IPPROTO_ICMP;
- ret = getaddrinfo(argv[optind], NULL, &aihint, &ai);
+ if((ret = getaddrinfo(argv[optind], NULL, &aihint, &ai)) != 0) {
+ fprintf(stderr, "%s: %s\n", argv[optind], gai_strerror(ret));
+ exit(1);
+ }
for(cai = ai; cai != NULL; cai = cai->ai_next) {
if((s = socket(cai->ai_family, SOCK_RAW, IPPROTO_ICMP)) < 0) {
for(cai = ai; cai != NULL; cai = cai->ai_next) {
if((s = socket(cai->ai_family, SOCK_RAW, IPPROTO_ICMP)) < 0) {
@@
-276,6
+261,6
@@
int main(int argc, char **argv)
/*
* Local Variables:
/*
* Local Variables:
- * compile-command: "
gcc -Wall -g -o idnlookup idnlookup.c
"
+ * compile-command: "
make CFLAGS='-Wall -g'
"
* End:
*/
* End:
*/