Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

reubensammut
Copy link
Contributor

The function swapNames in pointers-struct.c and enums.c have an incorrect function signature. If we're swapping what username and password point to as it seems to be the case when calling the swapNames function from main, both parameters should be of type char ** and not char *.

This change also fixes the ELF generated which seems to be swapping just the first character of an address instead of swapping the strings. In reality it only works as both argv[2] and argv[3] are very close and we're just changing the last byte of the address. There could be cases where the addresses of argv[2] and argv[3] have the last two bytes which are different

Also removed unnecessary malloc which was also not being freed.

Should this pull request be accepted, the relevant binaries would also need to be updated

- Updated signature to match call on line 69 
- Removed unnecessary `malloc` as we're only changing pointers
- Removed call to `free` as `malloc` was removed
Added calls to `free` for `info.password` allocated by `gen_password`
- Updated signature to match call on line 71
- Removed unnecessary `malloc` as we're only changing pointers
@wrongbaud
Copy link
Owner

Just merged this - thanks for pointing this out!

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 this pull request may close these issues.

2 participants