opkg

statically linked package installer
git clone anongit@rnpnr.xyz:opkg.git
Log | Files | Refs | Feed | Submodules | README | LICENSE

0011-Avoid-index-ranges.patch (1923B)


      1 From d1c93514cb65877134e8f53b189adbcd5a0e1b43 Mon Sep 17 00:00:00 2001
      2 From: Michael Forney <mforney@mforney.org>
      3 Date: Thu, 30 Jan 2020 22:32:50 -0800
      4 Subject: [PATCH] Avoid index ranges
      5 
      6 The change in print_mac.c is not functionally the same, but we
      7 ignore this for now.
      8 ---
      9  src/print_mac.c | 4 +---
     10  src/util.c      | 8 ++++----
     11  2 files changed, 5 insertions(+), 7 deletions(-)
     12 
     13 diff --git a/src/print_mac.c b/src/print_mac.c
     14 index cad1013a8..73d7bbe28 100644
     15 --- a/src/print_mac.c
     16 +++ b/src/print_mac.c
     17 @@ -17,8 +17,6 @@
     18  DIAG_PUSH_IGNORE_OVERRIDE_INIT
     19  
     20  static uint8_t hwaddr_sizes[] = {
     21 -	[0 ... ARPHRD_VSOCKMON] = 255,
     22 -
     23  	[ARPHRD_NETROM]     =  7 /* AX25_ADDR_LEN */,
     24  	[ARPHRD_ETHER]      =  6 /* ETH_ALEN */,
     25  	/* ARPHRD_EETHER - no actual devices in Linux */
     26 @@ -129,7 +127,7 @@ print_mac_addr(const char *prefix, const uint8_t addr[], size_t size)
     27  static const char *
     28  sprint_hwaddr(const uint8_t hwaddr[], size_t size, uint32_t devtype)
     29  {
     30 -	uint8_t sz = (devtype < ARRAY_SIZE(hwaddr_sizes))
     31 +	uint8_t sz = (devtype < ARRAY_SIZE(hwaddr_sizes) && hwaddr_sizes[devtype])
     32  			? hwaddr_sizes[devtype] : 255;
     33  
     34  	return sprint_mac_addr(hwaddr, MIN(size, sz));
     35 diff --git a/src/util.c b/src/util.c
     36 index a3bea5b76..21fb9560f 100644
     37 --- a/src/util.c
     38 +++ b/src/util.c
     39 @@ -1477,16 +1477,16 @@ dumpstr(struct tcb *const tcp, const kernel_ulong_t addr,
     40  		? 1 + ilog2_klong(len - 1) / HEX_BIT : DUMPSTR_OFFS_MIN_CHARS;
     41  	kernel_ulong_t i = 0;
     42  	const unsigned char *src;
     43 +	char outbuf[DUMPSTR_WIDTH_CHARS + 1];
     44 +
     45 +	memset(outbuf, ' ', DUMPSTR_WIDTH_CHARS);
     46 +	outbuf[DUMPSTR_WIDTH_CHARS] = '\0';
     47  
     48  	while (i < len) {
     49  		/*
     50  		 * It is important to overwrite all the byte values, as we
     51  		 * re-use the buffer in order to avoid its re-initialisation.
     52  		 */
     53 -		static char outbuf[] = {
     54 -			[0 ... DUMPSTR_WIDTH_CHARS - 1] = ' ',
     55 -			'\0'
     56 -		};
     57  		char *dst = outbuf;
     58  
     59  		/* Fetching data from tracee.  */
     60 -- 
     61 2.37.3
     62