Skip to content

Commit

Permalink
Added patch from Erwin Paternotte,
Browse files Browse the repository at this point in the history
that fixes a lot of compile warnings. Original comments:
 - Uninitialised variables
 - Unused variables
 - Using close() instead of fclose()
 - Using a bstring as a string, rather then using bdata()
 - Useless statements
 - Return without argument, even though function must return something
 - Assuming time_t is int
 - Passing pointers to arrays instead of the array itself
  • Loading branch information
Edward Bjarte Fjellskål committed Apr 18, 2010
1 parent 86f9d84 commit 1dc4a71
Show file tree
Hide file tree
Showing 27 changed files with 3,698 additions and 2,902 deletions.
6,056 changes: 3,400 additions & 2,656 deletions configure

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions configure.in
Expand Up @@ -15,12 +15,12 @@
# vim:expandtab:smartindent:ts=4:tw=0:sw=4:

# Process this file with autoconf to produce a configure script.
AC_INIT(pads, 1.2, matt@mattshelton.com)
AC_INIT(pads, 1.2.1, edwardfjellskaal@gmail.com)
AM_CONFIG_HEADER(config.h)
AM_INIT_AUTOMAKE
AC_PROG_CC
AC_PROG_RANLIB
AC_DEFINE(PACKAGE_DATE, "06/17/05", Define the date of this release.)
AC_DEFINE(PACKAGE_DATE, "04/18/10", Define the date of this release.)

##
# Define the arguments that that we accept.
Expand Down
13 changes: 12 additions & 1 deletion src/configuration.c
Expand Up @@ -25,7 +25,18 @@
* $Id: configuration.c,v 1.3 2005/04/27 13:50:29 mattshelton Exp $
*
**************************************************************************/
/* INCLUDES ---------------------------------------- */
#include "global.h"

#include <stdio.h>
#include <unistd.h>
#include "util.h"
#include "bstring/util.h"
#include "bstring/bstrlib.h"

#include "configuration.h"
#include "monnet.h"


/* Variable Declarations */

Expand Down Expand Up @@ -59,7 +70,7 @@ void init_configuration (bstring filename) {
/* Clean Up */
bdestroy(filedata);
bstrListDestroy(lines);
close(fp);
fclose(fp);
}

/* ----------------------------------------------------------
Expand Down
17 changes: 0 additions & 17 deletions src/configuration.h
Expand Up @@ -27,23 +27,6 @@
*
**************************************************************************/

/* DEFINES ----------------------------------------- */
#ifdef LINUX
#ifndef __FAVOR_BSD
#define __FAVOR_BSD
#endif
#ifndef _BSD_SOURCE
#define _BSD_SOURCE
#endif
#endif /* ifdef LINUX */


/* INCLUDES ---------------------------------------- */
#include "global.h"

#include <stdio.h>
#include "bstring/bstrlib.h"

/* PROTOTYPES -------------------------------------- */
void init_configuration (bstring conf_file);
void parse_line (bstring line);
Expand Down
13 changes: 13 additions & 0 deletions src/global.h
Expand Up @@ -25,11 +25,23 @@
* $Id: global.h,v 1.7 2005/04/27 13:45:47 mattshelton Exp $
*
**************************************************************************/
#ifndef INCLUDED_GLOBAL_H
#define INCLUDED_GLOBAL_H

#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

/* DEFINES ------------------------------------------ */
#ifdef LINUX
#ifndef __FAVOR_BSD
#define __FAVOR_BSD
#endif
#ifndef _BSD_SOURCE
#define _BSD_SOURCE
#endif
#endif /* ifdef LINUX */

