Michael Day wrote:
> Hi,
> 
> Why does xmlReadFile read from stdin if "-" is specified as a filename, 
> and is there any way to disable this behaviour?

It's fairly typical behaviour on Unix systems (may even be POSIX, not
sure). And no, there isn't.

> It seems that this will create potential bugs wherever a program passes 
> a filename to libxml2 without checking it first; if the filename is "-" 
> then libxml2 will attempt to read from stdin and the program may block 
> indefinitely.

Sure - but so would CON under windows, or /dev/stdin, or /dev/ttys7, ...
Reading input in a blocking condition is not a problem for libxml2; it's
up to the users to prevent such cases if it's important for them.
If you're using the library, you could always freopen stdin from
/dev/null (or dup fd 0, not sure if libxml2 uses the stdin FILE*) - that
would prevent libxml2 from blocking if someone passed "-" (but the other
cases listed above would still cause trouble).
Or you could filter user-supplied names and reject "-" and "/dev/*",
which should catch most cases of blocking input.

_______________________________________________
xml mailing list, project page  http://xmlsoft.org/
[email protected]
http://mail.gnome.org/mailman/listinfo/xml

Reply via email to