-
Notifications
You must be signed in to change notification settings - Fork 62
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
Conversation
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); |
There was a problem hiding this comment.
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_); |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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...
There was a problem hiding this 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) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
make it const char *
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.
Thanks! |
you are welcome |
sgtm
… On 29 Oct 2018, at 22:06, a1ext ***@***.***> wrote:
@a1ext commented on this pull request.
In src/disk.c <#170 (comment)>:
>
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_);
Also, I think it's better to make it impossible to build it on windows without turned on unicode support...
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub <#170 (comment)>, or mute the thread <https://github.com/notifications/unsubscribe-auth/AA3-ltM7H_nrngJ8YSXlrSdLL6hHQa06ks5up23MgaJpZM4X_EEV>.
|
Related to radareorg/cutter#589
fixed heap corruption in SDB
fixed proper project saving on windows