path: root/com32/lib/sys/module/common.c
diff options
authorMatt Fleming <matt.fleming@intel.com>2012-03-01 17:23:57 +0000
committerMatt Fleming <matt.fleming@intel.com>2012-03-23 16:56:15 +0000
commit6b28c0cfec3ecc43c9718fafbfd19297c3768701 (patch)
tree12f4f04c94c86cdb6d05dcb8b1128f7bf915bad8 /com32/lib/sys/module/common.c
parent3a316db137afe3b4c9d7f04fcf47921f509ef36c (diff)
elflink: Don't use strcmp on a non-NUL terminated string
The syslinux implementation of strcmp() only checks for NUL in the first argument and will use any NULs in the second argument for comparison with the corresponding character in the first string. This caused problems because at the time strcmp() is called 'path' isn't NUL-terminated. Since we're only checking the first character of 'path' just code it explicitly. This bug caused some modules not to load when resolving module dependencies via the ELF DT_NEEDED field because the "." in the PATH lookup code wouldn't be expanded to the current working directory. For example, instead of expanding to "/foo/bar" if /foo was the cwd, the path would be ".bar". Signed-off-by: Matt Fleming <matt.fleming@intel.com>
Diffstat (limited to 'com32/lib/sys/module/common.c')
1 files changed, 1 insertions, 1 deletions
diff --git a/com32/lib/sys/module/common.c b/com32/lib/sys/module/common.c
index b22e9c8a..e26163f1 100644
--- a/com32/lib/sys/module/common.c
+++ b/com32/lib/sys/module/common.c
@@ -74,7 +74,7 @@ again:
if (*p == ':')
- if (!strcmp(path, ".")) {
+ if (path[0] == '.' && i == 1) {
if (!core_getcwd(path, sizeof(path))) {
DBG_PRINT("Could not get cwd\n");
return NULL;