Fix issue with extension check - #1
Open
klezVirus wants to merge 1 commit into
Open
Conversation
Hi man, the syscall version was not working because the file check against the binary was not working when compiled with MSVC. Indeed, when MSVC is used, the unistd function strcasecmp is replaced by stricmp. However, completely unexpectedely, while `strcasecmp` return 0 when the two strings are equal, the custom implementation `stricmp` return 0 when they are different. Indeed, following through the definition in `donut.h`:
```
#if defined(_MSC_VER)
#pragma comment(lib, "advapi32.lib")
#pragma comment(lib, "user32.lib")
#define strcasecmp stricmp
```
And if we go and ivestigate in in `clib.c`, we can see that the `stricmp` implementation is:
```
int stricmp(const char *str1, const char *str2) {
while (*str1 && *str2) {
if ((*str1 | 0x20) != (*str2 | 0x20)) {
return 0;
}
str1++; str2++;
}
return *str2 == 0;
}
```
Which evidentely return 0 if the two strings are different.
Author
|
This is just a workaround for MSVC, actually. I think it would be better to change the |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hi man, the syscall version was not working because the file check against the binary was not working when compiled with MSVC. Indeed, when MSVC is used, the unistd function strcasecmp is replaced by stricmp. However, completely unexpectedely, while
strcasecmpreturn 0 when the two strings are equal, the custom implementationstricmpreturn 0 when they are different. Indeed, following through the definition indonut.h:And if we go and ivestigate in in
clib.c, we can see that thestricmpimplementation is:Which evidentely return 0 if the two strings are different.