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

Warning while compiling and error after running #30

Open
dannyrock opened this issue Apr 18, 2019 · 1 comment
Open

Warning while compiling and error after running #30

dannyrock opened this issue Apr 18, 2019 · 1 comment

Comments

@dannyrock
Copy link

cc -std=c99 -O2 -fPIC -finline-functions -Wall -W -Wunused -pedantic -Wpointer-arith -Wreturn-type -Wstrict-prototypes -Wmissing-prototypes -Wshadow -Wcast-qual -Wextra -o eschalot eschalot.c -lpthread -lssl -lcrypto
In function ‘setoptions’,
    inlined from ‘main’ at eschalot.c:172:2:
eschalot.c:788:4: warning: ‘strncpy’ specified bound 17 equals destination size [-Wstringop-truncation]
    strncpy(prefix, optarg, ONION_LENP1);
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cc -std=c99 -O2 -fPIC -finline-functions -Wall -W -Wunused -pedantic -Wpointer-arith -Wreturn-type -Wstrict-prototypes -Wmissing-prototypes -Wshadow -Wcast-qual -Wextra -o worgen worgen.c

while running
root@io:/opt/eschalot/eschalot# ./eschalot -ct5 -p test
ERROR: malloc(buf->length + 1) failed!

@judearich
Copy link

The error happened because malloc couldn't allocate enough memory, so the program aborted.

The warning happened because of this call to strncpy. The size of prefix is exactly ONION_LENP1, so the string might not be null-terminated.

I would suggest to a developer to use snprintf, since it guarantees the string to be null terminated.

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

No branches or pull requests

2 participants