Skip to content

Commit

Permalink
Fixes for many compiler warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
Dan Petro committed Jul 19, 2012
1 parent 913118f commit c841645
Show file tree
Hide file tree
Showing 18 changed files with 61 additions and 164 deletions.
3 changes: 2 additions & 1 deletion Makefile.am
Expand Up @@ -130,7 +130,8 @@ CFLAGS = -O2 -Wall -g \
-DPATH_HONEYDLIB="\"$(honeydlibdir)\"" \
-DHONEYD_PLUGINS_DECLARE="$(honeydpluginsdeclare)" \
-DHONEYD_PLUGINS="$(honeydplugins)" \
-DPATH_RRDTOOL="\"$(PATH_RRDTOOL)\""
-DPATH_RRDTOOL="\"$(PATH_RRDTOOL)\"" \
-D_GNU_SOURCE

INCLUDES = -I$(top_srcdir)/@DNETCOMPAT@ -I$(top_srcdir)/compat \
@PYTHONINC@ @EVENTINC@ @PCAPINC@ @DNETINC@ @ZINC@
Expand Down
3 changes: 1 addition & 2 deletions command.c
Expand Up @@ -47,7 +47,6 @@
#include <errno.h>
#include <fcntl.h>
#include <signal.h>
#define _GNU_SOURCE
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
Expand Down Expand Up @@ -320,7 +319,7 @@ cmd_droppriv(uid_t uid, gid_t gid)

return;
error:
syslog(LOG_WARNING, error);
syslog(LOG_WARNING, error, "");
errx(1, "%s: terminated", __func__);
}

Expand Down
4 changes: 2 additions & 2 deletions config.c
Expand Up @@ -930,7 +930,7 @@ template_print(struct evbuffer *buffer, struct template *tmpl)
evbuffer_add_printf(buffer, " ethernet address: %s\n",
addr_ntoa(tmpl->ethernet_addr));
evbuffer_add_printf(buffer, " IP id: %u\n", tmpl->ipid);
evbuffer_add_printf(buffer, " TCP seq: %lx\n", tmpl->seq);
evbuffer_add_printf(buffer, " TCP seq: %x\n", tmpl->seq);
evbuffer_add_printf(buffer, " TCP drop: in: %d syn: %d\n",
tmpl->drop_inrate, tmpl->drop_synrate);
evbuffer_add_printf(buffer, " refcnt: %d\n", tmpl->refcnt);
Expand Down Expand Up @@ -1019,7 +1019,7 @@ template_delay_cb(int fd, short which, void *arg)
void
template_test_parse_error(char *line, struct evbuffer *evbuf)
{
char *p = EVBUFFER_DATA(evbuf);
char *p = (char*)EVBUFFER_DATA(evbuf);
size_t off = EVBUFFER_LENGTH(evbuf);
p[off - 1] = '\0';
errx(1, "parse_line \"%s\" failed: %s", line, p);
Expand Down
4 changes: 2 additions & 2 deletions fdpass.c
Expand Up @@ -63,7 +63,7 @@ send_fd(int socket, int fd, void *base, size_t len)
cmsg->cmsg_len = CMSG_LEN(sizeof(int));
cmsg->cmsg_level = SOL_SOCKET;
cmsg->cmsg_type = SCM_RIGHTS;
*(int *)CMSG_DATA(cmsg) = fd;
memcpy(CMSG_DATA(cmsg), &fd, sizeof(fd));
#endif

if (base == NULL) {
Expand Down Expand Up @@ -145,7 +145,7 @@ receive_fd(int socket, void *base, size_t *len)
if (cmsg->cmsg_type != SCM_RIGHTS)
errx(1, "%s: expected type %d got %d", __func__,
SCM_RIGHTS, cmsg->cmsg_type);
fd = (*(int *)CMSG_DATA(cmsg));
memcpy(&fd, CMSG_DATA(cmsg), sizeof(fd));
#endif
return fd;
#else
Expand Down
11 changes: 8 additions & 3 deletions honeyd.c
Expand Up @@ -3194,7 +3194,7 @@ honeyd_signal(int fd, short what, void *arg)
if ((fp = fopen(templateDump , "w+")) == NULL)
warn("Error opening the DHCP IP address dump file");
else
close(fp);
fclose(fp);
}

honeyd_exit(0);
Expand Down Expand Up @@ -3271,7 +3271,12 @@ main(int argc, char *argv[])
int i, c, orig_argc, ninterfaces = 0;
FILE *fp;

chdir(PATH_HONEYDDATA);
if(chdir(PATH_HONEYDDATA) == -1)
{
printf("ERROR: Could not find path PATH_HONEYDDATA: %s\n", PATH_HONEYDDATA);
perror("");
exit(EXIT_FAILURE);
}

fprintf(stderr, "Honeyd V%s Copyright (c) 2002-2007 Niels Provos\n",
VERSION);
Expand Down Expand Up @@ -3604,7 +3609,7 @@ main(int argc, char *argv[])
if ((fp = fopen(templateDump , "w+")) == NULL)
warn("Error opening the DHCP IP address dump file");
else
close(fp);
fclose(fp);
}

