X-Git-Url: http://dolda2000.com/gitweb/?p=icmp-dn.git;a=blobdiff_plain;f=src%2Fidnlookup.c;h=b120c52090dcc5a55bb6a67d02b7d6de4dab8d07;hp=bab502da024acfe27823a30b5a0e3db229dc0aec;hb=29183b092874493c6585c4c0c3caf19683436945;hpb=2269406c64770520d8c504f925af30eebe60d5aa diff --git a/src/idnlookup.c b/src/idnlookup.c index bab502d..b120c52 100644 --- a/src/idnlookup.c +++ b/src/idnlookup.c @@ -31,34 +31,11 @@ #include #include #include +#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]; @@ -76,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); } + 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) @@ -277,6 +258,6 @@ int main(int argc, char **argv) /* * Local Variables: - * compile-command: "gcc -Wall -g -o idnlookup idnlookup.c" + * compile-command: "make CFLAGS='-Wall -g'" * End: */