From 6a81215bb2c5f254a0b74d113c131eab6d3bdcf4 Mon Sep 17 00:00:00 2001 From: Daniel Borkmann Date: Wed, 28 Nov 2012 14:52:31 +0100 Subject: [PATCH] curvetun: shut up GCC! Signed-off-by: Daniel Borkmann --- TODO | 2 +- src/Makefile | 2 +- src/ct_client.c | 11 ++++------- src/ct_server.c | 3 +-- src/curvetun.c | 7 ++++--- 5 files changed, 11 insertions(+), 14 deletions(-) diff --git a/TODO b/TODO index e03ce74..c35c802 100644 --- a/TODO +++ b/TODO @@ -67,7 +67,7 @@ submit your contributions, items marked with '!' are of high importance): 38! netsniff-ng (and others): if interface goes down, properly exit @TODO: Daniel Borkmann -39! Add a pcap indexing utility fo a faster retrival, analysis on huge +39) Add a pcap indexing utility fo a faster retrival, analysis on huge pcap files. Write the index file out for each pcap capture. @TODO: Daniel Borkmann, Francesco Fusco diff --git a/src/Makefile b/src/Makefile index 368a904..443cb44 100644 --- a/src/Makefile +++ b/src/Makefile @@ -43,7 +43,7 @@ CFLAGS += -D_REENTRANT CFLAGS += -D_FILE_OFFSET_BITS=64 CFLAGS += -D_LARGEFILE_SOURCE CFLAGS += -D_LARGEFILE64_SOURCE -#CFLAGS += -D__WITH_HARDWARE_TIMESTAMPING +CFLAGS += -D__WITH_HARDWARE_TIMESTAMPING=1 CFLAGS += -DVERSION_STRING=\"$(VERSION_STRING)\" CFLAGS += -std=gnu99 CFLAGS += -march=native diff --git a/src/ct_client.c b/src/ct_client.c index 2104b1d..fb80132 100644 --- a/src/ct_client.c +++ b/src/ct_client.c @@ -89,7 +89,7 @@ static void handler_udp_net_to_tun(int sfd, int dfd, struct curve25519_proto *p, size_t len) { char *cbuff; - ssize_t rlen, err, clen; + ssize_t rlen, clen; struct ct_proto *hdr; struct sockaddr_storage naddr; @@ -122,7 +122,7 @@ static void handler_udp_net_to_tun(int sfd, int dfd, struct curve25519_proto *p, cbuff += crypto_box_zerobytes; clen -= crypto_box_zerobytes; - err = write(dfd, cbuff, clen); + if (write(dfd, cbuff, clen)); } return; @@ -180,7 +180,7 @@ static void handler_tcp_net_to_tun(int sfd, int dfd, struct curve25519_proto *p, size_t len) { char *cbuff; - ssize_t rlen, err, clen; + ssize_t rlen, clen; struct ct_proto *hdr; if (!buff || !len) @@ -208,7 +208,7 @@ static void handler_tcp_net_to_tun(int sfd, int dfd, struct curve25519_proto *p, cbuff += crypto_box_zerobytes; clen -= crypto_box_zerobytes; - err = write(dfd, cbuff, clen); + if (write(dfd, cbuff, clen)); } return; @@ -304,7 +304,6 @@ int client_main(char *home, char *dev, char *host, char *port, int udp) int fd = -1, tunfd = 0, retry_server = 0; int ret, try = 1, i; struct addrinfo hints, *ahead, *ai; - struct sockaddr_in6 *saddr6; struct pollfd fds[2]; struct curve25519_proto *p; struct curve25519_struct *c; @@ -346,8 +345,6 @@ retry: } for (ai = ahead; ai != NULL && fd < 0; ai = ai->ai_next) { - if (ai->ai_family == PF_INET6) - saddr6 = (struct sockaddr_in6 *) ai->ai_addr; fd = socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol); if (fd < 0) continue; diff --git a/src/ct_server.c b/src/ct_server.c index 575ebb0..3b1a115 100644 --- a/src/ct_server.c +++ b/src/ct_server.c @@ -335,14 +335,13 @@ ssize_t handler_tcp_read(int fd, char *buff, size_t len) static void handler_tcp_notify_close(int fd) { - ssize_t err; struct ct_proto hdr; memset(&hdr, 0, sizeof(hdr)); hdr.flags |= PROTO_FLAG_EXIT; hdr.payload = 0; - err = write(fd, &hdr, sizeof(hdr)); + if (write(fd, &hdr, sizeof(hdr))); } static int handler_tcp_net_to_tun(int fd, const struct worker_struct *ws, diff --git a/src/curvetun.c b/src/curvetun.c index 806785a..73dc17e 100644 --- a/src/curvetun.c +++ b/src/curvetun.c @@ -218,7 +218,7 @@ static char *fetch_home_dir(void) static void write_username(char *home) { int fd, ret; - char path[PATH_MAX], *eof; + char path[PATH_MAX]; char user[512]; memset(path, 0, sizeof(path)); @@ -228,7 +228,8 @@ static void write_username(char *home) fflush(stdout); memset(user, 0, sizeof(user)); - eof = fgets(user, sizeof(user), stdin); + if (fgets(user, sizeof(user), stdin) == NULL) + panic("Could not read from stdin!\n"); user[sizeof(user) - 1] = 0; user[strlen(user) - 1] = 0; /* omit last \n */ if (strlen(user) == 0) @@ -589,7 +590,7 @@ int main(int argc, char **argv) enum working_mode wmode = MODE_UNKNOW; if (getuid() != geteuid()) - seteuid(getuid()); + if (seteuid(getuid())); home = fetch_home_dir(); -- 2.11.4.GIT