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

Windows&Unicode fix, fixed heap corruption #170

Merged
merged 3 commits into from
Oct 29, 2018

Conversation

a1ext
Copy link
Contributor

@a1ext a1ext commented Oct 29, 2018

Related to radareorg/cutter#589
fixed heap corruption in SDB
fixed proper project saving on windows

fixed heap corruption in SDB
fixed proper project saving on windows
src/disk.c Outdated
@@ -120,7 +105,13 @@ SDB_API bool sdb_disk_create(Sdb* s) {
if (s->fdump != -1) {
close (s->fdump);
}
#if __SDB_WINDOWS__ && UNICODE
wchar_t *wstr = r_sys_conv_utf8_to_utf16 (str);
s->fdump = _wopen (wstr, O_BINARY | O_RDWR | O_CREAT | O_TRUNC, SDB_MODE);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

check for wstr


static bool r_sys_mkdir(char *path) {
LPTSTR path_ = r_sys_conv_utf8_to_utf16 (path);
bool ret = CreateDirectory (path_, NULL);

free (path);
free (path_);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

uhm, i think this function should be const char *path, and as long as the behaviour has changed, review the rest of the uses.. i did a quick view and seems like it's fine because the non-windows cases the string is still owned by the caller. Also, his non-processed string is saved in s->ndump, so we can probably just return the re-encoded string to save it in ndump and avoid to call r_sys_conv_utf8... again in sdb_disk_finish(). but this change can be probably done later in a separate pr

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this will require to make ndump of wchar_t * type... which will require to put mess of #if/#else in sdb.h

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, I think it's better to make it impossible to build it on windows without turned on unicode support...

Copy link
Collaborator

@radare radare left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.

src/disk.c Outdated
}

#define r_sys_conv_utf8_to_utf16(buf) r_str_mb_to_wc (buf)
#define r_sys_conv_utf8_to_utf16(buf) r_utf8_to_utf16_l ((buf), -1)

static bool r_sys_mkdir(char *path) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

make it const char *

Copy link
Collaborator

@radare radare left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.

@radare radare merged commit f06be61 into radareorg:master Oct 29, 2018
@radare
Copy link
Collaborator

radare commented Oct 29, 2018

Thanks!

@a1ext
Copy link
Contributor Author

a1ext commented Oct 29, 2018

you are welcome

@radare
Copy link
Collaborator

radare commented Oct 29, 2018 via email

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