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

-Werror=use-after-free in http.c #255

Open
philderbeast opened this issue Dec 15, 2023 · 0 comments · May be fixed by #256
Open

-Werror=use-after-free in http.c #255

philderbeast opened this issue Dec 15, 2023 · 0 comments · May be fixed by #256

Comments

@philderbeast
Copy link

On ubuntu 23.04, I followed instructions to build from source at 2f901dd. This triggered -Werror=use-after-free.

$ make
Making all in src/c
make[1]: Entering directory '/.../urweb/src/c'
/bin/bash ../../libtool  --tag=CC   --mode=compile gcc -DHAVE_CONFIG_H -I. -I../../include/urweb  -I./../../include/urweb    -Wall -Wunused-parameter -Werror -Wno-format-security -Wno-deprecated-declarations -U_FORTIFY_SOURCE  -g -O2 -MT http.lo -MD -MP -MF .deps/http.Tpo -c -o http.lo http.c
libtool: compile:  gcc -DHAVE_CONFIG_H -I. -I../../include/urweb -I./../../include/urweb -Wall -Wunused-parameter -Werror -Wno-format-security -Wno-deprecated-declarations -U_FORTIFY_SOURCE -g -O2 -MT http.lo -MD -MP -MF .deps/http.Tpo -c http.c  -fPIC -DPIC -o .libs/http.o
http.c: In function 'worker':
http.c:192:32: error: pointer 'buf' may be used after 'realloc' [-Werror=use-after-free]
  192 |               s = new_buf + (s - buf);
      |                             ~~~^~~~~~
http.c:181:25: note: call to 'realloc' here
  181 |               new_buf = realloc(buf, new_buf_size);
      |                         ^~~~~~~~~~~~~~~~~~~~~~~~~~
http.c:191:38: error: pointer 'buf' may be used after 'realloc' [-Werror=use-after-free]
  191 |               body = new_buf + (body - buf);
      |                                ~~~~~~^~~~~~
http.c:181:25: note: call to 'realloc' here
  181 |               new_buf = realloc(buf, new_buf_size);
      |                         ^~~~~~~~~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
make[1]: *** [Makefile:536: http.lo] Error 1
make[1]: Leaving directory '/.../urweb/src/c'
make: *** [Makefile:433: all-recursive] Error 1
$ gcc --version
gcc (Ubuntu 12.3.0-1ubuntu1~23.04) 12.3.0
@philderbeast philderbeast linked a pull request Dec 15, 2023 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant