[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]
Re: [xml] Why does "-" read from stdin?
- From: Tim Van Holder <tim vanholder anubex com>
- To: Michael Day <mikeday yeslogic com>
- Cc: xml gnome org
- Subject: Re: [xml] Why does "-" read from stdin?
- Date: Fri, 02 Feb 2007 08:16:35 +0100
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.
[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]