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

Make/Compile Error/Warning Including Fix - In function ‘setoptions’, inlined from ‘main’ at eschalot.c:172:2: eschalot.c:788:4: warning: ‘strncpy’ specified bound 17 #40

Open
dramat1c opened this issue May 2, 2023 · 0 comments

Comments

@dramat1c
Copy link

dramat1c commented May 2, 2023

root@box:~/tor/eschalot# make test
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 -Wl,-Bstatic -lssl -lcrypto -Wl,-Bdynamic -
lpthread -ldl
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);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

I was receiving this error when trying to make/compile Eschalot in Proxmox which is a Debian based distro that runs a custom kernel, the kernel version I was compiling on is 5.4.106-1-pve. It is actually not an error but a compiling warning.

It indicates a potential issue with the strncpy function in your code. The strncpy function is being used to copy the contents of optarg to prefix, with a specified bound of 17 (ONION_LENP1). The warning -Wstringop-truncation is triggered because the specified bound (17) is equal to the destination size, which means strncpy might not null-terminate the destination string if the source string has 17 or more characters. This can lead to unexpected behavior or security issues.

To fix the issue, I edited the code of eschalot.c, going to line 788 as specified from the warning, and changed the following:

Original code under case 'p':
strncpy(prefix, optarg, ONION_LENP1);

Changed to the following:
strncpy(prefix, optarg, ONION_LENP1 - 1);
prefix[ONION_LENP1 - 1] = '\0'; // Explicitly null terminate the destination string

This fixed the issue and it compiled with no warning errors. If you are having this issue when compiling, this fix should help you out.
BUT, I am still having an issue for some reason when it comes to another issue.

Compiling following the fix, which is an issue I had before the warning:
root@box:~/tor/eschalot# make test
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 -Wl,-Bstatic -lssl -lcrypto -Wl,-Bdynamic -
lpthread -ldl
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
./worgen 8-16 top150adjectives.txt 3-16 top400nouns.txt 3-16 top1000.txt 3-16 > wordlist.txt
Will be producing 8-16 character long word combinations.
Reading 3-16 characters words from top150adjectives.txt.
Reading 3-16 characters words from top400nouns.txt.
Reading 3-16 characters words from top1000.txt.
Loading words from top150adjectives.txt.
Loaded 150 words from top150adjectives.txt.
Loading words from top400nouns.txt.
Loaded 400 words from top400nouns.txt.
Loading words from top1000.txt.
Loaded 974 words from top1000.txt.
Working. 100% complete, 31122412 words (approximately 377Mb) produced.
Final count: 31366539 word combinations.
./eschalot -vct4 -f wordlist.txt >> results.txt
Verbose, continuous, no digits, 4 threads, prefixes 8-16 characters long.
Reading words from wordlist.txt, please wait...
Loaded 31366539 words.
Sorting the word hashes and removing duplicates.
Final word count: 31363570.
Thread #1 started.
Thread #2 started.
Thread #3 started.
Thread #4 started.
Running, collecting performance data...
WARNING: Key check failed - e is coprime to lambda!
ERROR: A bad key was found!
make: *** [Makefile:74: test] Error 1

For some reason I am still having the WARNING: Key check failed - e is coprime to lamda! - ERROR: A bad key was found!
I have read the other thread regarding this and tried doing what worked for others but it does not seem to be working for me. If there is anyone else out there who is having this issue and also using Proxmox which has come to a solution, any help would be greatly appreciated. The reason I am running it under Proxmox is so I can utilize all the resources of this particular colocated server which I also use to host VPS' for myself. Again any help would be appreciated. Thanks in advance!

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

1 participant