diff options
author | 2016-08-05 10:10:18 -0400 | |
---|---|---|
committer | 2016-08-05 10:10:38 -0400 | |
commit | f9c231ec12c2233557bfbb58feb87a1fcddf224a (patch) | |
tree | 6ee8846be9a6c79d68d0364c00cc58b2f3547ddd | |
parent | 56faee837281c7f9c28aa40dbf0f6e4620b76be8 (diff) |
vpp-189 Clean up more coverity warnings
Time to make the donuts
Change-Id: I528937800f7daefce19723dda0216e58d857942c
Signed-off-by: Dave Barach <dave@barachs.net>
-rw-r--r-- | vlib-api/vlibsocket/socksvr_vlib.c | 2 | ||||
-rw-r--r-- | vlib/vlib/unix/cli.c | 2 | ||||
-rw-r--r-- | vnet/vnet/ip/ip_input_acl.c | 2 | ||||
-rw-r--r-- | vnet/vnet/ip/udp_local.c | 8 | ||||
-rw-r--r-- | vnet/vnet/mpls-gre/mpls.c | 6 | ||||
-rw-r--r-- | vnet/vnet/policer/node_funcs.c | 2 | ||||
-rw-r--r-- | vnet/vnet/policer/xlate.c | 2 | ||||
-rw-r--r-- | vnet/vnet/rewrite.c | 2 | ||||
-rw-r--r-- | vnet/vnet/sr/sr.c | 11 | ||||
-rw-r--r-- | vnet/vnet/sr/sr_replicate.c | 8 | ||||
-rw-r--r-- | vnet/vnet/unix/tapcli.c | 3 | ||||
-rw-r--r-- | vnet/vnet/unix/tuntap.c | 6 | ||||
-rw-r--r-- | vnet/vnet/vxlan-gpe/decap.c | 5 | ||||
-rw-r--r-- | vnet/vnet/vxlan/decap.c | 5 | ||||
-rw-r--r-- | vpp/app/vpe_cli.c | 1 | ||||
-rw-r--r-- | vppapigen/lex.c | 57 | ||||
-rw-r--r-- | vppapigen/node.c | 2 | ||||
-rw-r--r-- | vppinfra/tools/elftool.c | 13 | ||||
-rw-r--r-- | vppinfra/vppinfra/asm_x86.c | 4 | ||||
-rw-r--r-- | vppinfra/vppinfra/bitmap.h | 4 | ||||
-rw-r--r-- | vppinfra/vppinfra/elf.c | 11 | ||||
-rw-r--r-- | vppinfra/vppinfra/elf_clib.c | 8 | ||||
-rw-r--r-- | vppinfra/vppinfra/elog.c | 2 |
23 files changed, 102 insertions, 64 deletions
diff --git a/vlib-api/vlibsocket/socksvr_vlib.c b/vlib-api/vlibsocket/socksvr_vlib.c index eb8dd334..354c4f1c 100644 --- a/vlib-api/vlibsocket/socksvr_vlib.c +++ b/vlib-api/vlibsocket/socksvr_vlib.c @@ -575,12 +575,14 @@ socksvr_api_init (vlib_main_t * vm) rv = ioctl (sockfd, FIONBIO, &one); if (rv < 0) { + close (sockfd); return clib_error_return_unix (0, "FIONBIO"); } rv = setsockopt (sockfd, SOL_SOCKET, SO_REUSEADDR, &one, sizeof (one)); if (rv < 0) { + close (sockfd); return clib_error_return_unix (0, "SO_REUSEADDR"); } diff --git a/vlib/vlib/unix/cli.c b/vlib/vlib/unix/cli.c index 7d5e10b8..22f07f99 100644 --- a/vlib/vlib/unix/cli.c +++ b/vlib/vlib/unix/cli.c @@ -2397,8 +2397,8 @@ unix_cli_config (vlib_main_t * vm, unformat_input_t * input) if (isatty (UNIX_CLI_STDIN_FD) && um->cli_line_mode == 0) { /* Capture terminal resize events */ + memset (&sa, 0, sizeof(sa)); sa.sa_handler = unix_cli_resize_interrupt; - sa.sa_flags = 0; if (sigaction (SIGWINCH, &sa, 0) < 0) clib_panic ("sigaction"); diff --git a/vnet/vnet/ip/ip_input_acl.c b/vnet/vnet/ip/ip_input_acl.c index eaf7f34e..6331cf4f 100644 --- a/vnet/vnet/ip/ip_input_acl.c +++ b/vnet/vnet/ip/ip_input_acl.c @@ -322,7 +322,7 @@ ip_inacl_inline (vlib_main_t * vm, t->sw_if_index = vnet_buffer(b0)->sw_if_index[VLIB_RX]; t->next_index = next0; t->table_index = t0 ? t0 - vcm->tables : ~0; - t->offset = e0 ? vnet_classify_get_offset (t0, e0): ~0; + t->offset = (e0 && t0) ? vnet_classify_get_offset (t0, e0): ~0; } /* verify speculative enqueue, maybe switch current next frame */ diff --git a/vnet/vnet/ip/udp_local.c b/vnet/vnet/ip/udp_local.c index 9b701470..4928d552 100644 --- a/vnet/vnet/ip/udp_local.c +++ b/vnet/vnet/ip/udp_local.c @@ -242,8 +242,8 @@ udp46_input_inline (vlib_main_t * vm, b0, sizeof (*tr)); if (b0->error != node->errors[UDP_ERROR_LENGTH_ERROR]) { - tr->src_port = h0->src_port; - tr->dst_port = h0->dst_port; + tr->src_port = h0 ? h0->src_port : 0; + tr->dst_port = h0 ? h0->dst_port : 0; tr->bound = (next0 != UDP_INPUT_NEXT_ICMP4_ERROR && next0 != UDP_INPUT_NEXT_ICMP6_ERROR); } @@ -254,8 +254,8 @@ udp46_input_inline (vlib_main_t * vm, b1, sizeof (*tr)); if (b1->error != node->errors[UDP_ERROR_LENGTH_ERROR]) { - tr->src_port = h1->src_port; - tr->dst_port = h1->dst_port; + tr->src_port = h1 ? h1->src_port : 0; + tr->dst_port = h1 ? h1->dst_port : 0; tr->bound = (next1 != UDP_INPUT_NEXT_ICMP4_ERROR && next1 != UDP_INPUT_NEXT_ICMP6_ERROR); } diff --git a/vnet/vnet/mpls-gre/mpls.c b/vnet/vnet/mpls-gre/mpls.c index 4b36c5dc..d914b4c2 100644 --- a/vnet/vnet/mpls-gre/mpls.c +++ b/vnet/vnet/mpls-gre/mpls.c @@ -399,7 +399,7 @@ int vnet_mpls_add_del_decap (u32 rx_fib_id, tx_fib_index_or_output_swif_index = tx_fib_id; } - key = ((u64)rx_fib_index<<32) | ((u64) (label_host_byte_order<<12)) + key = ((u64) rx_fib_index<<32) | ((u64) label_host_byte_order<<12) | ((u64) s_bit<<8); p = hash_get (mm->mpls_decap_by_rx_fib_and_label, key); @@ -748,8 +748,8 @@ int mpls_fib_reset_labels (u32 fib_id) vec_foreach (s, records) { - key = ((u64)fib_index <<32) | ((u64)(s->dest<<12)) | - ((u64)s->s_bit); + key = ((u64) fib_index <<32) | ((u64) s->dest<<12) | + ((u64) s->s_bit); hash_unset (mm->mpls_decap_by_rx_fib_and_label, key); pool_put_index (mm->decaps, s->entry_index); diff --git a/vnet/vnet/policer/node_funcs.c b/vnet/vnet/policer/node_funcs.c index 0858a86d..61a29733 100644 --- a/vnet/vnet/policer/node_funcs.c +++ b/vnet/vnet/policer/node_funcs.c @@ -804,7 +804,7 @@ policer_classify_inline (vlib_main_t * vm, t->sw_if_index = vnet_buffer(b0)->sw_if_index[VLIB_RX]; t->next_index = next0; t->table_index = t0 ? t0 - vcm->tables : ~0; - t->offset = e0 ? vnet_classify_get_offset (t0, e0): ~0; + t->offset = (e0 && t0) ? vnet_classify_get_offset (t0, e0): ~0; t->policer_index = e0 ? e0->next_index: ~0; } diff --git a/vnet/vnet/policer/xlate.c b/vnet/vnet/policer/xlate.c index 934c488c..61976b1c 100644 --- a/vnet/vnet/policer/xlate.c +++ b/vnet/vnet/policer/xlate.c @@ -468,7 +468,7 @@ sse2_pol_convert_cfg_rates_to_hw (sse2_qos_pol_cfg_params_st *cfg, &exp, &hi_mant); } - denom = (1 << exp); + denom = (1ULL << exp); if (hi_rate == eir_hw) { hw->peak_rate_man = (uint16_t)hi_mant; rc = sse2_qos_pol_round((uint64_t)cir_hw, denom, &rnd_value, diff --git a/vnet/vnet/rewrite.c b/vnet/vnet/rewrite.c index a538eef3..3435b0f2 100644 --- a/vnet/vnet/rewrite.c +++ b/vnet/vnet/rewrite.c @@ -209,7 +209,7 @@ void vnet_rewrite_for_sw_interface (vnet_main_t * vnm, ASSERT (hc->set_rewrite); n_rw_tmp = hc->set_rewrite (vnm, sw_if_index, packet_type, dst_address, rw_tmp, max_rewrite_bytes); - ASSERT (n_rw_tmp >= 0 && n_rw_tmp < max_rewrite_bytes); + ASSERT (n_rw_tmp < max_rewrite_bytes); vnet_rewrite_set_data_internal (rw, max_rewrite_bytes, rw_tmp, n_rw_tmp); } diff --git a/vnet/vnet/sr/sr.c b/vnet/vnet/sr/sr.c index 05d8d816..d935b458 100644 --- a/vnet/vnet/sr/sr.c +++ b/vnet/vnet/sr/sr.c @@ -724,8 +724,10 @@ find_or_add_shared_secret (ip6_sr_main_t * sm, u8 * secret, u32 * indexp) for (i = 0; i < vec_len (sm->hmac_keys); i++) { if (sm->hmac_keys[i].shared_secret == 0) - key = sm->hmac_keys + i; - goto found; + { + key = sm->hmac_keys + i; + goto found; + } } vec_validate (sm->hmac_keys, i); key = sm->hmac_keys + i; @@ -970,7 +972,6 @@ int ip6_sr_add_del_tunnel (ip6_sr_add_del_tunnel_args_t * a) memset(&adj, 0, sizeof (adj)); /* Create an adjacency and add to v6 fib */ - adj.lookup_next_index = IP_LOOKUP_NEXT_REWRITE; adj.lookup_next_index = sm->ip6_lookup_sr_next_index; adj.explicit_fib_index = ~0; @@ -1020,7 +1021,9 @@ int ip6_sr_add_del_tunnel (ip6_sr_add_del_tunnel_args_t * a) p=hash_get_mem (sm->policy_index_by_policy_name, a->policy_name); } vec_add1 (pt->tunnel_indices, t - sm->tunnels); - t->policy_index = p[0]; /* equiv. to (pt - sm->policies) */ + if (p == 0) + clib_warning ("p is NULL!"); + t->policy_index = p ? p[0] : ~0; /* equiv. to (pt - sm->policies) */ } if (a->name) diff --git a/vnet/vnet/sr/sr_replicate.c b/vnet/vnet/sr/sr_replicate.c index ccc01465..f059ce95 100644 --- a/vnet/vnet/sr/sr_replicate.c +++ b/vnet/vnet/sr/sr_replicate.c @@ -304,17 +304,17 @@ sr_replicate_node_fn (vlib_main_t * vm, sr_replicate_trace_t *tr = vlib_add_trace (vm, node, b0, sizeof (*tr)); tr->tunnel_index = t0 - sm->tunnels; + tr->length = 0; if (hdr_ip0) { memcpy (tr->src.as_u8, hdr_ip0->src_address.as_u8, sizeof (tr->src.as_u8)); memcpy (tr->dst.as_u8, hdr_ip0->dst_address.as_u8, sizeof (tr->dst.as_u8)); + if (hdr_ip0->payload_length) + tr->length = clib_net_to_host_u16 + (hdr_ip0->payload_length); } - if (hdr_ip0->payload_length) - tr->length = clib_net_to_host_u16(hdr_ip0->payload_length); - else - tr->length = 0; tr->next_index = next_index; memcpy (tr->sr, hdr_sr0, sizeof (tr->sr)); } diff --git a/vnet/vnet/unix/tapcli.c b/vnet/vnet/unix/tapcli.c index 667e3e41..7e2ee063 100644 --- a/vnet/vnet/unix/tapcli.c +++ b/vnet/vnet/unix/tapcli.c @@ -823,7 +823,8 @@ int vnet_tap_connect (vlib_main_t * vm, u8 * intfc_name, u8 *hwaddr_arg, error: close (dev_net_tun_fd); - close (dev_tap_fd); + if (dev_tap_fd >= 0) + close (dev_tap_fd); return rv; } diff --git a/vnet/vnet/unix/tuntap.c b/vnet/vnet/unix/tuntap.c index 28b2584b..f24d71ee 100644 --- a/vnet/vnet/unix/tuntap.c +++ b/vnet/vnet/unix/tuntap.c @@ -427,7 +427,8 @@ tuntap_exit (vlib_main_t * vm) if (ioctl (tm->dev_net_tun_fd, TUNSETPERSIST, 0) < 0) clib_unix_warning ("TUNSETPERSIST"); close(tm->dev_tap_fd); - close(tm->dev_net_tun_fd); + if (tm->dev_net_tun_fd >= 0) + close(tm->dev_net_tun_fd); close (sfd); return 0; @@ -809,7 +810,8 @@ tuntap_ip6_add_del_interface_address (ip6_main_t * im, if (ioctl (sockfd, SIOCDIFADDR, &ifr6) < 0) clib_unix_warning ("del address"); - close (sockfd); + if (sockfd >= 0) + close (sockfd); mhash_unset (&tm->subif_mhash, &subif_addr, 0 /* old value ptr */); pool_put (tm->subifs, ap); diff --git a/vnet/vnet/vxlan-gpe/decap.c b/vnet/vnet/vxlan-gpe/decap.c index 34bcccd9..7f32cbd8 100644 --- a/vnet/vnet/vxlan-gpe/decap.c +++ b/vnet/vnet/vxlan-gpe/decap.c @@ -73,7 +73,10 @@ vxlan_gpe_input (vlib_main_t * vm, u32 cpu_index = os_get_cpu_number (); u32 stats_sw_if_index, stats_n_packets, stats_n_bytes; - memset (&last_key4, 0xff, sizeof(last_key4)); + if (is_ip4) + memset (&last_key4, 0xff, sizeof(last_key4)); + else + memset (&last_key6, 0xff, sizeof(last_key6)); from = vlib_frame_vector_args (from_frame); n_left_from = from_frame->n_vectors; diff --git a/vnet/vnet/vxlan/decap.c b/vnet/vnet/vxlan/decap.c index dc9a2ff7..899b3318 100644 --- a/vnet/vnet/vxlan/decap.c +++ b/vnet/vnet/vxlan/decap.c @@ -64,7 +64,10 @@ vxlan_input (vlib_main_t * vm, u32 cpu_index = os_get_cpu_number(); u32 stats_sw_if_index, stats_n_packets, stats_n_bytes; - last_key4.as_u64 = ~0; + if (is_ip4) + last_key4.as_u64 = ~0; + else + memset (&last_key6, 0xff, sizeof (last_key6)); from = vlib_frame_vector_args (from_frame); n_left_from = from_frame->n_vectors; diff --git a/vpp/app/vpe_cli.c b/vpp/app/vpe_cli.c index 32b6d03d..b9f717bd 100644 --- a/vpp/app/vpe_cli.c +++ b/vpp/app/vpe_cli.c @@ -67,6 +67,7 @@ virtual_ip_cmd_fn_command_fn (vlib_main_t * vm, ip_adjacency_t adj; u32 adj_index; + memset(&adj, 0, sizeof(adj)); adj.lookup_next_index = IP_LOOKUP_NEXT_REWRITE; vnet_rewrite_for_sw_interface diff --git a/vppapigen/lex.c b/vppapigen/lex.c index d7d8cbaf..88744ff1 100644 --- a/vppapigen/lex.c +++ b/vppapigen/lex.c @@ -390,7 +390,8 @@ int main (int argc, char **argv) } else { fclose (ifp); - fclose (ofp); + if (ofp) + fclose (ofp); if (ofile) { printf ("Removing %s\n", ofile); unlink (ofile); @@ -426,6 +427,12 @@ void yyerror (char *s) static char namebuf [MAXNAME]; +static inline char +getc_char (FILE *ifp) +{ + return ((char)(getc(ifp) & 0x7f)); +} + /* * yylex (well, yylex_1: The real yylex below does crc-hackery) */ @@ -433,7 +440,6 @@ static int yylex_1 (void) { int nameidx=0; char c; - int at_bol=1; enum { LP_INITIAL_WHITESPACE, LP_LINE_NUMBER, LP_PRE_FILENAME_WHITESPACE, LP_FILENAME, LP_POST_FILENAME, @@ -446,23 +452,16 @@ static int yylex_1 (void) * START state -- looking for something interesting */ case START_STATE: - c = getc (ifp); + c = getc_char (ifp); if (feof (ifp)) return (EOF); switch (c) { case '\n': the_lexer_linenumber++; - at_bol=1; goto again; case '#': - if (!at_bol) { - fprintf (stderr, "unknown token /%c at line %d\n", - c, the_lexer_linenumber); - return (BARF); - } - the_lexer_state = LINE_PRAGMA_STATE; lp_substate = LP_INITIAL_WHITESPACE; goto again; @@ -507,7 +506,7 @@ static int yylex_1 (void) goto again; case '/': - c = getc (ifp); + c = getc_char (ifp); if (feof (ifp)) return (EOF); @@ -524,7 +523,7 @@ static int yylex_1 (void) } case '\\': - c = getc (ifp); + c = getc_char (ifp); if (feof (ifp)) return (EOF); @@ -552,7 +551,7 @@ static int yylex_1 (void) * NAME state -- eat the rest of a name */ case NAME_STATE: - c = getc (ifp); + c = getc_char (ifp); if (feof (ifp)) return (EOF); @@ -573,7 +572,7 @@ static int yylex_1 (void) * NUMBER state -- eat the rest of a number */ case NUMBER_STATE: - c = getc (ifp); + c = getc_char (ifp); if (feof (ifp)) return (EOF); @@ -595,11 +594,11 @@ static int yylex_1 (void) * C_COMMENT state -- eat a peach */ case C_COMMENT_STATE: - c = getc (ifp); + c = getc_char (ifp); if (feof (ifp)) return (EOF); if (c == '*') { - c = getc (ifp); + c = getc_char (ifp); if (feof (ifp)) return (EOF); if (c == '/') { @@ -616,7 +615,7 @@ static int yylex_1 (void) */ case CPP_COMMENT_STATE: - c = getc (ifp); + c = getc_char (ifp); if (feof (ifp)) return (EOF); if (c == '\n') { @@ -627,12 +626,12 @@ static int yylex_1 (void) goto again; case STRING_STATE: - c = getc (ifp); + c = getc_char (ifp); if (feof (ifp)) return (EOF); switch (c) { case '\\': - c = getc (ifp); + c = getc_char (ifp); if (feof (ifp)) return (EOF); namebuf[nameidx++] = c; @@ -658,12 +657,12 @@ static int yylex_1 (void) break; case HELPER_STATE: - c = getc (ifp); + c = getc_char (ifp); if (feof (ifp)) return (EOF); switch (c) { case '\\': - c = getc (ifp); + c = getc_char (ifp); if (feof (ifp)) return (EOF); namebuf[nameidx] = c; @@ -703,7 +702,7 @@ static int yylex_1 (void) switch (lp_substate) { case LP_INITIAL_WHITESPACE: /* no number seen yet */ - c = getc(ifp); + c = getc_char(ifp); if (feof(ifp)) return(EOF); if (c >= '0' && c <= '9') { @@ -719,7 +718,7 @@ static int yylex_1 (void) goto again; case LP_LINE_NUMBER: /* eating linenumber */ - c = getc(ifp); + c = getc_char(ifp); if (feof(ifp)) return(EOF); if (c >= '0' && c <= '9') { @@ -736,7 +735,7 @@ static int yylex_1 (void) goto again; case LP_PRE_FILENAME_WHITESPACE: /* awaiting filename */ - c = getc(ifp); + c = getc_char(ifp); if (feof(ifp)) return(EOF); @@ -753,7 +752,7 @@ static int yylex_1 (void) goto again; case LP_FILENAME: /* eating filename */ - c = getc(ifp); + c = getc_char(ifp); if (feof(ifp)) return(EOF); @@ -769,7 +768,7 @@ static int yylex_1 (void) case LP_POST_FILENAME: /* ignoring rest of line */ case LP_OTHER: - c = getc(ifp); + c = getc_char(ifp); if (feof(ifp)) return(EOF); @@ -789,7 +788,6 @@ static int yylex_1 (void) } lp_end_of_line: the_lexer_state = START_STATE; - at_bol = 1; nameidx = 0; } goto again; @@ -986,6 +984,11 @@ char *sxerox (const char *s) char *rv; rv = (char *) malloc (len+1); + if (rv == 0) { + fprintf(stderr, "Out of memory..."); + exit (1); + } + strcpy (rv, s); return (rv); } diff --git a/vppapigen/node.c b/vppapigen/node.c index ab8adc56..e66fdce8 100644 --- a/vppapigen/node.c +++ b/vppapigen/node.c @@ -1034,7 +1034,7 @@ char *fixup_input_filename(void) if (*cp == '/') cp++; - strcpy (tmpbuf, cp); + strncpy (tmpbuf, cp, sizeof(tmpbuf)-1); cp = tmpbuf; diff --git a/vppinfra/tools/elftool.c b/vppinfra/tools/elftool.c index f5d70b56..d9d3704b 100644 --- a/vppinfra/tools/elftool.c +++ b/vppinfra/tools/elftool.c @@ -358,10 +358,12 @@ set_interpreter_rpath (elf_tool_main_t * tm) } done: - if (mmap_length > 0) + if (mmap_length > 0 && idp) munmap (idp, mmap_length); - close (ifd); - close (ofd); + if (ifd >= 0) + close (ifd); + if (ofd >= 0) + close (ofd); return error; } @@ -408,7 +410,10 @@ int main (int argc, char * argv[]) } if (! tm->input_file) - clib_error ("no input file"); + { + error = clib_error_return (0, "no input file"); + goto done; + } /* Do the typical case a stone-simple way... */ if (tm->quiet && tm->set_interpreter && tm->set_rpath && tm->output_file) diff --git a/vppinfra/vppinfra/asm_x86.c b/vppinfra/vppinfra/asm_x86.c index d89739cb..16e41c24 100644 --- a/vppinfra/vppinfra/asm_x86.c +++ b/vppinfra/vppinfra/asm_x86.c @@ -1736,6 +1736,7 @@ static u8 * format_x86_reg_operand (u8 * s, va_list * va) { default: ASSERT (0); + break; case 'x': ASSERT (reg < 16); @@ -1816,6 +1817,7 @@ static u8 * format_x86_insn_operand (u8 * s, va_list * va) /* Memory or reg field from modrm byte. */ case 'M': ASSERT (p->flags & X86_INSN_IS_ADDRESS); + /* FALLTHROUGH */ case 'E': if (p->flags & X86_INSN_IS_ADDRESS) s = format (s, "%U", format_x86_mem_operand, p); @@ -1836,7 +1838,7 @@ static u8 * format_x86_insn_operand (u8 * s, va_list * va) case 'I': { u32 l = x86_insn_log2_immediate_bytes (p, insn); - i64 mask = pow2_mask (8 << l); + i64 mask = pow2_mask (8ULL << l); s = format (s, "$0x%Lx", p->immediate & mask); } break; diff --git a/vppinfra/vppinfra/bitmap.h b/vppinfra/vppinfra/bitmap.h index 35de1b48..17b72ac6 100644 --- a/vppinfra/vppinfra/bitmap.h +++ b/vppinfra/vppinfra/bitmap.h @@ -196,7 +196,7 @@ clib_bitmap_get_multiple (uword * bitmap, uword i, uword n_bits) uword i0, i1, result; uword l = vec_len (bitmap); - ASSERT (n_bits >= 0 && n_bits <= BITS (result)); + ASSERT (n_bits <= BITS (result)); i0 = i / BITS (bitmap[0]); i1 = i % BITS (bitmap[0]); @@ -229,7 +229,7 @@ clib_bitmap_set_multiple (uword * bitmap, uword i, uword value, uword n_bits) { uword i0, i1, l, t, m; - ASSERT (n_bits >= 0 && n_bits <= BITS (value)); + ASSERT (n_bits <= BITS (value)); i0 = i / BITS (bitmap[0]); i1 = i % BITS (bitmap[0]); diff --git a/vppinfra/vppinfra/elf.c b/vppinfra/vppinfra/elf.c index 7fe3048b..71ae1d33 100644 --- a/vppinfra/vppinfra/elf.c +++ b/vppinfra/vppinfra/elf.c @@ -559,7 +559,8 @@ format_elf_main (u8 * s, va_list * args) s = format (s, "\nSections %d at file offset 0x%Lx-0x%Lx:\n", fh->section_header_count, fh->section_header_file_offset, - fh->section_header_file_offset + fh->section_header_count * fh->section_header_size); + fh->section_header_file_offset + + (u64) fh->section_header_count * fh->section_header_size); s = format (s, "%U\n", format_elf_section, em, 0); vec_foreach (h, copy) s = format (s, "%U\n", format_elf_section, em, h); @@ -1604,7 +1605,7 @@ static void layout_sections (elf_main_t * em) fh->section_header_file_offset = file_offset; fh->section_header_count = vec_len (em->sections) - n_deleted_sections; - file_offset += fh->section_header_count * fh->section_header_size; + file_offset += (u64) fh->section_header_count * fh->section_header_size; } { @@ -1809,7 +1810,11 @@ clib_error_t * elf_write_file (elf_main_t * em, char * file_name) continue; if (fseek (f, s->header.file_offset, SEEK_SET) < 0) - return clib_error_return_unix (0, "fseek 0x%Lx", s->header.file_offset); + { + fclose(f); + return clib_error_return_unix (0, "fseek 0x%Lx", + s->header.file_offset); + } if (s->header.type == ELF_SECTION_NO_BITS) /* don't write for .bss sections */; diff --git a/vppinfra/vppinfra/elf_clib.c b/vppinfra/vppinfra/elf_clib.c index f3d3b32a..8c705488 100644 --- a/vppinfra/vppinfra/elf_clib.c +++ b/vppinfra/vppinfra/elf_clib.c @@ -82,6 +82,9 @@ path_search (char * file) if (file[0] == '.' || file[0] == '/') return file; + if (getenv("PATH") == 0) + return file; + ps.path = split_string (getenv ("PATH"), ':'); for (i = 0; i < vec_len (ps.path); i++) @@ -231,7 +234,10 @@ add_section (struct dl_phdr_info * info, size_t size, void * opaque) name = path_search (cem->exec_path); if (! name) - clib_error ("failed to find %s on PATH", cem->exec_path); + { + clib_error ("failed to find %s on PATH", cem->exec_path); + return 0; + } addr = 0; } diff --git a/vppinfra/vppinfra/elog.c b/vppinfra/vppinfra/elog.c index 06b97d8a..7ae4ea1d 100644 --- a/vppinfra/vppinfra/elog.c +++ b/vppinfra/vppinfra/elog.c @@ -582,6 +582,8 @@ void elog_merge (elog_main_t * dst, u8 * dst_tag, elog_track_t newt; int i; + memset(&newt, 0, sizeof (newt)); + elog_get_events (src); elog_get_events (dst); |