/*
Expand Down
24 changes: 20 additions & 4 deletions honeydctl.c
Expand Up @@ -154,7 +154,10 @@ receive(int fd, int display)
last = prompt;
if (last) {
last++;
write(1, Buffer, last-Buffer);
if(write(1, Buffer, last-Buffer) == -1)
{
errx(EXIT_FAILURE, "Failed to write to file descriptor");
}
}
}
prompt = prompt == NULL ? Buffer : prompt+1;
Expand All @@ -174,7 +177,10 @@ receive(int fd, int display)
flush = sizeof (Buffer) / 2;
else
flush = last - Buffer + 1;
write(1, Buffer, flush);
if(write(1, Buffer, flush) == -1)
{
errx(EXIT_FAILURE, "Failed to write to file descriptor");
}
strlcpy(Buffer, Buffer + flush, sizeof(Buffer));
len -= flush;
}
Expand All @@ -201,7 +207,12 @@ check_fd(int sig)
if (select(data+1, &f, NULL, NULL, &t) > 0) {
len = read(data, buf, sizeof (buf));
if (len > 0)
write(fileno(stdout), buf, len);
{
if(write(fileno(stdout), buf, len))
{
errx(EXIT_FAILURE, "Failed to write to file descriptor");
}
}
else
longjmp(pppdead, -1);
}
Expand Down Expand Up @@ -263,6 +274,8 @@ main(int argc, char **argv)

case 'v':
verbose = REC_VERBOSE;
//TODO: Dirty kludge to suppress warning. Fix this unused variable
verbose = verbose;
break;
default:
usage();
Expand Down Expand Up @@ -358,7 +371,10 @@ main(int argc, char **argv)
len++;
}
#endif
write(fd, l, len);
if(write(fd, l, len) == -1)
{
errx(EXIT_FAILURE, "Failed to write to file descriptor");
}
if (receive(fd, REC_SHOW) != 0)
break;
}
Expand Down
3 changes: 2 additions & 1 deletion hsniff.c
Expand Up @@ -62,6 +62,7 @@
#include <time.h>
#endif
#include <unistd.h>
#include <grp.h>
#include <getopt.h>
#include <dnet.h>

Expand Down Expand Up @@ -809,6 +810,6 @@ droppriv(uid_t uid, gid_t gid)

return;
error:
syslog(LOG_WARNING, error);
syslog(LOG_WARNING, error, "");
errx(1, "%s: terminated", __func__);
}
123 changes: 0 additions & 123 deletions lex.c
Expand Up @@ -806,8 +806,6 @@ extern "C" int hydwrap (void );
extern int hydwrap (void );
#endif
#endif

static void yyunput (int c,char *buf_ptr );

#ifndef yytext_ptr
static void yy_flex_strncpy (char *,yyconst char *,int );
Expand All @@ -817,16 +815,6 @@ static void yy_flex_strncpy (char *,yyconst char *,int );
static int yy_flex_strlen (yyconst char * );
#endif

#ifndef YY_NO_INPUT

#ifdef __cplusplus
static int yyinput (void );
#else
static int input (void );
#endif

#endif

/* Amount of stuff to slurp up with each read. */
#ifndef YY_READ_BUF_SIZE
#ifdef __ia64__
Expand Down Expand Up @@ -1825,117 +1813,6 @@ static int yy_get_next_buffer (void)
return yy_is_jam ? 0 : yy_current_state;
}