#define MAX_LENGTH 500
#define MAX_SERVICE 10
#define MAX_APP 100
Expand Down Expand Up @@ -161,5 +173,6 @@ typedef struct _Vendor {
/* GLOBAL VARIABLES -------------------------------- */
extern GC gc;

#endif /* INCLUDED_GLOBAL_H */
/* vim:expandtab:cindent:smartindent:ts=4:tw=0:sw=4:
*/
26 changes: 20 additions & 6 deletions src/identification.c
Expand Up @@ -25,7 +25,22 @@
* $Id: identification.c,v 1.5 2005/05/14 20:14:34 mattshelton Exp $
*
**************************************************************************/

/* INCLUDES ---------------------------------------- */
#include "global.h"

#include <stdio.h>
#include <signal.h>

#include <netinet/ip.h>
#include <netinet/tcp.h>
#include <string.h>
#include <unistd.h>

#include "identification.h"
#include "util.h"
#include "storage.h"
#include "output/output.h"

Signature *signature_list;

Expand Down Expand Up @@ -73,7 +88,7 @@ int init_identification()
bdestroy(filename);
bdestroy(filedata);
bstrListDestroy(lines);
close(fp);
fclose(fp);

return 0;
}
Expand All @@ -91,17 +106,17 @@ int init_identification()
int parse_raw_signature (bstring line, int lineno)
{
struct bstrList *raw_sig;
struct bstrList *title;
struct bstrList *title = NULL;
Signature *sig;
bstring pcre_string;
bstring pcre_string = NULL;
const char *err; /* PCRE */
int erroffset; /* PCRE */
int ret = 0;
int i;

/* Check to see if this line has something to read. */
if (line->data[0] == '\0' || line->data[0] == '#')
return;
return -1;

/* Split Line */
if ((raw_sig = bsplit(line, ',')) == NULL)
Expand Down Expand Up @@ -270,7 +285,6 @@ int pcre_identify (struct in_addr ip_addr,
Signature *list = signature_list;
int rc;
int ovector[15];
int i;
bstring app;

while (list != NULL) {
Expand Down Expand Up @@ -421,7 +435,7 @@ void print_signature()
printf("2a: %s\n", bdata(list->title.app));
printf("2b: %s\n", bdata(list->title.ver));
printf("2c: %s\n", bdata(list->title.misc));
printf("3: %s\n", list->regex);
printf("3: %s\n", (char *)list->regex);
printf("\n");

i++;
Expand Down
10 changes: 0 additions & 10 deletions src/identification.h
Expand Up @@ -26,16 +26,6 @@
*
**************************************************************************/

/* INCLUDES ---------------------------------------- */
#include <stdio.h>
#include <signal.h>

#include "global.h"

#include <netinet/ip.h>
#include <netinet/tcp.h>


/* PROTOTYPES -------------------------------------- */
int init_identification(void);
int parse_raw_signature (bstring line, int lineno);
Expand Down
10 changes: 7 additions & 3 deletions src/mac-resolution.c
Expand Up @@ -31,7 +31,13 @@
**************************************************************************/
#ifndef DISABLE_VENDOR

/* INCLUDES ---------------------------------------- */
#include "global.h"

#include <stdio.h>
#include <unistd.h>
#include "mac-resolution.h"
#include "util.h"

Vendor *vendor_list = NULL;

Expand Down Expand Up @@ -79,7 +85,7 @@ int init_mac_resolution (void) {
bdestroy(filedata);
if (lines != NULL)
bstrListDestroy(lines);
close(fp);
fclose(fp);

return 0;
}
Expand All @@ -99,8 +105,6 @@ int parse_raw_mac (bstring line)
char vendor[80];
int m1, m2, m3;

int pos;

/* Parse out the contents of the line. */
if (sscanf(bdata(line), "%02X:%02X:%02X %80[^,\n],\n", &m1, &m2, &m3, vendor) != 4)
return -1;
Expand Down
5 changes: 1 addition & 4 deletions src/mac-resolution.h
Expand Up @@ -32,10 +32,7 @@

/* DEFINES ----------------------------------------- */

/* INCLUDES ---------------------------------------- */
#include <stdio.h>
#include "global.h"

#include <bstring/bstrlib.h>

/* PROTOTYPES -------------------------------------- */
int init_mac_resolution (void);
Expand Down
13 changes: 11 additions & 2 deletions src/monnet.c
Expand Up @@ -27,7 +27,17 @@
* $Id: monnet.c,v 1.3 2005/02/17 16:29:14 mattshelton Exp $
*
**************************************************************************/
/* INCLUDES ---------------------------------------- */
#include "global.h"

#include <stdio.h>
#include <sys/types.h>
#include <netinet/in.h>
#include <stdlib.h>
#include <arpa/inet.h>

#include "monnet.h"
#include "util.h"

struct mon_net *mn;

Expand All @@ -45,7 +55,6 @@ void parse_networks (char *cmdline)
{
int i = 0;
char network[16], netmask[3], tmp[16];
struct in_addr in_net;

/* Make sure something was defined. */
if (cmdline == NULL)
Expand Down Expand Up @@ -81,7 +90,7 @@ void parse_networks (char *cmdline)
i++;
}

*cmdline++;
cmdline++;
}
}

Expand Down
5 changes: 0 additions & 5 deletions src/monnet.h
Expand Up @@ -25,11 +25,6 @@
*
**************************************************************************/

/* INCLUDES ---------------------------------------- */
#include <stdio.h>
#include <sys/types.h>
#include <netinet/in.h>


/* DATA STRUCTURES --------------------------------- */
struct mon_net {
Expand Down
27 changes: 18 additions & 9 deletions src/output/output-csv.c
Expand Up @@ -24,8 +24,16 @@
* $Id: output-csv.c,v 1.6 2005/02/22 16:09:25 mattshelton Exp $
*
**************************************************************************/
#include "output-csv.h"

/* INCLUDES ---------------------------------------- */
#include "global.h"

#include <stdio.h>
#include <arpa/inet.h>

#include "output.h"
#include "output-csv.h"
#include "util.h"

OutputCSVConf output_csv_conf;

Expand All @@ -41,7 +49,6 @@ int
setup_output_csv (void)
{
OutputPlugin *plugin;
bstring name;

/* Allocate and setup plugin data record. */
plugin = (OutputPlugin*)malloc(sizeof(OutputPlugin));
Expand Down Expand Up @@ -107,7 +114,7 @@ init_output_csv (bstring filename)
}
}

return;
return 0;
}

