From 76f3169ec47f76c62fdd2f7c3b66371f67da7df3 Mon Sep 17 00:00:00 2001 From: Petter Reinholdtsen Date: Sun, 13 Oct 2013 09:01:05 +0200 Subject: [PATCH 01/51] Enable more warnings and use the flags from dpkg-buildflags to enhance security. --- Makefile.in | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Makefile.in b/Makefile.in index 87fb9452..5b939b15 100644 --- a/Makefile.in +++ b/Makefile.in @@ -70,6 +70,12 @@ CFLAGS+=-DSHA2_USE_INTTYPES_H -D_XOPEN_SOURCE=600 -D_XOPEN_SOURCE_EXTENDED=1 -D_ CFLAGS+=-D_DARWIN_C_SOURCE -include Makefile.dbg +# More warnings, discover problems that only happen on some archs +CFLAGS+=-Wextra +# Security enhancements from Debian +CFLAGS+=-fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2 +LDFLAGS+=-Wl,-z,relro + DEFS= @DEFS@ .PHONY: all test clean From b401af895c442227c780193e67fc9738d0743ef9 Mon Sep 17 00:00:00 2001 From: Petter Reinholdtsen Date: Sun, 13 Oct 2013 09:01:35 +0200 Subject: [PATCH 02/51] Make sure to check argc before use argv. --- fakeradio.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fakeradio.c b/fakeradio.c index b310fbe3..b1057e23 100644 --- a/fakeradio.c +++ b/fakeradio.c @@ -366,9 +366,9 @@ int transfer_bytes(struct radio_state *radios) int main(int argc,char **argv) { - if (argv[1]) { + if (1 < argc) { chars_per_ms=atol(argv[1]); - if (argv[2]) + if (2 < argc) ber=atol(argv[2]); } fprintf(stderr, "Sending %d bytes per ms\n", chars_per_ms); From 6564449f49ac819ac5f5b74679f2076add6efe94 Mon Sep 17 00:00:00 2001 From: Petter Reinholdtsen Date: Sun, 13 Oct 2013 09:01:53 +0200 Subject: [PATCH 03/51] Initialize some struct members reported by the compiler. --- commandline.c | 2 +- serval.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/commandline.c b/commandline.c index 74ed1da3..1230ae01 100644 --- a/commandline.c +++ b/commandline.c @@ -2642,5 +2642,5 @@ struct cli_schema command_line_options[]={ {app_pa_phone,{"phone",NULL}, 0, "Run phone test application"}, #endif - {NULL,{NULL}} + {NULL,{NULL},0,NULL} }; diff --git a/serval.h b/serval.h index 3dc44809..96284911 100644 --- a/serval.h +++ b/serval.h @@ -862,8 +862,8 @@ int fd_func_enter(struct __sourceloc, struct call_stats *this_call); int fd_func_exit(struct __sourceloc, struct call_stats *this_call); void dump_stack(int log_level); -#define IN() static struct profile_total _aggregate_stats={NULL,0,__FUNCTION__,0,0,0}; \ - struct call_stats _this_call={.totals=&_aggregate_stats}; \ +#define IN() static struct profile_total _aggregate_stats={NULL,0,__FUNCTION__,0,0,0,0}; \ + struct call_stats _this_call={.totals=&_aggregate_stats,.enter_time=0,.child_time=0,.prev=NULL}; \ fd_func_enter(__HERE__, &_this_call); #define OUT() fd_func_exit(__HERE__, &_this_call) From 2c3c7527d395be13c577c1251367f2fc4ab71263 Mon Sep 17 00:00:00 2001 From: Petter Reinholdtsen Date: Sun, 13 Oct 2013 09:49:25 +0200 Subject: [PATCH 04/51] Initialize a few more uninitialized values. --- dna_helper.c | 4 ++-- fdqueue.c | 2 +- overlay_mdp.c | 5 +++-- overlay_olsr.c | 3 +-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/dna_helper.c b/dna_helper.c index d1d18b42..a2962978 100644 --- a/dna_helper.c +++ b/dna_helper.c @@ -87,8 +87,8 @@ static int dna_helper_started = 0; #define DECLARE_SCHED_ENT(FUNCTION, VARIABLE) \ static void FUNCTION(struct sched_ent *alarm); \ -static struct profile_total VARIABLE##_timing={.name="" #FUNCTION "",}; \ -static struct sched_ent VARIABLE = {.function = FUNCTION, .stats = & VARIABLE##_timing, .poll.fd = -1, }; +static struct profile_total VARIABLE##_timing={.name="" #FUNCTION "",._next=NULL,._initialised=0,.max_time=0,.total_time=0,.child_time=0,.calls=0}; \ +static struct sched_ent VARIABLE = {.function = FUNCTION, .stats = & VARIABLE##_timing, .poll={.fd=-1, .events=0,.revents=0}}; DECLARE_SCHED_ENT(monitor_requests, sched_requests); DECLARE_SCHED_ENT(monitor_replies, sched_replies); diff --git a/fdqueue.c b/fdqueue.c index 1ef8aea4..8f8a002b 100644 --- a/fdqueue.c +++ b/fdqueue.c @@ -30,7 +30,7 @@ int fdcount=0; struct sched_ent *fd_callbacks[MAX_WATCHED_FDS]; struct sched_ent *next_alarm=NULL; struct sched_ent *next_deadline=NULL; -struct profile_total poll_stats={NULL,0,"Idle (in poll)",0,0,0}; +struct profile_total poll_stats={NULL,0,"Idle (in poll)",0,0,0,0}; #define alloca_alarm_name(alarm) ((alarm)->stats ? alloca_str_toprint((alarm)->stats->name) : "Unnamed") diff --git a/overlay_mdp.c b/overlay_mdp.c index d18800b1..18cdbf27 100644 --- a/overlay_mdp.c +++ b/overlay_mdp.c @@ -37,14 +37,14 @@ static struct profile_total mdp_stats = { .name="overlay_mdp_poll" }; static struct sched_ent mdp_sock = { .function = overlay_mdp_poll, .stats = &mdp_stats, - .poll.fd = -1, + .poll={.fd = -1,.events=0,.revents=0}, }; static struct profile_total mdp_stats2 = { .name="mdp_poll2" }; static struct sched_ent mdp_sock2 = { .function = mdp_poll2, .stats = &mdp_stats2, - .poll.fd = -1, + .poll={.fd = -1,.events=0,.revents=0}, }; static int overlay_saw_mdp_frame(struct overlay_frame *frame, overlay_mdp_frame *mdp, time_ms_t now); @@ -893,6 +893,7 @@ static void overlay_mdp_scan(struct sched_ent *alarm) struct sockaddr_in addr={ .sin_family=AF_INET, .sin_port=htons(PORT_DNA), + .sin_addr={0}, }; struct scan_state *state = (struct scan_state *)alarm; uint32_t stop = state->last; diff --git a/overlay_olsr.c b/overlay_olsr.c index 6eec98cd..cff3b420 100644 --- a/overlay_olsr.c +++ b/overlay_olsr.c @@ -48,8 +48,7 @@ static struct profile_total read_timing={ static struct sched_ent read_watch={ .function=olsr_read, .stats=&read_timing, - .poll.fd=-1, - .poll.events=POLLIN, + .poll={.fd=-1,.events=POLLIN,.revents=0}, }; int olsr_init_socket(void){ From 294710086a51af59e9e6308344b5707ab73b15a5 Mon Sep 17 00:00:00 2001 From: Petter Reinholdtsen Date: Sun, 13 Oct 2013 21:09:23 +0200 Subject: [PATCH 05/51] Avoid warning when trying to print size_t value. --- rhizome.c | 2 +- rhizome_bundle.c | 4 ++-- rhizome_database.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/rhizome.c b/rhizome.c index 3148d547..172bc23c 100644 --- a/rhizome.c +++ b/rhizome.c @@ -103,7 +103,7 @@ int rhizome_bundle_import_files(rhizome_manifest *m, const char *manifest_path, if (ret==0){ buffer_len = read_uint16(marker); if (buffer_len < 1 || buffer_len > MAX_MANIFEST_BYTES) - ret=WHYF("Invalid manifest length %d", buffer_len); + ret=WHYF("Invalid manifest length %zu", buffer_len); } if (ret==0){ diff --git a/rhizome_bundle.c b/rhizome_bundle.c index 3075de8b..4cf1f7d3 100644 --- a/rhizome_bundle.c +++ b/rhizome_bundle.c @@ -93,7 +93,7 @@ ssize_t read_whole_file(const char *path, unsigned char *buffer, size_t buffer_s return WHYF_perror("open(%s,O_RDONLY)", alloca_str_toprint(path)); ssize_t ret = read(fd, buffer, buffer_size); if (ret == -1) - ret = WHYF_perror("read(%s,%u)", alloca_str_toprint(path), buffer_size); + ret = WHYF_perror("read(%s,%zu)", alloca_str_toprint(path), buffer_size); if (close(fd) == -1) ret = WHY_perror("close"); return ret; @@ -367,7 +367,7 @@ int rhizome_hash_file(rhizome_manifest *m, const char *path, rhizome_filehash_t ssize_t r; while ((r = read(fd, buffer, sizeof buffer))) { if (r == -1) { - WHYF_perror("read(%s,%u)", alloca_str_toprint(path), sizeof buffer); + WHYF_perror("read(%s,%zu)", alloca_str_toprint(path), sizeof buffer); close(fd); return -1; } diff --git a/rhizome_database.c b/rhizome_database.c index d559cd15..3407aae4 100644 --- a/rhizome_database.c +++ b/rhizome_database.c @@ -686,7 +686,7 @@ int _sqlite_vbind(struct __sourceloc __whence, int log_level, sqlite_retry_state } else { char hash_hex[RHIZOME_FILEHASH_STRLEN]; tohex(hash_hex, sizeof hash_hex, hashp->binary); - BIND_DEBUG(RHIZOME_FILEHASH_T, sqlite3_bind_text, "%s,%d,SQLITE_TRANSIENT", hash_hex, sizeof hash_hex); + BIND_DEBUG(RHIZOME_FILEHASH_T, sqlite3_bind_text, "%s,%zd,SQLITE_TRANSIENT", hash_hex, sizeof hash_hex); BIND_RETRY(sqlite3_bind_text, hash_hex, sizeof hash_hex, SQLITE_TRANSIENT); } } From 3df845adbc7dadf3514fa7c699d75a4076f18cfb Mon Sep 17 00:00:00 2001 From: Petter Reinholdtsen Date: Sun, 13 Oct 2013 21:09:37 +0200 Subject: [PATCH 06/51] Avoid warning from unused variable. --- nacl/src/crypto_scalarmult_curve25519_ref/smult.c | 1 - 1 file changed, 1 deletion(-) diff --git a/nacl/src/crypto_scalarmult_curve25519_ref/smult.c b/nacl/src/crypto_scalarmult_curve25519_ref/smult.c index 6a479558..87f5bebe 100644 --- a/nacl/src/crypto_scalarmult_curve25519_ref/smult.c +++ b/nacl/src/crypto_scalarmult_curve25519_ref/smult.c @@ -137,7 +137,6 @@ static void mainloop(unsigned int work[64],const unsigned char e[32]) unsigned int s[32]; unsigned int t[32]; unsigned int u[32]; - unsigned int i; unsigned int j; unsigned int b; int pos; From 0d9a812824b863dc5602ae12999afa82bc02c0ec Mon Sep 17 00:00:00 2001 From: Petter Reinholdtsen Date: Sun, 13 Oct 2013 22:12:17 +0200 Subject: [PATCH 07/51] Reorder keywords to avoid compilter warnings. --- sha2.c | 10 +++++----- strbuf_helpers.c | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/sha2.c b/sha2.c index f0fc9f07..ad588a7e 100644 --- a/sha2.c +++ b/sha2.c @@ -242,7 +242,7 @@ void SHA512_Transform(SHA512_CTX*, const sha2_word64*); /*** SHA-XYZ INITIAL HASH VALUES AND CONSTANTS ************************/ /* Hash constant words K for SHA-256: */ -const static sha2_word32 K256[64] = { +static const sha2_word32 K256[64] = { 0x428a2f98UL, 0x71374491UL, 0xb5c0fbcfUL, 0xe9b5dba5UL, 0x3956c25bUL, 0x59f111f1UL, 0x923f82a4UL, 0xab1c5ed5UL, 0xd807aa98UL, 0x12835b01UL, 0x243185beUL, 0x550c7dc3UL, @@ -262,7 +262,7 @@ const static sha2_word32 K256[64] = { }; /* Initial hash value H for SHA-256: */ -const static sha2_word32 sha256_initial_hash_value[8] = { +static const sha2_word32 sha256_initial_hash_value[8] = { 0x6a09e667UL, 0xbb67ae85UL, 0x3c6ef372UL, @@ -274,7 +274,7 @@ const static sha2_word32 sha256_initial_hash_value[8] = { }; /* Hash constant words K for SHA-384 and SHA-512: */ -const static sha2_word64 K512[80] = { +static const sha2_word64 K512[80] = { 0x428a2f98d728ae22ULL, 0x7137449123ef65cdULL, 0xb5c0fbcfec4d3b2fULL, 0xe9b5dba58189dbbcULL, 0x3956c25bf348b538ULL, 0x59f111f1b605d019ULL, @@ -318,7 +318,7 @@ const static sha2_word64 K512[80] = { }; /* Initial hash value H for SHA-384 */ -const static sha2_word64 sha384_initial_hash_value[8] = { +static const sha2_word64 sha384_initial_hash_value[8] = { 0xcbbb9d5dc1059ed8ULL, 0x629a292a367cd507ULL, 0x9159015a3070dd17ULL, @@ -330,7 +330,7 @@ const static sha2_word64 sha384_initial_hash_value[8] = { }; /* Initial hash value H for SHA-512 */ -const static sha2_word64 sha512_initial_hash_value[8] = { +static const sha2_word64 sha512_initial_hash_value[8] = { 0x6a09e667f3bcc908ULL, 0xbb67ae8584caa73bULL, 0x3c6ef372fe94f82bULL, diff --git a/strbuf_helpers.c b/strbuf_helpers.c index dd63d473..3c4e81f0 100644 --- a/strbuf_helpers.c +++ b/strbuf_helpers.c @@ -52,7 +52,7 @@ static inline strbuf _toprint(strbuf sb, char c) return sb; } -static strbuf inline _overrun(strbuf sb, const char *suffix) +inline static strbuf _overrun(strbuf sb, const char *suffix) { if (strbuf_overrun(sb)) { strbuf_trunc(sb, -strlen(suffix)); @@ -61,7 +61,7 @@ static strbuf inline _overrun(strbuf sb, const char *suffix) return sb; } -static strbuf inline _overrun_quote(strbuf sb, char quote, const char *suffix) +inline static strbuf _overrun_quote(strbuf sb, char quote, const char *suffix) { if (strbuf_overrun(sb)) { strbuf_trunc(sb, -strlen(suffix) - (quote ? 1 : 0)); From de376ca4bb4f08b544effd6ef1ff2eee9e7559a0 Mon Sep 17 00:00:00 2001 From: Petter Reinholdtsen Date: Sun, 13 Oct 2013 22:17:42 +0200 Subject: [PATCH 08/51] Avoid warning from compiler about empty if block. --- serval_packetvisualise.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/serval_packetvisualise.c b/serval_packetvisualise.c index dde444d6..619438d7 100644 --- a/serval_packetvisualise.c +++ b/serval_packetvisualise.c @@ -321,8 +321,7 @@ int serval_packetvisualise_xpf(XPRINTF xpf, const char *message, const unsigned _dump(xpf, packet, len, 0, " "); size_t ofs=0; xprintf(xpf," Packet Structure:\n"); - if (isOverlayPacket(xpf,packet,&ofs,len)) - ; + if (isOverlayPacket(xpf,packet,&ofs,len)) { } if (ofs Date: Sun, 13 Oct 2013 22:18:38 +0200 Subject: [PATCH 09/51] Correct if block, only update neighbour->next_neighbour_update when the if-test is true. Avoid compiler warning. --- route_link.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/route_link.c b/route_link.c index 6a64923f..e7a49427 100644 --- a/route_link.c +++ b/route_link.c @@ -1174,8 +1174,9 @@ int link_received_packet(struct decode_context *context, int sender_seq, char un // force an update when we start hearing a new neighbour link if (link->link_timeout < now){ - if (neighbour->next_neighbour_update > now + 10); + if (neighbour->next_neighbour_update > now + 10) { neighbour->next_neighbour_update = now + 10; + } } link->link_timeout = now + (context->interface->destination->tick_ms *5); From 8cdeda51f40a4c8c2890cbdfc93baca9d0ee0215 Mon Sep 17 00:00:00 2001 From: Petter Reinholdtsen Date: Sun, 13 Oct 2013 22:19:18 +0200 Subject: [PATCH 10/51] Correct test of FILE value. Get rid of compiler warning. --- srandomdev.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/srandomdev.c b/srandomdev.c index 93c498e8..f22483b4 100644 --- a/srandomdev.c +++ b/srandomdev.c @@ -69,7 +69,7 @@ srandomdev(void) #ifndef WIN32 FILE *fd; fd = fopen("/dev/urandom", "r"); - if (fd >= 0) { + if (NULL != fd) { if (fread(&seed, sizeof seed, 1, fd) != 1) WARNF("fread(\"/dev/urandom\") failed -- falling back to gettimeofday()"); else From 3fd6cafe9f09a34884bc238b66467edd11e8cfee Mon Sep 17 00:00:00 2001 From: Petter Reinholdtsen Date: Sun, 13 Oct 2013 22:41:41 +0200 Subject: [PATCH 11/51] Avoid warnings about missing initializers. --- performance_timing.c | 2 +- serval.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/performance_timing.c b/performance_timing.c index 7c989b18..c37b8b70 100644 --- a/performance_timing.c +++ b/performance_timing.c @@ -138,7 +138,7 @@ int fd_clearstats() int fd_showstats() { - struct profile_total total={NULL, 0, "Total", 0,0,0}; + struct profile_total total={NULL, 0, "Total", 0,0,0,0}; stats_head = sort(stats_head); diff --git a/serval.h b/serval.h index 96284911..e46369fe 100644 --- a/serval.h +++ b/serval.h @@ -391,7 +391,7 @@ struct overlay_buffer; struct overlay_frame; struct broadcast; -#define STRUCT_SCHED_ENT_UNUSED {.poll.fd=-1, ._poll_index=-1,} +#define STRUCT_SCHED_ENT_UNUSED {.poll={.fd=-1}, ._poll_index=-1,} extern int overlayMode; From fde6dc210fd10c0766aa322bae780dbca48ebc33 Mon Sep 17 00:00:00 2001 From: Petter Reinholdtsen Date: Sun, 13 Oct 2013 22:55:24 +0200 Subject: [PATCH 12/51] Make code to avoid compiler warnings about uninitialized variables simpler. Fix some more. --- dna_helper.c | 2 +- overlay_mdp.c | 4 ++-- overlay_olsr.c | 2 +- vomp_console.c | 12 +++++++----- 4 files changed, 11 insertions(+), 9 deletions(-) diff --git a/dna_helper.c b/dna_helper.c index a2962978..026c7f7e 100644 --- a/dna_helper.c +++ b/dna_helper.c @@ -88,7 +88,7 @@ static int dna_helper_started = 0; #define DECLARE_SCHED_ENT(FUNCTION, VARIABLE) \ static void FUNCTION(struct sched_ent *alarm); \ static struct profile_total VARIABLE##_timing={.name="" #FUNCTION "",._next=NULL,._initialised=0,.max_time=0,.total_time=0,.child_time=0,.calls=0}; \ -static struct sched_ent VARIABLE = {.function = FUNCTION, .stats = & VARIABLE##_timing, .poll={.fd=-1, .events=0,.revents=0}}; +static struct sched_ent VARIABLE = {.function = FUNCTION, .stats = & VARIABLE##_timing, .poll={.fd=-1}}; DECLARE_SCHED_ENT(monitor_requests, sched_requests); DECLARE_SCHED_ENT(monitor_replies, sched_replies); diff --git a/overlay_mdp.c b/overlay_mdp.c index 18cdbf27..36a78fc3 100644 --- a/overlay_mdp.c +++ b/overlay_mdp.c @@ -37,14 +37,14 @@ static struct profile_total mdp_stats = { .name="overlay_mdp_poll" }; static struct sched_ent mdp_sock = { .function = overlay_mdp_poll, .stats = &mdp_stats, - .poll={.fd = -1,.events=0,.revents=0}, + .poll={.fd = -1}, }; static struct profile_total mdp_stats2 = { .name="mdp_poll2" }; static struct sched_ent mdp_sock2 = { .function = mdp_poll2, .stats = &mdp_stats2, - .poll={.fd = -1,.events=0,.revents=0}, + .poll={.fd = -1}, }; static int overlay_saw_mdp_frame(struct overlay_frame *frame, overlay_mdp_frame *mdp, time_ms_t now); diff --git a/overlay_olsr.c b/overlay_olsr.c index cff3b420..92422124 100644 --- a/overlay_olsr.c +++ b/overlay_olsr.c @@ -48,7 +48,7 @@ static struct profile_total read_timing={ static struct sched_ent read_watch={ .function=olsr_read, .stats=&read_timing, - .poll={.fd=-1,.events=POLLIN,.revents=0}, + .poll={.fd=-1,.events=POLLIN}, }; int olsr_init_socket(void){ diff --git a/vomp_console.c b/vomp_console.c index a3ee4c05..1b8f09d3 100644 --- a/vomp_console.c +++ b/vomp_console.c @@ -330,17 +330,19 @@ int app_vomp_console(const struct cli_parsed *parsed, struct cli_context *contex .name="read_lines", }; struct line_state stdin_state={ - .alarm.poll.fd = STDIN_FILENO, - .alarm.poll.events = POLLIN, - .alarm.function = read_lines, - .alarm.stats=&stdin_profile, + .alarm = { + .poll = {.fd = STDIN_FILENO,.events = POLLIN}, + .function = read_lines, + .stats=&stdin_profile + }, + .fd=0, .process_line=console_command, }; static struct profile_total monitor_profile={ .name="monitor_read", }; struct sched_ent monitor_alarm={ - .poll.events = POLLIN, + .poll = {.fd = STDIN_FILENO,.events = POLLIN}, .function = monitor_read, .stats=&monitor_profile, }; From 1124e3de3493905bd579cfb3c8f7a3ee9e63b8f6 Mon Sep 17 00:00:00 2001 From: Petter Reinholdtsen Date: Sun, 13 Oct 2013 22:56:48 +0200 Subject: [PATCH 13/51] Remove useless tests that have constant value because the variables are unsigned. --- rhizome_fetch.c | 2 +- rhizome_store.c | 2 +- tfw_createfile.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/rhizome_fetch.c b/rhizome_fetch.c index 20a51f26..f4ec6f18 100644 --- a/rhizome_fetch.c +++ b/rhizome_fetch.c @@ -1135,7 +1135,7 @@ static int pipe_journal(struct rhizome_fetch_slot *slot){ uint64_t length = slot->previous->fileLength - slot->manifest->journalTail - slot->write_state.file_offset; // of course there might not be any overlap - if (start>=0 && start < slot->previous->fileLength && length>0){ + if (start < slot->previous->fileLength && length>0){ if (config.debug.rhizome) DEBUGF("Copying %"PRId64" bytes from previous journal", length); rhizome_journal_pipe(&slot->write_state, &slot->previous->filehash, start, length); diff --git a/rhizome_store.c b/rhizome_store.c index 5e761852..c52a84cd 100644 --- a/rhizome_store.c +++ b/rhizome_store.c @@ -821,7 +821,7 @@ int rhizome_read_buffered(struct rhizome_read *read, struct rhizome_read_buffer // if we can supply either the beginning or end of the data from cache, do that first. uint64_t ofs=read->offset - buffer->offset; - if (ofs>=0 && ofs<=buffer->len){ + if (ofs<=buffer->len){ int size=len; if (size > buffer->len - ofs) size = buffer->len - ofs; diff --git a/tfw_createfile.c b/tfw_createfile.c index 3ca1b75d..fad4ec8f 100644 --- a/tfw_createfile.c +++ b/tfw_createfile.c @@ -56,7 +56,7 @@ int main(int argc, char **argv) for (i = 1; i < argc; ++i) { const char *arg = argv[i]; if (str_startswith(arg, "--size=", &arg)) { - if (!str_to_uint64_scaled(arg, 10, &size, NULL) || size < 0) + if (!str_to_uint64_scaled(arg, 10, &size, NULL)) fatal("illegal --size= argument: %s", arg); } else if (str_startswith(arg, "--label=", &arg)) From 8da836164163b463213a62c66e3baff5654683b1 Mon Sep 17 00:00:00 2001 From: Petter Reinholdtsen Date: Wed, 30 Oct 2013 18:19:28 +0100 Subject: [PATCH 14/51] Avoid duplicate settings for : and /. --- http_server.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/http_server.c b/http_server.c index b3bd6c99..9209a897 100644 --- a/http_server.c +++ b/http_server.c @@ -180,7 +180,7 @@ uint8_t http_ctype[256] = { ['p'] = _BND, ['q'] = _BND, ['r'] = _BND, ['s'] = _BND, ['t'] = _BND, ['u'] = _BND, ['v'] = _BND, ['w'] = _BND, ['x'] = _BND, ['y'] = _BND, ['z'] = _BND, - ['+'] = _BND, ['-'] = _BND, ['.'] = _BND, ['/'] = _BND, [':'] = _BND, + ['+'] = _BND, ['-'] = _BND, ['.'] = _BND, ['_'] = _BND, ['('] = _SEP | _BND, [')'] = _SEP | _BND, From 4f2b8b8fb7f4b62f6e82055ab7259bec6abe4a25 Mon Sep 17 00:00:00 2001 From: Petter Reinholdtsen Date: Wed, 30 Oct 2013 18:19:54 +0100 Subject: [PATCH 15/51] Make sure all array values are initialized, getting rid of compiler warning. --- fdqueue.h | 2 +- monitor.c | 2 +- vomp_console.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/fdqueue.h b/fdqueue.h index 11596cf3..044ed064 100644 --- a/fdqueue.h +++ b/fdqueue.h @@ -81,7 +81,7 @@ int fd_func_enter(struct __sourceloc, struct call_stats *this_call); int fd_func_exit(struct __sourceloc, struct call_stats *this_call); void dump_stack(int log_level); -#define IN() static struct profile_total _aggregate_stats={NULL,0,__FUNCTION__,0,0,0}; \ +#define IN() static struct profile_total _aggregate_stats={NULL,0,__FUNCTION__,0,0,0,0}; \ struct call_stats _this_call={.totals=&_aggregate_stats}; \ fd_func_enter(__HERE__, &_this_call); diff --git a/monitor.c b/monitor.c index a1d9611c..b3715a6e 100644 --- a/monitor.c +++ b/monitor.c @@ -546,7 +546,7 @@ struct cli_schema monitor_commands[] = { {monitor_call_audio,{"audio","","","[