making a system safe for utf-8?

David Wuertele dave-gnus@bfnet.com
Fri Sep 17 19:31:00 GMT 2004


I am building the following system:

  crosstool-0.28-rc31
  binutils-2.14
  gcc-3.3.3
  glibc-2.3.2
  linux-2.4.18

I want this system to be safe for Japanese command-line arguments, but
it is not.  I am compiling my linux-2.4.18 with NLS default codepage
UTF8.

When I telnet into the target (using a UTF-8 clean terminal) and run

  mkdir ¿·¤·¤¤¥Õ¥©¥ë¥À

... the busybox command complains about a syntax error.  The above
command is not a syntax error on my workstation, which is stock Fedora
Core 2.  I figured maybe the shell on my target is not UTF8 clean
(strange that it would matter, since UTF8 fits so cleanly into the
null-terminated-string world).

So to bypass the shell, I typed this program into a file:

  int main () { execl ("/bin/mkdir", "/tmp/¿·¤·¤¤¥Õ¥©¥ë¥À"); }

...and saved it as UTF8 text.  I compiled it using my cross compiler.
When I ran it under strace to look at the execve arguments:

  execve("/bin/mkdir", ["/tmp/\346\226\260\343\201\227\343\201\204\343\203\225\343\202\251\343\203\253\343\203\200", "A\177\377\177Q\177\377\177\\\177\377\177f\177\377\177\211\177\377\177\242\177\377\177\252\177\377\177\265\177\377\177\302\177\377\177\324\177\377\177", "\300\17\34<\360w\234\'!\340\231\3\320\377\275\'\20", umovestr: Input/output error
  0x10008030, "&\177\377\177", umovestr: Input/output error
  0x10008030, "", "\20", "&\177\377\177", "\215*", "\20"], [/* 10 vars */]) = -1 EFAULT (Bad address)

I notice that it failed.  I also notice that the second argument of
execve(), the target directory:

  "/tmp/\346\226\260\343\201\227\343\201\204\343\203\225\343\202\251\343\203\253\343\203\200"

...doesn't look very much like the character codes for the original
UTF8 directory name string.

Anyone know what is going on here?  What is different about my FC2
system that makes it work, while my crosstool target does not?

Thanks,
Dave


------
Want more information?  See the CrossGCC FAQ, http://www.objsw.com/CrossGCC/
Want to unsubscribe? Send a note to crossgcc-unsubscribe@sources.redhat.com



More information about the crossgcc mailing list