static void yyunput (int c, register char * yy_bp )
{
register char *yy_cp;

yy_cp = (yy_c_buf_p);

/* undo effects of setting up hydtext */
*yy_cp = (yy_hold_char);

if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 )
{ /* need to shift things up to make room */
/* +2 for EOB chars. */
register int number_to_move = (yy_n_chars) + 2;
register char *dest = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[
YY_CURRENT_BUFFER_LVALUE->yy_buf_size + 2];
register char *source =
&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move];

while ( source > YY_CURRENT_BUFFER_LVALUE->yy_ch_buf )
*--dest = *--source;

yy_cp += (int) (dest - source);
yy_bp += (int) (dest - source);
YY_CURRENT_BUFFER_LVALUE->yy_n_chars =
(yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_buf_size;

if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 )
YY_FATAL_ERROR( "flex scanner push-back overflow" );
}

*--yy_cp = (char) c;

(yytext_ptr) = yy_bp;
(yy_hold_char) = *yy_cp;
(yy_c_buf_p) = yy_cp;
}

#ifndef YY_NO_INPUT
#ifdef __cplusplus
static int yyinput (void)
#else
static int input (void)
#endif

{
int c;

*(yy_c_buf_p) = (yy_hold_char);

if ( *(yy_c_buf_p) == YY_END_OF_BUFFER_CHAR )
{
/* yy_c_buf_p now points to the character we want to return.
* If this occurs *before* the EOB characters, then it's a
* valid NUL; if not, then we've hit the end of the buffer.
*/
if ( (yy_c_buf_p) < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] )
/* This was really a NUL. */
*(yy_c_buf_p) = '\0';

else
{ /* need more input */
int offset = (yy_c_buf_p) - (yytext_ptr);
++(yy_c_buf_p);

switch ( yy_get_next_buffer( ) )
{
case EOB_ACT_LAST_MATCH:
/* This happens because yy_g_n_b()
* sees that we've accumulated a
* token and flags that we need to
* try matching the token before
* proceeding. But for input(),
* there's no matching to consider.
* So convert the EOB_ACT_LAST_MATCH
* to EOB_ACT_END_OF_FILE.
*/

/* Reset buffer status. */
hydrestart(hydin );

/*FALLTHROUGH*/

case EOB_ACT_END_OF_FILE:
{
if ( hydwrap( ) )
return EOF;

if ( ! (yy_did_buffer_switch_on_eof) )
YY_NEW_FILE;
#ifdef __cplusplus
return yyinput();
#else
return input();
#endif
}

case EOB_ACT_CONTINUE_SCAN:
(yy_c_buf_p) = (yytext_ptr) + offset;
break;
}
}
}

c = *(unsigned char *) (yy_c_buf_p); /* cast for 8-bit char's */
*(yy_c_buf_p) = '\0'; /* preserve hydtext */
(yy_hold_char) = *++(yy_c_buf_p);

return c;
}
#endif /* ifndef YY_NO_INPUT */

