Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
99538272
Commit
99538272
authored
Aug 11, 2009
by
Alexandre Julliard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
libwine: Ignore libraries that are of the wrong 32/64 class.
parent
c9cea6f2
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
44 additions
and
2 deletions
+44
-2
loader.c
libs/wine/loader.c
+44
-2
No files found.
libs/wine/loader.c
View file @
99538272
...
@@ -147,12 +147,54 @@ static void build_dll_path(void)
...
@@ -147,12 +147,54 @@ static void build_dll_path(void)
}
}
}
}
/* check if the library is the correct architecture */
/* only returns false for a valid library of the wrong arch */
static
int
check_library_arch
(
int
fd
)
{
#ifdef __APPLE__
struct
/* Mach-O header */
{
unsigned
int
magic
;
unsigned
int
cputype
;
}
header
;
if
(
read
(
fd
,
&
header
,
sizeof
(
header
)
)
!=
sizeof
(
header
))
return
1
;
if
(
header
.
magic
!=
0xfeedface
)
return
1
;
if
(
sizeof
(
void
*
)
==
sizeof
(
int
))
return
!
(
header
.
cputype
>>
24
);
else
return
(
header
.
cputype
>>
24
)
==
1
;
/* CPU_ARCH_ABI64 */
#else
struct
/* ELF header */
{
unsigned
char
magic
[
4
];
unsigned
char
class
;
unsigned
char
data
;
unsigned
char
version
;
}
header
;
if
(
read
(
fd
,
&
header
,
sizeof
(
header
)
)
!=
sizeof
(
header
))
return
1
;
if
(
memcmp
(
header
.
magic
,
"
\177
ELF"
,
4
))
return
1
;
if
(
header
.
version
!=
1
/* EV_CURRENT */
)
return
1
;
#ifdef WORDS_BIGENDIAN
if
(
header
.
data
!=
2
/* ELFDATA2MSB */
)
return
1
;
#else
if
(
header
.
data
!=
1
/* ELFDATA2LSB */
)
return
1
;
#endif
if
(
sizeof
(
void
*
)
==
sizeof
(
int
))
return
header
.
class
==
1
;
/* ELFCLASS32 */
else
return
header
.
class
==
2
;
/* ELFCLASS64 */
#endif
}
/* check if a given file can be opened */
/* check if a given file can be opened */
static
inline
int
file_exists
(
const
char
*
name
)
static
inline
int
file_exists
(
const
char
*
name
)
{
{
int
ret
=
0
;
int
fd
=
open
(
name
,
O_RDONLY
);
int
fd
=
open
(
name
,
O_RDONLY
);
if
(
fd
!=
-
1
)
close
(
fd
);
if
(
fd
!=
-
1
)
return
(
fd
!=
-
1
);
{
ret
=
check_library_arch
(
fd
);
close
(
fd
);
}
return
ret
;
}
}
static
inline
char
*
prepend
(
char
*
buffer
,
const
char
*
str
,
size_t
len
)
static
inline
char
*
prepend
(
char
*
buffer
,
const
char
*
str
,
size_t
len
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment