Bug#349855: dash: when storing a string in a variable, special character (e.g. octal 201) is dropped
On Sat, Feb 04, 2006 at 10:47:09AM +, Gerrit Pape wrote: Hi Herbert, I can confirm this. '\201' is used as CTLESC, and removed on expansion it seems. Sorry, I don't have a patch to suggest this time. Yes this is a real bug. Here is the patch that should fix this. Cheers, -- Visit Openswan at http://www.openswan.org/ Email: Herbert Xu ~{PmVHI~} [EMAIL PROTECTED] Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt diff --git a/COPYING b/COPYING diff --git a/ChangeLog.O b/ChangeLog.O diff --git a/Makefile.am b/Makefile.am diff --git a/configure.ac b/configure.ac diff --git a/src/expand.c b/src/expand.c index dafb51f..cf64921 100644 --- a/src/expand.c +++ b/src/expand.c @@ -171,7 +171,7 @@ esclen(const char *start, const char *p) { size_t esc = 0; - while (p start *--p == CTLESC) { + while (p start *--p == (char)CTLESC) { esc++; } return esc; @@ -296,7 +296,7 @@ flag = ~EXP_TILDE; tilde: q = p; - if (*q == CTLESC (flag EXP_QWORD)) + if (*q == (char)CTLESC (flag EXP_QWORD)) q++; if (*q == '~') p = exptilde(p, q, flag); @@ -305,7 +305,7 @@ startloc = expdest - (char *)stackblock(); for (;;) { length += strcspn(p + length, reject); - c = p[length]; + c = (signed char)p[length]; if (c (!(c 0x80) || c == CTLENDARI)) { /* c == '=' || c == ':' || c == CTLENDARI */ length++; @@ -352,9 +352,9 @@ if ( !inquotes !memcmp(p, dolatstr, DOLATSTRLEN) - (p[4] == CTLQUOTEMARK || ( - p[4] == CTLENDVAR - p[5] == CTLQUOTEMARK + (p[4] == (char)CTLQUOTEMARK || ( + p[4] == (char)CTLENDVAR + p[5] == (char)CTLQUOTEMARK )) ) { p = evalvar(p + 1, flag) + 1; @@ -394,7 +394,7 @@ STATIC char * exptilde(char *startp, char *p, int flag) { - char c; + signed char c; char *name; const char *home; int quotes = flag QUOTES_ESC; @@ -503,7 +503,7 @@ do { int esc; - while (*p != CTLARI) { + while (*p != (char)CTLARI) { p--; #ifdef DEBUG if (p start) { @@ -626,7 +626,7 @@ *loc2 = c; if (match) return loc; - if (quotes *loc == CTLESC) + if (quotes *loc == (char)CTLESC) loc++; loc++; loc2++; @@ -860,7 +860,7 @@ if (subtype != VSNORMAL) { /* skip to end of alternative */ int nesting = 1; for (;;) { - if ((c = *p++) == CTLESC) + if ((c = (signed char)*p++) == CTLESC) p++; else if (c == CTLBACKQ || c == (CTLBACKQ|CTLQUOTE)) { if (varlen = 0) @@ -892,7 +892,7 @@ q = makestrspace(len * 2, expdest); do { - int c = (unsigned char)*p++; + int c = (signed char)*p++; if (c) { if ((quotes QUOTES_ESC) (syntax[c] == CCTL || syntax[c] == CBACK)) @@ -1078,7 +1078,7 @@ ifsspc = 0; while (p string + ifsp-endoff) { q = p; - if (*p == CTLESC) + if (*p == (char)CTLESC) p++; if (strchr(ifs, *p)) { if (!nulonly) @@ -1101,7 +1101,7 @@ break; } q = p; - if (*p == CTLESC) + if (*p == (char)CTLESC) p++; if (strchr(ifs, *p) == NULL ) { p = q; @@ -1658,7 +1658,7 @@ globbing = flag RMESCAPE_GLOB; notescaped = globbing; while (*p) { - if (*p == CTLQUOTEMARK) { + if (*p == (char)CTLQUOTEMARK) {
Bug#349855: dash: when storing a string in a variable, special character (e.g. octal 201) is dropped
Gerrit Pape wrote: forwarded 349855 upstream quit On Wed, Jan 25, 2006 at 06:25:29PM +0100, Torsten Scheck wrote: The character 'octal 201' is dropped when it is stored in a shell variable: $ x=`printf xxx\201` $ echo $x xxx Hi Herbert, I can confirm this. '\201' is used as CTLESC, and removed on expansion it seems. Sorry, I don't have a patch to suggest this time. Thanks for the report, Torsten. Regards, Gerrit. You're welcome. BTW: The same is true for '\210'. These two characters seem to be the only ones leading to the reported problem. $ x=`printf xxx\210` $ echo $x xxx Thanks for taking care of this, Gerrit. Cheers, Torsten -- Torsten Scheck [EMAIL PROTECTED] Jabber:[EMAIL PROTECTED] GnuPG 1024D/728E 6696 F43D D622 78F1 F481 45C0 2147 69AB DD54 software engineer:open standards/access/knowledge:enthgnusiast -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]
Bug#349855: dash: when storing a string in a variable, special character (e.g. octal 201) is dropped
forwarded 349855 upstream quit On Wed, Jan 25, 2006 at 06:25:29PM +0100, Torsten Scheck wrote: The character 'octal 201' is dropped when it is stored in a shell variable: $ x=`printf xxx\201` $ echo $x xxx Hi Herbert, I can confirm this. '\201' is used as CTLESC, and removed on expansion it seems. Sorry, I don't have a patch to suggest this time. Thanks for the report, Torsten. Regards, Gerrit. I encountered the problem, when a script failed which worked on file names containing the special character: $ touch `printf xxx\201` $ ls xxx* xxx? $ set xxx* $ ls $1 ls: xxx: No such file or directory $ ls $@ ls: xxx: No such file or directory With bash there is no problem, so I wonder if this is a dash bug. -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]
Bug#349855: dash: when storing a string in a variable, special character (e.g. octal 201) is dropped
Package: dash Version: 0.5.2-5 Severity: normal The character 'octal 201' is dropped when it is stored in a shell variable: $ x=`printf xxx\201` $ echo $x xxx I encountered the problem, when a script failed which worked on file names containing the special character: $ touch `printf xxx\201` $ ls xxx* xxx? $ set xxx* $ ls $1 ls: xxx: No such file or directory $ ls $@ ls: xxx: No such file or directory With bash there is no problem, so I wonder if this is a dash bug. -- System Information: Debian Release: 3.1 Architecture: i386 (i686) Kernel: Linux 2.4.30-vs1.2.10 Locale: LANG=C, LC_CTYPE=C (charmap=ANSI_X3.4-1968) Versions of packages dash depends on: ii libc6 2.3.2.ds1-22 GNU C Library: Shared libraries an -- debconf information: dash/sh: false -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]