Buffer overflow detected #2
Reference in New Issue
Block a user
No description provided.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Hello! Please excuse my ignorance, I am just getting started with i2p and the SAM library. When I build and run the libsam3 stream examples "streams.c" and "streamss.c" I get "buffer overflow detected" error, which terminate the program.
I am running Linux, and have my i2prouter running with the SAM client running.
Thanks very much @obscuratus for bumping this back into my view and for providing a fix, I'll review, test, and in all likelihood merge this patch shortly.
Here's my proposed fix:
@idk :
I think I've found the problem.
Looking at this strcpy at line 899 of libsam3.c
I've been getting a buffer overflow here.
I added some debugging comments, and sure enough, the strlen of v was 908
privkey is defined in the Sam3Session structure as:
where SAM3_PRIVKEY_MIN_SIZE is
If I change SAM3_PRIVKEY_MIN_SIZE to 908, the program runs.
But it worries me that it seems necessary to anticipate the key size exactly.
If I change SAM3_PRIVKEY_MIN_SIZE to 1024, libsam3 kicks this key out for being too small.
So changing the SAM3_PRIVKEY_MIN_SIZE is a work-around, but it leaves libsam3 not very robust with respect to keys of varying size, I think.
Thank you! I'm trying to debug the problem too, I'll make a comment in this thread or a new MR if I figure anything out.
Thanks for the report b4, it seems like something must have changed to cause this but I don't quite know what yet. I'll investigate and fix it.