Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Array bounds error #840

Open
michaelortmann opened this issue Aug 15, 2019 · 0 comments · May be fixed by #841

Comments

@michaelortmann
Copy link
Member

commented Aug 15, 2019

gcc 9.1.0, default cflags:

gcc -g -O2 -pipe -Wall -I.. -I..  -DHAVE_CONFIG_H -I/usr/include -g3 -DDEBUG -DDEBUG_ASSERT -DDEBUG_MEM -DDEBUG_DNS  -c flags.c
flags.c: In function ‘break_down_flags’:
flags.c:387:10: warning: array subscript 1 is outside array bounds of ‘char[1]’ [-Warray-bounds]
  387 |   while (*string) {
      |          ^~~~~~~

I looked into it very hard, and as always, the compiler was right.

See:

https://github.com/eggheads/eggdrop/blob/develop/src/flags.c#L406
https://github.com/eggheads/eggdrop/blob/develop/src/flags.c#L448
https://github.com/eggheads/eggdrop/blob/develop/src/flags.c#L387

Pseudocode:

while (*string) { /* Array bounds error if the following "if" is triggered */
  if [...]
    string = "";
  string++;
}
This was referenced Aug 15, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant
You can’t perform that action at this time.