Project

General

Profile

Bug #6173

GCC12: error: array subscript 1 is outside array bounds

Added by Dirk Diggler 4 months ago. Updated 16 days ago.

Status:
New
Priority:
Normal
Assignee:
-
Category:
-
Target version:
-
Start date:
2022-05-27
Due date:
% Done:

0%

Estimated time:
Found in version:
latest snapshot
Affected Versions:

Description

See: https://aur.archlinux.org/packages/tvheadend-git

In file included from src/tcp.c:32:
In function 'ip_check_is_any_v6',
inlined from 'ip_check_is_any' at src/tcp.h:109:46,
inlined from 'ip_check_is_local_address' at src/tcp.c:89:17:
src/tcp.h:104:57: error: array subscript 1 is outside array bounds of 'const struct sockaddr_storage0' [-Werror=array-bounds]
104 | { return ((uint64_t *)IP_AS_V6(address, addr).s6_addr)[0] == ((uint64_t *)(&in6addr_any.s6_addr))[0] && | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
src/tcp.h: In function 'ip_check_is_local_address':
src/tcp.h:107:19: note: at offset 8 into object 'address' of size 8
107 | static inline int ip_check_is_any(const struct sockaddr_storage *address) | ^~~~~~~~~~~~~
In function 'ip_check_is_any_v6',
inlined from 'ip_check_is_any' at src/tcp.h:109:46,
inlined from 'ip_check_is_local_address' at src/tcp.c:89:17:
src/tcp.h:105:57: error: array subscript 2 is outside array bounds of 'const struct sockaddr_storage0' [-Werror=array-bounds]
105 | ((uint64_t *)IP_AS_V6(address, addr).s6_addr)[1] == ((uint64_t *)(&in6addr_any.s6_addr))[1]; } | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
src/tcp.h: In function 'ip_check_is_local_address':
src/tcp.h:107:19: note: at offset 16 into object 'address' of size 8
107 | static inline int ip_check_is_any(const struct sockaddr_storage *address) | ^~~~~~~~~~~~~
In function 'ip_check_equal_v6',
inlined from 'ip_check_equal' at src/tcp.h:78:42,
inlined from 'ip_check_is_local_address' at src/tcp.c:96:26:
src/tcp.h:71:53: error: array subscript 1 is outside array bounds of 'const struct sockaddr_storage0' [-Werror=array-bounds]
71 | { return ((uint64_t *)IP_AS_V6(a, addr).s6_addr)[0] == ((uint64_t *)IP_AS_V6(b, addr).s6_addr)[0] && | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
src/tcp.h: In function 'ip_check_is_local_address':
src/tcp.h:74:19: note: at offset 8 into object 'a' of size 8
74 | static inline int ip_check_equal | ^~~~~~~~~~~~
In function 'ip_check_equal_v6',
inlined from 'ip_check_equal' at src/tcp.h:78:42,
inlined from 'ip_check_is_local_address' at src/tcp.c:96:26:
src/tcp.h:71:99: error: array subscript 1 is outside array bounds of 'const struct sockaddr_storage0' [-Werror=array-bounds]
71 | { return ((uint64_t *)IP_AS_V6(a, addr).s6_addr)[0] == ((uint64_t *)IP_AS_V6(b, addr).s6_addr)[0] && | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
src/tcp.h: In function 'ip_check_is_local_address':
src/tcp.h:74:19: note: at offset 8 into object 'b' of size 8
74 | static inline int ip_check_equal | ^~~~~~~~~~~~
In function 'ip_check_equal_v6',
inlined from 'ip_check_equal' at src/tcp.h:78:42,
inlined from 'ip_check_is_local_address' at src/tcp.c:96:26:
src/tcp.h:72:53: error: array subscript 2 is outside array bounds of 'const struct sockaddr_storage0' [-Werror=array-bounds]
72 | ((uint64_t *)IP_AS_V6(a, addr).s6_addr)[1] == ((uint64_t *)IP_AS_V6(b, addr).s6_addr)[1]; } | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
src/tcp.h: In function 'ip_check_is_local_address':
src/tcp.h:74:19: note: at offset 16 into object 'a' of size 8
74 | static inline int ip_check_equal | ^~~~~~~~~~~~
In function 'ip_check_equal_v6',
inlined from 'ip_check_equal' at src/tcp.h:78:42,
inlined from 'ip_check_is_local_address' at src/tcp.c:96:26:
src/tcp.h:72:99: error: array subscript 2 is outside array bounds of 'const struct sockaddr_storage0' [-Werror=array-bounds]
72 | ((uint64_t *)IP_AS_V6(a, addr).s6_addr)[1] == ((uint64_t *)IP_AS_V6(b, addr).s6_addr)[1]; } | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
src/tcp.h: In function 'ip_check_is_local_address':
src/tcp.h:74:19: note: at offset 16 into object 'b' of size 8
74 | static inline int ip_check_equal

History

#1

Updated by Flole Systems 4 months ago

  • Status changed from New to Invalid

You're using an unofficial/modified build. Contact the maintainer for support.

#2

Updated by Dirk Diggler 4 months ago

Flole Systems wrote:

You're using an unofficial/modified build. Contact the maintainer for support.

Hey, not so fast. I get the same error when compiling the current github source!

#3

Updated by Flole Systems 4 months ago

Then feel free to update this so it's a proper bug report (including which OS and compiler is used and steps to reproduce) then it can be re-opened, but don't expect anyone to work on it as it's building perfectly fine on 24 different systems. If you provide a PR though it will be reviewed and merged eventually.

#4

Updated by Dirk Diggler 4 months ago

Operating System: Arch Linux
Kernel: Linux 5.17.9-arch1-1
Architecture: x86-64

gcc (GCC) 12.1.0

Steps: ./configure, make

#5

Updated by Dirk Diggler 4 months ago

Hey, compiler version was a good hint. I installed older GCC 11 version, which works.
So i don't know if tvheadend code has to be fixed for GCC 12?

#6

Updated by Flole Systems 4 months ago

  • Subject changed from error: array subscript 1 is outside array bounds to GCC12: error: array subscript 1 is outside array bounds
  • Status changed from Invalid to New
#7

Updated by Pim Zandbergen 4 months ago

Fedora 36 switched to GCC 12 too.

#8

Updated by Volker Schmidt about 2 months ago

Found a wuerg-around (err, german-IT-slang) - a work around for GCC 12.

Add this for your additions to CFLAGS (PKGBUILD / environment / Makefile):

export CFLAGS="$CFLAGS -Wno-error=array-bounds -Wno-error=address"

tvheadend now builds.

#9

Updated by Flole Systems 16 days ago

That is not a solution though, there are several things wrong with that code. For example in the ip_check_equal_v6 (and probably in others aswell) there is a pointer to a pointer which is then casted to an uint64_t* and then offset 1 of that is accessed. It will never work like this, and basically same thing for IPv4. Someone needs to go through all usages and figure out where it needs to be changed so that always a pointer is passed and the & needs to be removed from the IP_AS_V* aswell.

Also for IPv6 there is a strict aliasing violation, even with those fixes the comparison like that is undefined behaviour.

Also available in: Atom PDF