apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dan Ports <d...@csail.mit.edu>
Subject fd setup bug in apr_proc_create
Date Thu, 06 Oct 2011 18:38:29 GMT
Yesterday, I noticed an error which was caused by apr_proc_create
setting up file descriptors for the child process incorrectly.
Specifically, the child's stdin may fail to be connected to the pipe if
the parent's stdin is closed.

What's happening is that apr allocates a pipe in the parent, and it may
get assigned fd 0 if stdin is closed. The child doesn't account for
this case, so it proceeds to dup2(0, 0) and close(0), leaving it with
no stdin. The same could happen for stdout and stderr. The attached
patch will fix it.

The way this came up for me was using Subversion to commit to a
repository over ssh, with the commit message from stdin (i.e.
`svn ci -F -`). There, stdin gets closed once the log message is read.
Afterwards, it forks a child to run ssh, but fails with a broken pipe


Dan R. K. Ports              MIT CSAIL                http://drkp.net/

View raw message