/** Immediately switch to a different input stream.
* @param input_file A readable stream.
*
Expand Down
2 changes: 0 additions & 2 deletions parse.c
Expand Up @@ -80,8 +80,6 @@
#include <sys/tree.h>
#include <sys/queue.h>

#define _XOPEN_SOURCE /* glibc2 is stupid and needs this */
#define _GNU_SOURCE
#include <stdio.h>
#include <stdlib.h>
#include <err.h>
Expand Down
2 changes: 0 additions & 2 deletions parse.y
Expand Up @@ -40,8 +40,6 @@
#include <sys/tree.h>
#include <sys/queue.h>

#define _XOPEN_SOURCE /* glibc2 is stupid and needs this */
#define _GNU_SOURCE
#include <stdio.h>
#include <stdlib.h>
#include <err.h>
Expand Down
7 changes: 3 additions & 4 deletions personality.c
Expand Up @@ -665,7 +665,6 @@ tcp_personality_seq(struct tcp_con * con, struct template *tmpl, struct personal
{
struct timeval tmp;
extern rand_t *honeyd_rand;
int slowhz;

tmpl->seqcalls++;

Expand All @@ -681,7 +680,7 @@ tcp_personality_seq(struct tcp_con * con, struct template *tmpl, struct personal
}
}

slowhz = tcp_personality_time(tmpl, &tmp);
tcp_personality_time(tmpl, &tmp);

/*
* This is where new ISNs are generated. The latest ISN is
Expand Down Expand Up @@ -852,7 +851,7 @@ tcp_personality_options(struct tcp_con *con, struct tcp_hdr *tcp,
case 'T':
if (tmpl != NULL)
{
struct timeval tv;
//struct timeval tv;
//tcp_personality_time(tmpl, &tv);
//gettimeofday(&tv, NULL);
//timestamp = tv.tv_sec;
Expand Down Expand Up @@ -2622,7 +2621,7 @@ get_fprint(FILE * fp_in)

/* !!!DEBUG FUNCTION!!! */

static void
static void __attribute__ ((unused))
print_xprobe_struct(struct xp_fingerprint *pers)
{
printf ("OS_ID: %s\n", pers->os_id);
Expand Down
2 changes: 2 additions & 0 deletions personality.h
Expand Up @@ -268,6 +268,8 @@ struct personality *personality_random(void);
void personality_free(struct personality *);

void ip_personality(struct template *, uint16_t *, enum ipid_protocol proto);
struct personate * tcp_personality_test(const struct tcp_con *con, struct personality *person,
uint8_t sndflags);
int tcp_personality(struct tcp_con *con, uint8_t *pflags, int *pwindow, int *pdf,
uint16_t *pid, struct tcp_options *poptions);
void tcp_personality_options(struct tcp_con *con, struct tcp_hdr *tcp, struct tcp_options *options);
Expand Down
2 changes: 1 addition & 1 deletion pf_osfp.c
Expand Up @@ -85,7 +85,7 @@ pf_osfp_fingerprint_hdr(const struct ip_hdr *ip, const struct tcp_hdr *tcp)


cnt = (tcp->th_off << 2) - sizeof(*tcp);
optp = (caddr_t)tcp + sizeof(*tcp);
optp = (void*)tcp + sizeof(*tcp);
for (; cnt > 0; cnt -= optlen, optp += optlen) {
if (*optp == TCP_OPT_EOL)
break;
Expand Down
4 changes: 2 additions & 2 deletions rrdtool.c
Expand Up @@ -77,8 +77,8 @@ rrdtool_evb_readcb(struct bufferevent *bev, void *parameter)

char *start, *end;

start = EVBUFFER_DATA(bev->input);
if ((end = evbuffer_find(bev->input, "OK ", 3)) == NULL)
start = (char*)EVBUFFER_DATA(bev->input);
if ((end = (char*)evbuffer_find(bev->input, (unsigned char*)"OK ", 3)) == NULL)
return;

/* Find the end of the line */
Expand Down

0 comments on commit c841645

Please sign in to comment.