Opened 10 years ago
Closed 10 years ago
#11618 closed bug (invalid)
[libroot] readdir crashes
Reported by: | waddlesplash | Owned by: | nobody |
---|---|---|---|
Priority: | normal | Milestone: | R1/beta1 |
Component: | System/POSIX | Version: | R1/Development |
Keywords: | Cc: | ||
Blocked By: | Blocking: | ||
Platform: | All |
Description
Not sure what the cause is. This is triggered repeatedly by Mupen64 (port recipe is currently in a pull request) [main/plugin.c line 240].
Backtrace attached.
Attachments (1)
Change History (6)
by , 10 years ago
Attachment: | mupen64_nogui-371-debug-13-12-2014-23-06-22.report added |
---|
comment:1 by , 10 years ago
comment:2 by , 10 years ago
Here's the snippet of code:
DIR *dir; char cwd[1024]; struct dirent *entry; liste_plugins = (plugins*)malloc(sizeof(plugins)); liste_plugins->type = -1; liste_plugins->next = NULL; strcpy(cwd, directory); strcat(cwd, "plugins"); dir = opendir(cwd); while((entry = readdir(dir)) != NULL) {
It's known to work on at least Linux & FreeBSD. An older version of this code (that is identical as far as opendir/readdir is concerned) also works on BeOS (the binary does not run on Haiku due to different libsdl/libzs).
EDIT: directory is a const char *
that is an argument to this function.
comment:3 by , 10 years ago
And the value of directory in this case is? It should be noted that the code's not checking the result of opendir(), so if it's passing a value to it that's not correct for Haiku (i.e. a hardcoded path that may have been OK on BeOS, but has changed due to differences in Haiku's directory hierarchy), then the subsequent readdir() will indeed crash due to being passed an invalid pointer.
comment:4 by , 10 years ago
Unfortunately after doing a clean build with a printf
just before the opendir
call, I get a totally different behavior and it doesn't crash (a prior function creates the directory and then it works). Probably there was some patching mixup on my part that caused the issue.
Sorry for the noise!
Looks more likely to be an application-side bug (I.e. passing in a null pointer for one of the parameters).