From cb20b2cd727c892756ff3f144ebf92feb5590562 Mon Sep 17 00:00:00 2001 From: Herbert Xu Date: Tue, 6 Jul 2010 17:40:53 +0800 Subject: [VAR] Fix loss of variables when hash collides Brian Koropoff reported that the new var patches broke the following script: #!/bin/dash GDM_LANG="bar" OPTION="foo" unset GDM_LANG # OPTION has mysteriously become unset echo "$OPTION" He correctly diagnosed this as a result of removing all variables in the hash chain preceding the one that should be removed in setvareq. He also provided a patch to fix this. This patch is based on his but without keeping the original vpp. As a result, we now store new variables at the end of the hash chain instead of the beginning. To make this work, setvareq/setvar now returns the vp pointer modified. In case they're used to unset a variable the pointer returned is undefined. This is because mklocal needs it and used to get it by assuming that the new variable always appear at the beginning of the chain. Signed-off-by: Herbert Xu --- src/var.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/var.h') diff --git a/src/var.h b/src/var.h index 7e7e505..7aa051f 100644 --- a/src/var.h +++ b/src/var.h @@ -128,9 +128,9 @@ extern const char defpathvar[]; #define mpathset() ((vmpath.flags & VUNSET) == 0) void initvar(void); -void setvar(const char *, const char *, int); +struct var *setvar(const char *name, const char *val, int flags); intmax_t setvarint(const char *, intmax_t, int); -void setvareq(char *, int); +struct var *setvareq(char *s, int flags); struct strlist; void listsetvar(struct strlist *, int); char *lookupvar(const char *); -- cgit 1.4.1