From 9ae0d5e65685449cb33355276299bc619191dc9a Mon Sep 17 00:00:00 2001 From: Ciccio87 Date: Sat, 17 Aug 2013 07:26:44 +0200 Subject: [PATCH 1/4] quick and dirty fix to make it compile and (seemingly) work on 32 bits systems, it needs more testing though --- lib/blacklist.c | 2 +- src/zmap.c | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/blacklist.c b/lib/blacklist.c index 9647e4b..2b8a70e 100644 --- a/lib/blacklist.c +++ b/lib/blacklist.c @@ -124,6 +124,6 @@ int blacklist_init_from_files(char *whitelist_filename, char *blacklist_filename constraint_optimize(constraint); uint64_t allowed = blacklist_count_allowed(); log_debug("blacklist", "%lu addresses allowed to be scanned (%0.0f%% of address space)", - allowed, allowed*100./(1L << 32)); + allowed, allowed*100./(1L << (int)sizeof(long)*4)); return 0; } diff --git a/src/zmap.c b/src/zmap.c index 9ebab9e..33c4a7b 100644 --- a/src/zmap.c +++ b/src/zmap.c @@ -81,7 +81,7 @@ static void *start_mon(__attribute__((unused)) void *arg) #define SI(w,x,y) printf("%s\t%s\t%i\n", w, x, y); #define SD(w,x,y) printf("%s\t%s\t%f\n", w, x, y); #define SU(w,x,y) printf("%s\t%s\t%u\n", w, x, y); -#define SLU(w,x,y) printf("%s\t%s\t%lu\n", w, x, y); +#define SLU(w,x,y) printf("%s\t%s\t%lu\n", w, x, (long unsigned int)y); #define SS(w,x,y) printf("%s\t%s\t%s\n", w, x, y); #define STRTIME_LEN 1024 @@ -458,7 +458,7 @@ int main(int argc, char *argv[]) } if (end[0] == '%' && end[1] == '\0') { // treat as percentage - v = v * (1L << 32) / 100.; + v = v * (1L << (int)sizeof(long)*4) / 100.; } else if (end[0] != '\0') { fprintf(stderr, "%s: extra characters after max-targets\n", CMDLINE_PARSER_PACKAGE); @@ -467,7 +467,7 @@ int main(int argc, char *argv[]) if (v <= 0) { zconf.max_targets = 0; } - else if (v >= (1L << 32)) { + else if (v >= (1L << (int)sizeof(long)*4)) { zconf.max_targets = 0xFFFFFFFF; } else { zconf.max_targets = v; From b90a9016847ef4171d8685be7f5bd1d502a20dc5 Mon Sep 17 00:00:00 2001 From: ciccio87 Date: Sat, 17 Aug 2013 08:04:19 +0200 Subject: [PATCH 2/4] OK, now the 32bit fix should be working, keeping numbers right (maybe issues could still exists in summary print) --- src/zmap.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/zmap.c b/src/zmap.c index 33c4a7b..ca3d495 100644 --- a/src/zmap.c +++ b/src/zmap.c @@ -458,7 +458,7 @@ int main(int argc, char *argv[]) } if (end[0] == '%' && end[1] == '\0') { // treat as percentage - v = v * (1L << (int)sizeof(long)*4) / 100.; + v = v * ((unsigned long long int)1 << 32) / 100.; } else if (end[0] != '\0') { fprintf(stderr, "%s: extra characters after max-targets\n", CMDLINE_PARSER_PACKAGE); @@ -467,7 +467,7 @@ int main(int argc, char *argv[]) if (v <= 0) { zconf.max_targets = 0; } - else if (v >= (1L << (int)sizeof(long)*4)) { + else if (v >= ((unsigned long long int)1 << 32)) { zconf.max_targets = 0xFFFFFFFF; } else { zconf.max_targets = v; From 4f860d66db128756f6092653a5ed025167236d9f Mon Sep 17 00:00:00 2001 From: ciccio87 Date: Sat, 17 Aug 2013 08:13:01 +0200 Subject: [PATCH 3/4] fixed blacklist.c --- lib/blacklist.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/blacklist.c b/lib/blacklist.c index 2b8a70e..49eaa32 100644 --- a/lib/blacklist.c +++ b/lib/blacklist.c @@ -124,6 +124,6 @@ int blacklist_init_from_files(char *whitelist_filename, char *blacklist_filename constraint_optimize(constraint); uint64_t allowed = blacklist_count_allowed(); log_debug("blacklist", "%lu addresses allowed to be scanned (%0.0f%% of address space)", - allowed, allowed*100./(1L << (int)sizeof(long)*4)); + allowed, allowed*100./((long long int)1 << 32)); return 0; } From 69f22bb9960d1a1f672c39f2a397d9d4d7c31115 Mon Sep 17 00:00:00 2001 From: ciccio-87 Date: Sat, 17 Aug 2013 08:19:56 +0200 Subject: [PATCH 4/4] Update README --- README | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README b/README index 87d118c..76a9141 100644 --- a/README +++ b/README @@ -1,3 +1,9 @@ +============================================================================== +Now it should be working on 32 bits systems (only possible issues +should be on some prints). +Further testing is needed though +============================================================================== + ZMap is a fast network scanner designed for Internet-wide network surveys. On a typical desktop computer with a gigabit Ethernet connection, ZMap is capable scanning the entire public IPv4 address space in under 45 minutes.