aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog.txt4
-rw-r--r--pseudo.h3
-rw-r--r--pseudo_util.c12
3 files changed, 13 insertions, 6 deletions
diff --git a/ChangeLog.txt b/ChangeLog.txt
index e93ea9e..b20096a 100644
--- a/ChangeLog.txt
+++ b/ChangeLog.txt
@@ -1,3 +1,7 @@
+2010-08-27:
+ * (seebs) fix a bug caused by memcmp with wrong length
+ * (seebs) stop hand-coding lengths of memcmp (torek was right...)
+
2010-08-26:
* (seebs) make offsets.c slightly less useless
* (seebs) don't overwrite LD_LIBRARY_PATH values that include us
diff --git a/pseudo.h b/pseudo.h
index 86fdd72..a568bca 100644
--- a/pseudo.h
+++ b/pseudo.h
@@ -159,6 +159,8 @@ extern char *pseudo_version;
#define PSEUDO_LIBDIR "lib"
#endif
+#define STARTSWITH(x, y) (!memcmp((x), (y), sizeof(y) - 1))
+
#ifndef PSEUDO_LOCALSTATEDIR
#define PSEUDO_LOCALSTATEDIR "var/pseudo"
#endif
@@ -191,3 +193,4 @@ extern char *pseudo_version;
#ifndef O_LARGEFILE
#define O_LARGEFILE 0
#endif
+
diff --git a/pseudo_util.c b/pseudo_util.c
index 6d66bd5..e2cabfe 100644
--- a/pseudo_util.c
+++ b/pseudo_util.c
@@ -624,7 +624,7 @@ pseudo_dropenvp(char * const *envp) {
j = 0;
for (i = 0; envp[i]; ++i) {
- if (!memcmp(envp[i], "LD_PRELOAD=", 11)) {
+ if (STARTSWITH(envp[i], "LD_PRELOAD=")) {
char *new_val = without_libpseudo(envp[i]);
if (!new_val) {
pseudo_diag("fatal: can't allocate new environment variable.\n");
@@ -632,7 +632,7 @@ pseudo_dropenvp(char * const *envp) {
} else {
/* don't keep an empty value; if the whole string is
* LD_PRELOAD=, we just drop it. */
- if (memcmp(new_val, "LD_PRELOAD=", 12)) {
+ if (strcmp(new_val, "LD_PRELOAD=")) {
new_envp[j++] = new_val;
}
}
@@ -725,10 +725,10 @@ pseudo_setupenvp(char * const *envp) {
free(pseudo_get_localstatedir());
for (i = 0; envp[i]; ++i) {
- if (!memcmp(envp[i], "LD_PRELOAD=", 11)) {
+ if (STARTSWITH(envp[i], "LD_PRELOAD=")) {
ld_preload = envp[i];
}
- if (!memcmp(envp[i], "LD_LIBRARY_PATH=", 11)) {
+ if (STARTSWITH(envp[i], "LD_LIBRARY_PATH=")) {
ld_library_path = envp[i];
}
++env_count;
@@ -784,8 +784,8 @@ pseudo_setupenvp(char * const *envp) {
free(libdir_path);
for (i = 0; envp[i]; ++i) {
- if (!memcmp(envp[i], "LD_PRELOAD=", 11)) continue;
- if (!memcmp(envp[i], "LD_LIBRARY_PATH=", 16)) continue;
+ if (STARTSWITH(envp[i], "LD_PRELOAD=")) continue;
+ if (STARTSWITH(envp[i], "LD_LIBRARY_PATH=")) continue;
new_envp[j++] = envp[i];
}