/* ----------------------------------------------------------
Expand Down Expand Up @@ -145,7 +152,7 @@ read_report_file (void)
/* Clean Up */
bdestroy(filedata);
bstrListDestroy(lines);
close(fp);
fclose(fp);
}

/* ----------------------------------------------------------
Expand Down Expand Up @@ -173,7 +180,7 @@ parse_raw_report (bstring line)

/* Check to see if this line has something to read. */
if (line->data[0] == '\0' || line->data[0] == '#')
return;
return -1;

/* Break line apart. */
if ((list = bsplit(line, ',')) == NULL)
Expand Down Expand Up @@ -216,7 +223,7 @@ parse_raw_report (bstring line)
add_arp_asset(ip_addr, mac_addr, discovered);
} else {
/* Everything Else */
add_asset(ip_addr, port, proto, service, application, discovered);
add_asset_csv(ip_addr, port, proto, service, application, discovered);
}

// Clean Up
Expand Down Expand Up @@ -251,7 +258,7 @@ print_asset_csv (Asset *rec)
(biseqcstr(rec->application, "unknown") != 0))) {
fprintf(output_csv_conf.file, "%s,%d,%d,%s,%s,%d\n",
inet_ntoa(rec->ip_addr), ntohs(rec->port), rec->proto, bdata(rec->service),
bdata(rec->application), rec->discovered);
bdata(rec->application), (int)rec->discovered);
fflush(output_csv_conf.file);
}
} else {
Expand Down Expand Up @@ -279,10 +286,10 @@ print_arp_asset_csv (ArpAsset *rec)
if (output_csv_conf.file != NULL) {
if (rec->mac_resolved != NULL) {
fprintf(output_csv_conf.file, "%s,0,0,ARP (%s),%s,%d\n", inet_ntoa(rec->ip_addr),
bdata(rec->mac_resolved), hex2mac(rec->mac_addr), rec->discovered);
bdata(rec->mac_resolved), hex2mac(rec->mac_addr), (int)rec->discovered);
} else {
fprintf(output_csv_conf.file, "%s,0,0,ARP,%s,%d\n", inet_ntoa(rec->ip_addr),
hex2mac(rec->mac_addr), rec->discovered);
hex2mac(rec->mac_addr), (int)rec->discovered);
}

fflush(output_csv_conf.file);
Expand Down Expand Up @@ -312,5 +319,7 @@ end_output_csv ()

if (output_csv_conf.filename != NULL)
bdestroy(output_csv_conf.filename);

return 0;
}

17 changes: 0 additions & 17 deletions src/output/output-csv.h
Expand Up @@ -26,22 +26,6 @@
*
**************************************************************************/

/* DEFINES ----------------------------------------- */
#ifdef LINUX
#ifndef __FAVOR_BSD
#define __FAVOR_BSD
#endif
#ifndef _BSD_SOURCE
#define _BSD_SOURCE
#endif
#endif /* ifdef LINUX */


/* INCLUDES ---------------------------------------- */
#include <stdio.h>

#include "output.h"


/* TYPEDEFS ---------------------------------------- */
typedef struct _OutputCSVConf
Expand All @@ -63,4 +47,3 @@ int parse_raw_report (bstring line);
int print_asset_csv (Asset *rec);
int print_arp_asset_csv (ArpAsset *rec);
int end_output_csv (void);

0 comments on commit 1dc4a71

Please sign in to comment.