From a64913d57382aa8a58c636861b7aa01f2b58136b Mon Sep 17 00:00:00 2001 From: Gianfranco Costamagna Date: Thu, 8 May 2014 17:33:58 +0200 Subject: [PATCH] Fixing issue #405, now etterfilter and etterlog uses dynamic gbls pointers --- include/ef.h | 5 ++- include/ef_functions.h | 8 ++--- include/el.h | 11 ++++--- utils/etterfilter/ef_main.c | 44 +++++++++++++++++--------- utils/etterfilter/ef_output.c | 6 ++-- utils/etterfilter/ef_parser.c | 12 ++++---- utils/etterfilter/ef_syntax.l | 2 +- utils/etterlog/el_analyze.c | 4 +-- utils/etterlog/el_conn.c | 14 ++++----- utils/etterlog/el_display.c | 56 ++++++++++++++++----------------- utils/etterlog/el_main.c | 58 +++++++++++++++++++++++------------ utils/etterlog/el_parser.c | 58 +++++++++++++++++------------------ utils/etterlog/el_target.c | 6 ++-- 13 files changed, 162 insertions(+), 122 deletions(-) diff --git a/include/ef.h b/include/ef.h index 0de9f7460..95256a4c6 100644 --- a/include/ef.h +++ b/include/ef.h @@ -65,7 +65,7 @@ struct globals { }; /* in el_main.c */ -extern struct globals gbls; +extern struct globals *gbls; #define GBL_OPTIONS gbls #define GBL gbls @@ -100,6 +100,9 @@ extern struct globals gbls; #define EC_COLOR_CYAN #endif +EC_API_EXTERN void globals_alloc(void); +EC_API_EXTERN void globals_free(void); + #endif /* EL_H */ /* EOF */ diff --git a/include/ef_functions.h b/include/ef_functions.h index 175bae088..2492d5c2b 100644 --- a/include/ef_functions.h +++ b/include/ef_functions.h @@ -3,13 +3,13 @@ #include -#define SCRIPT_ERROR(x, ...) FATAL_ERROR("\n[%s:%d]: "x, GBL_OPTIONS.source_file, GBL.lineno, ## __VA_ARGS__ ); +#define SCRIPT_ERROR(x, ...) FATAL_ERROR("\n[%s:%d]: "x, GBL_OPTIONS->source_file, GBL->lineno, ## __VA_ARGS__ ); #define WARNING(x) do { \ -if (!GBL_OPTIONS.suppress_warnings) \ - FATAL_ERROR("\n[%s:%ld]: WARNING "x, GBL_OPTIONS.source_file, (unsigned long)GBL.lineno); \ +if (!GBL_OPTIONS->suppress_warnings) \ + FATAL_ERROR("\n[%s:%ld]: WARNING "x, GBL_OPTIONS->source_file, (unsigned long)GBL->lineno); \ else \ - fprintf(stderr, "\n[%s:%ld]: WARNING "x, GBL_OPTIONS.source_file, (unsigned long)GBL.lineno); \ + fprintf(stderr, "\n[%s:%ld]: WARNING "x, GBL_OPTIONS->source_file, (unsigned long)GBL->lineno); \ } while(0) /* ef_main */ diff --git a/include/el.h b/include/el.h index b40e43de4..883767db1 100644 --- a/include/el.h +++ b/include/el.h @@ -103,14 +103,14 @@ struct globals { }; /* in el_main.c */ -extern struct globals gbls; +extern struct globals *gbls; #define GBL gbls -#define GBL_LOGFILE GBL.logfile -#define GBL_LOG_FD GBL.fd -#define GBL_TARGET (GBL.t) +#define GBL_LOGFILE GBL->logfile +#define GBL_LOG_FD GBL->fd +#define GBL_TARGET (GBL->t) #define GBL_PROGRAM "etterlog" @@ -148,6 +148,9 @@ extern struct globals gbls; #define COL_MAGENTA 35 #define COL_CYAN 36 +EC_API_EXTERN void globals_alloc(void); +EC_API_EXTERN void globals_free(void); + #endif /* EL_H */ diff --git a/utils/etterfilter/ef_main.c b/utils/etterfilter/ef_main.c index ed297d7e6..40f6e4057 100644 --- a/utils/etterfilter/ef_main.c +++ b/utils/etterfilter/ef_main.c @@ -25,35 +25,35 @@ #include +#define GBL_FREE(x) do{ if (x != NULL) { free(x); x = NULL; } }while(0) + /* globals */ extern FILE * yyin; /* from scanner */ extern int yyparse (void); /* from parser */ /* global options */ -struct globals gbls; - -/* protos */ -void clean_exit(int errcode); +struct globals *gbls; /*******************************************/ int main(int argc, char *argv[]) { + globals_alloc(); /* etterfilter copyright */ fprintf(stdout, "\n" EC_COLOR_BOLD "%s %s" EC_COLOR_END " copyright %s %s\n\n", GBL_PROGRAM, EC_VERSION, EC_COPYRIGHT, EC_AUTHORS); /* initialize the line number */ - GBL.lineno = 1; + GBL->lineno = 1; /* getopt related parsing... */ parse_options(argc, argv); /* set the input for source file */ - if (GBL_OPTIONS.source_file) { - yyin = fopen(GBL_OPTIONS.source_file, "r"); + if (GBL_OPTIONS->source_file) { + yyin = fopen(GBL_OPTIONS->source_file, "r"); if (yyin == NULL) FATAL_ERROR("Input file not found !"); } else { @@ -72,7 +72,7 @@ int main(int argc, char *argv[]) load_constants(); /* print the message */ - fprintf(stdout, "\n Parsing source file \'%s\' ", GBL_OPTIONS.source_file); + fprintf(stdout, "\n Parsing source file \'%s\' ", GBL_OPTIONS->source_file); fflush(stdout); ef_debug(1, "\n"); @@ -85,16 +85,12 @@ int main(int argc, char *argv[]) /* write to file */ if (write_output() != ESUCCESS) - FATAL_ERROR("Cannot write output file (%s)", GBL_OPTIONS.output_file); - + FATAL_ERROR("Cannot write output file (%s)", GBL_OPTIONS->output_file); + globals_free(); return 0; } -void clean_exit(int errcode) { - exit(errcode); -} - /* * print debug information */ @@ -103,7 +99,7 @@ void ef_debug(u_char level, const char *message, ...) va_list ap; /* if not in debug don't print anything */ - if (GBL_OPTIONS.debug < level) + if (GBL_OPTIONS->debug < level) return; /* print the mesasge */ @@ -114,6 +110,24 @@ void ef_debug(u_char level, const char *message, ...) } +void globals_alloc(void) +{ + + SAFE_CALLOC(gbls, 1, sizeof(struct globals)); + + return; +} + +void globals_free(void) +{ + SAFE_FREE(gbls->source_file); + SAFE_FREE(gbls->output_file); + SAFE_FREE(gbls); + + return; + +} + /* EOF */ // vim:ts=3:expandtab diff --git a/utils/etterfilter/ef_output.c b/utils/etterfilter/ef_output.c index 0c1bcda04..cc06b2c5d 100644 --- a/utils/etterfilter/ef_output.c +++ b/utils/etterfilter/ef_output.c @@ -52,11 +52,11 @@ int write_output(void) return -ENOTHANDLED; /* create the file */ - fd = open(GBL_OPTIONS.output_file, O_CREAT | O_RDWR | O_TRUNC | O_BINARY, 0644); - ON_ERROR(fd, -1, "Can't create file %s", GBL_OPTIONS.output_file); + fd = open(GBL_OPTIONS->output_file, O_CREAT | O_RDWR | O_TRUNC | O_BINARY, 0644); + ON_ERROR(fd, -1, "Can't create file %s", GBL_OPTIONS->output_file); /* display the message */ - fprintf(stdout, " Writing output to \'%s\' ", GBL_OPTIONS.output_file); + fprintf(stdout, " Writing output to \'%s\' ", GBL_OPTIONS->output_file); fflush(stdout); /* compute the header */ diff --git a/utils/etterfilter/ef_parser.c b/utils/etterfilter/ef_parser.c index b54104b13..afebf4194 100644 --- a/utils/etterfilter/ef_parser.c +++ b/utils/etterfilter/ef_parser.c @@ -86,16 +86,16 @@ void parse_options(int argc, char **argv) break; case 'o': - GBL_OPTIONS.output_file = strdup(optarg); + GBL_OPTIONS->output_file = strdup(optarg); break; case 'd': /* use many times to encrease debug level */ - GBL_OPTIONS.debug++; + GBL_OPTIONS->debug++; break; case 'w': - GBL_OPTIONS.suppress_warnings = 1; + GBL_OPTIONS->suppress_warnings = 1; break; case 'h': @@ -121,12 +121,12 @@ void parse_options(int argc, char **argv) /* the source file to be compiled */ if (argv[optind]) { - GBL_OPTIONS.source_file = strdup(argv[optind]); + GBL_OPTIONS->source_file = strdup(argv[optind]); } /* make the default name */ - if (GBL_OPTIONS.output_file == NULL) - GBL_OPTIONS.output_file = strdup("filter.ef"); + if (GBL_OPTIONS->output_file == NULL) + GBL_OPTIONS->output_file = strdup("filter.ef"); return; } diff --git a/utils/etterfilter/ef_syntax.l b/utils/etterfilter/ef_syntax.l index 7f92cd822..67efdfa09 100644 --- a/utils/etterfilter/ef_syntax.l +++ b/utils/etterfilter/ef_syntax.l @@ -203,7 +203,7 @@ SPACES [ \t]+ [\n\r] { /* increment the line number (used for error reporting) */ - GBL.lineno++; + GBL->lineno++; } . { diff --git a/utils/etterlog/el_analyze.c b/utils/etterlog/el_analyze.c index fc9799cec..ef6fb4ef0 100644 --- a/utils/etterlog/el_analyze.c +++ b/utils/etterlog/el_analyze.c @@ -33,7 +33,7 @@ void analyze_info(void); void analyze(void) { - switch(GBL.hdr.type) { + switch(GBL->hdr.type) { case LOG_PACKET: analyze_packet(); break; @@ -82,7 +82,7 @@ void analyze_packet(void) } /* get the file stat */ - ret = stat(GBL.logfile, &st); + ret = stat(GBL->logfile, &st); ON_ERROR(ret, -1, "Cannot stat file"); fprintf(stdout, "\n\n"); diff --git a/utils/etterlog/el_conn.c b/utils/etterlog/el_conn.c index f662029cb..28c6b3dab 100644 --- a/utils/etterlog/el_conn.c +++ b/utils/etterlog/el_conn.c @@ -54,7 +54,7 @@ void conn_table_create(void) int ret, count = 0; u_char *buf; - if (GBL.hdr.type == LOG_INFO) + if (GBL->hdr.type == LOG_INFO) FATAL_ERROR("LOG_INFO files don't contain connections !"); @@ -134,7 +134,7 @@ static int insert_table(struct log_header_packet *pck, char *buf) !ip_addr_cmp(&c->L3_dst, &pck->L3_dst)) { /* add to the stream (if necessary) */ - if (GBL.decode) + if (GBL->decode) stream_add(&c->so, pck, buf); return 0; @@ -148,7 +148,7 @@ static int insert_table(struct log_header_packet *pck, char *buf) !ip_addr_cmp(&c->L3_dst, &pck->L3_src)) { /* add to the stream (if necessary) */ - if (GBL.decode) + if (GBL->decode) stream_add(&c->so, pck, buf); return 0; @@ -170,7 +170,7 @@ static int insert_table(struct log_header_packet *pck, char *buf) stream_init(&c->so); /* add to the stream (if necessary) */ - if (GBL.decode) + if (GBL->decode) stream_add(&c->so, pck, buf); SLIST_INSERT_HEAD(&conn_list_head, c, next); @@ -265,7 +265,7 @@ int is_conn(struct log_header_packet *pck, int *versus) pck->L4_src == conn_target.L4_src && pck->L4_dst == conn_target.L4_dst && /* the packet is from source, but we are interested only in dest */ - !GBL.only_dest ) { + !GBL->only_dest ) { good = 1; *versus = VERSUS_SOURCE; } @@ -276,13 +276,13 @@ int is_conn(struct log_header_packet *pck, int *versus) pck->L4_src == conn_target.L4_dst && pck->L4_dst == conn_target.L4_src && /* the packet is from dest, but we are interested only in source */ - !GBL.only_source ) { + !GBL->only_source ) { good = 1; *versus = VERSUS_DEST; } /* check the reverse option */ - if (GBL.reverse ^ (good && proto) ) + if (GBL->reverse ^ (good && proto) ) return 1; else return 0; diff --git a/utils/etterlog/el_display.c b/utils/etterlog/el_display.c index 2035942f5..4ed3745eb 100644 --- a/utils/etterlog/el_display.c +++ b/utils/etterlog/el_display.c @@ -44,7 +44,7 @@ static void print_pass(struct host_profile *h); void display(void) { - switch(GBL.hdr.type) { + switch(GBL->hdr.type) { case LOG_PACKET: display_packet(); break; @@ -86,7 +86,7 @@ static void display_packet(void) } /* if the regex does not match, the packet is not interesting */ - if (GBL.regex && regexec(GBL.regex, (const char*)buf, 0, NULL, 0) != 0) { + if (GBL->regex && regexec(GBL->regex, (const char*)buf, 0, NULL, 0) != 0) { SAFE_FREE(buf); continue; } @@ -99,17 +99,17 @@ static void display_packet(void) SAFE_CALLOC(tmp, hex_len(pck.len), sizeof(u_char)); /* display the headers only if necessary */ - if (!GBL.no_headers) + if (!GBL->no_headers) display_headers(&pck); /* * format the packet with the function * set by the user */ - ret = GBL.format(buf, pck.len, tmp); + ret = GBL->format(buf, pck.len, tmp); /* the ANSI escape for the color */ - if (GBL.color) { + if (GBL->color) { int color = 0; switch (versus) { case VERSUS_SOURCE: @@ -125,14 +125,14 @@ static void display_packet(void) /* print it */ write(fileno(stdout), tmp, ret); - if (GBL.color) + if (GBL->color) reset_color(); SAFE_FREE(buf); SAFE_FREE(tmp); } - if (!GBL.no_headers) + if (!GBL->no_headers) write(fileno(stdout), "\n\n", 2); return; @@ -155,7 +155,7 @@ static void display_headers(struct log_header_packet *pck) /* display the date. ec_ctime() has no newline at end. */ fprintf(stdout, "\n\n%s [%lu]\n", ec_ctime(&pck->tv), pck->tv.tv_usec); - if (GBL.showmac) { + if (GBL->showmac) { /* display the mac addresses */ mac_addr_ntoa(pck->L2_src, tmp1); mac_addr_ntoa(pck->L2_dst, tmp2); @@ -201,13 +201,13 @@ void set_display_regex(char *regex) char errbuf[100]; /* allocate the new structure */ - SAFE_CALLOC(GBL.regex, 1, sizeof(regex_t)); + SAFE_CALLOC(GBL->regex, 1, sizeof(regex_t)); /* compile the regex */ - err = regcomp(GBL.regex, regex, REG_EXTENDED | REG_NOSUB | REG_ICASE ); + err = regcomp(GBL->regex, regex, REG_EXTENDED | REG_NOSUB | REG_ICASE ); if (err) { - regerror(err, GBL.regex, errbuf, sizeof(errbuf)); + regerror(err, GBL->regex, errbuf, sizeof(errbuf)); FATAL_ERROR("%s\n", errbuf); } } @@ -223,7 +223,7 @@ static void display_info(void) create_hosts_list(); /* don't load if the user is interested only in passwords... */ - if (!GBL.passwords) { + if (!GBL->passwords) { /* load the fingerprint database */ fingerprint_init(); @@ -235,7 +235,7 @@ static void display_info(void) } /* write the XML prolog */ - if (GBL.xml) { + if (GBL->xml) { time_t tt = time(NULL); char time[28]; /* remove the final '\n' */ @@ -254,7 +254,7 @@ static void display_info(void) continue; /* we are searching one particular user */ - if (find_user(h, GBL.user) == -ENOTFOUND) + if (find_user(h, GBL->user) == -ENOTFOUND) continue; /* if the regex was set, respect it */ @@ -262,14 +262,14 @@ static void display_info(void) continue; /* skip the host respecting the options */ - if (GBL.only_local && (h->type & FP_HOST_NONLOCAL)) + if (GBL->only_local && (h->type & FP_HOST_NONLOCAL)) continue; - if (GBL.only_remote && (h->type & FP_HOST_LOCAL)) + if (GBL->only_remote && (h->type & FP_HOST_LOCAL)) continue; /* set the color */ - if (GBL.color) { + if (GBL->color) { if (h->type & FP_GATEWAY) set_color(COL_RED); else if (h->type & FP_HOST_LOCAL) @@ -279,20 +279,20 @@ static void display_info(void) } /* print the infos */ - if (GBL.passwords) + if (GBL->passwords) print_pass(h); - else if (GBL.xml) + else if (GBL->xml) print_host_xml(h); else print_host(h); /* reset the color */ - if (GBL.color) + if (GBL->color) reset_color(); } /* close the global tag */ - if (GBL.xml) + if (GBL->xml) fprintf(stdout, "\n"); fprintf(stdout, "\n\n"); @@ -308,25 +308,25 @@ static int match_regex(struct host_profile *h) struct open_port *o; char os[OS_LEN+1]; - if (!GBL.regex) + if (!GBL->regex) return 1; /* check the manufacturer */ - if (regexec(GBL.regex, manuf_search((const char*)h->L2_addr), 0, NULL, 0) == 0) + if (regexec(GBL->regex, manuf_search((const char*)h->L2_addr), 0, NULL, 0) == 0) return 1; /* check the OS */ fingerprint_search((const char*)h->fingerprint, os); - if (regexec(GBL.regex, os, 0, NULL, 0) == 0) + if (regexec(GBL->regex, os, 0, NULL, 0) == 0) return 1; /* check the open ports banners and service */ LIST_FOREACH(o, &(h->open_ports_head), next) { - if (regexec(GBL.regex, service_search(o->L4_addr, o->L4_proto), 0, NULL, 0) == 0) + if (regexec(GBL->regex, service_search(o->L4_addr, o->L4_proto), 0, NULL, 0) == 0) return 1; - if (o->banner && regexec(GBL.regex, o->banner, 0, NULL, 0) == 0) + if (o->banner && regexec(GBL->regex, o->banner, 0, NULL, 0) == 0) return 1; } @@ -349,7 +349,7 @@ static void print_pass(struct host_profile *h) LIST_FOREACH(u, &(o->users_list_head), next) { /* skip client not matching the filter */ - if (!ip_addr_is_zero(&GBL.client) && ip_addr_cmp(&GBL.client, &u->client)) + if (!ip_addr_is_zero(&GBL->client) && ip_addr_cmp(&GBL->client, &u->client)) continue; fprintf(stdout, " %-15s ", ip_addr_ntoa(&h->L3_addr, tmp)); @@ -357,7 +357,7 @@ static void print_pass(struct host_profile *h) fprintf(stdout, "(%s)", h->hostname); /* print the client if requested */ - if (GBL.showclient) + if (GBL->showclient) fprintf(stdout, "(%s)", ip_addr_ntoa(&u->client, tmp)); fprintf(stdout, " %s %-5d %s USER: %s \tPASS: %s ", diff --git a/utils/etterlog/el_main.c b/utils/etterlog/el_main.c index 5ecef3873..d802c51a0 100644 --- a/utils/etterlog/el_main.c +++ b/utils/etterlog/el_main.c @@ -25,11 +25,10 @@ #include -/* global options */ -struct globals gbls; - -void clean_exit(int errcode); +#define GBL_FREE(x) do{ if (x != NULL) { free(x); x = NULL; } }while(0) +/* global options */ +struct globals *gbls; /*******************************************/ @@ -37,6 +36,7 @@ int main(int argc, char *argv[]) { int ret; /* etterlog copyright */ + globals_alloc(); fprintf(stdout, "\n" EC_COLOR_BOLD "%s %s" EC_COLOR_END " copyright %s %s\n\n", GBL_PROGRAM, EC_VERSION, EC_COPYRIGHT, EC_AUTHORS); @@ -53,47 +53,46 @@ int main(int argc, char *argv[]) parse_options(argc, argv); /* get the global header */ - ret = get_header(&GBL.hdr); + ret = get_header(&GBL->hdr); if (ret == -EINVALID) FATAL_ERROR("Invalid log file"); - fprintf(stderr, "Log file version : %s\n", GBL.hdr.version); + + fprintf(stderr, "Log file version : %s\n", GBL->hdr.version); /* display the date. ec_ctime() has no newline at end. */ - fprintf(stderr, "Timestamp : %s [%lu]\n", ec_ctime(&GBL.hdr.tv), GBL.hdr.tv.tv_usec); - fprintf(stderr, "Type : %s\n\n", (GBL.hdr.type == LOG_PACKET) ? "LOG_PACKET" : "LOG_INFO" ); + fprintf(stderr, "Timestamp : %s [%lu]\n", ec_ctime(&GBL->hdr.tv), GBL->hdr.tv.tv_usec); + fprintf(stderr, "Type : %s\n\n", (GBL->hdr.type == LOG_PACKET) ? "LOG_PACKET" : "LOG_INFO" ); /* analyze the logfile */ - if (GBL.analyze) + if (GBL->analyze) analyze(); /* rewind the log file and skip the global header */ gzrewind(GBL_LOG_FD); - get_header(&GBL.hdr); + get_header(&GBL->hdr); /* create the connection table (respecting the filters) */ - if (GBL.connections) + if (GBL->connections) conn_table_create(); /* display the connection table */ - if (GBL.connections && !GBL.decode) + if (GBL->connections && !GBL->decode) conn_table_display(); /* extract files from the connections */ - if (GBL.decode) + if (GBL->decode) conn_decode(); /* not interested in the content... only analysis */ - if (GBL.analyze || GBL.connections) + if (GBL->analyze || GBL->connections) return 0; /* display the content of the logfile */ display(); - return 0; -} + globals_free(); -void clean_exit(int errcode) { - exit(errcode); + return 0; } /* ANSI color escapes */ @@ -119,8 +118,29 @@ void reset_color(void) #endif } +void globals_alloc(void) +{ + + SAFE_CALLOC(gbls, 1, sizeof(struct globals)); + SAFE_CALLOC(gbls->regex, 1, sizeof(regex_t)); + SAFE_CALLOC(gbls->t, 1, sizeof(struct target_env)); -/* EOF */ + return; +} + +void globals_free(void) +{ + SAFE_FREE(gbls->user); + SAFE_FREE(gbls->logfile); + SAFE_FREE(gbls->regex); + SAFE_FREE(gbls->t); + + SAFE_FREE(gbls); + + return; + +} + // vim:ts=3:expandtab diff --git a/utils/etterlog/el_parser.c b/utils/etterlog/el_parser.c index 78e3415b0..19afa451f 100644 --- a/utils/etterlog/el_parser.c +++ b/utils/etterlog/el_parser.c @@ -146,16 +146,16 @@ void parse_options(int argc, char **argv) switch (c) { case 'a': - GBL.analyze = 1; + GBL->analyze = 1; break; case 'c': - GBL.connections = 1; + GBL->connections = 1; break; case 'D': - GBL.connections = 1; - GBL.decode = 1; + GBL->connections = 1; + GBL->decode = 1; NOT_IMPLEMENTED(); break; @@ -168,19 +168,19 @@ void parse_options(int argc, char **argv) break; case 's': - GBL.only_source = 1; + GBL->only_source = 1; break; case 'd': - GBL.only_dest = 1; + GBL->only_dest = 1; break; case 'k': - GBL.color = 1; + GBL->color = 1; break; case 'r': - GBL.reverse = 1; + GBL->reverse = 1; break; case 't': @@ -188,15 +188,15 @@ void parse_options(int argc, char **argv) break; case 'n': - GBL.no_headers = 1; + GBL->no_headers = 1; break; case 'm': - GBL.showmac = 1; + GBL->showmac = 1; break; case 'i': - GBL.showclient = 1; + GBL->showclient = 1; break; case 'I': @@ -204,23 +204,23 @@ void parse_options(int argc, char **argv) FATAL_ERROR("Invalid client ip address"); return; } - ip_addr_init(&GBL.client, AF_INET, (u_char *)&ip); + ip_addr_init(&GBL->client, AF_INET, (u_char *)&ip); break; case 'l': - GBL.only_local = 1; + GBL->only_local = 1; break; case 'L': - GBL.only_remote = 1; + GBL->only_remote = 1; break; case 'u': - GBL.user = strdup(optarg); + GBL->user = strdup(optarg); break; case 'p': - GBL.passwords = 1; + GBL->passwords = 1; break; case 'e': @@ -232,44 +232,44 @@ void parse_options(int argc, char **argv) break; case 'C': - GBL.concat = 1; + GBL->concat = 1; break; case 'B': - GBL.format = &bin_format; + GBL->format = &bin_format; break; case 'X': - GBL.format = &hex_format; + GBL->format = &hex_format; break; case 'A': - GBL.format = &ascii_format; + GBL->format = &ascii_format; break; case 'T': - GBL.format = &text_format; + GBL->format = &text_format; break; case 'E': - GBL.format = &ebcdic_format; + GBL->format = &ebcdic_format; break; case 'H': - GBL.format = &html_format; + GBL->format = &html_format; break; case 'U': set_utf8_encoding((u_char*)optarg); - GBL.format = &utf8_format; + GBL->format = &utf8_format; break; case 'Z': - GBL.format = &zero_format; + GBL->format = &zero_format; break; case 'x': - GBL.xml = 1; + GBL->xml = 1; break; case 'h': @@ -294,7 +294,7 @@ void parse_options(int argc, char **argv) } /* file concatenation */ - if (GBL.concat) { + if (GBL->concat) { if (argv[optind] == NULL) FATAL_ERROR("You MUST specify at least one logfile"); @@ -309,8 +309,8 @@ void parse_options(int argc, char **argv) FATAL_ERROR("You MUST specify a logfile\n"); /* default to ASCII view */ - if (GBL.format == NULL) - GBL.format = &ascii_format; + if (GBL->format == NULL) + GBL->format = &ascii_format; return; } diff --git a/utils/etterlog/el_target.c b/utils/etterlog/el_target.c index 81a2ab785..ac86ac9c1 100644 --- a/utils/etterlog/el_target.c +++ b/utils/etterlog/el_target.c @@ -259,7 +259,7 @@ int is_target_pck(struct log_header_packet *pck) proto = 1; /* the protocol does not match */ - if (!GBL.reverse && proto == 0) + if (!GBL->reverse && proto == 0) return 0; /* @@ -280,7 +280,7 @@ int is_target_pck(struct log_header_packet *pck) good = 1; /* check the reverse option */ - if (GBL.reverse ^ (good && proto) ) + if (GBL->reverse ^ (good && proto) ) return 1; @@ -341,7 +341,7 @@ int is_target_info(struct host_profile *hst) /* check the reverse option */ - if (GBL.reverse ^ (host && port) ) + if (GBL->reverse ^ (host && port) ) return 1; else return 0;