[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

r19004

From: Peter N. Lundblad <peter_at_famlundblad.se>
Date: 2006-03-24 21:25:36 CET

> Index: subversion/libsvn_repos/hooks.c
> ===================================================================
> --- subversion/libsvn_repos/hooks.c (revision 19003)
> +++ subversion/libsvn_repos/hooks.c (revision 19004)
[...]
> +{
> + const char *script_stderr_utf8 = "";
> + const char **native_args;
> + char buffer[20];

This seems like a rather small buffer size.

> + /* Allocate memory for the native_args string array plus one for
> + * the ending null element. */
> + native_args = apr_palloc(pool, sizeof(char *) * args_arr_size + 1);
                                    ^ ^
Missing parens. Above is interpreted as (sizeof(char*) * args_arr_size) + 1.

> + if (child_pid == -1)
> + {
> + return svn_error_createf(SVN_ERR_EXTERNAL_PROGRAM, NULL,
> + "Error spawning process for hook script '%s'",

You're missing _() marks for translation here and in other places, but
if your port doesn't use gettext, then you're just doing us
translators a favour:-)

> + cmd);
> + }
> +
> + /* If there is "APR stdin", read it and then write it to the hook's
> + * stdin pipe. */
> + if (stdin_handle)
> + {
> + while (1)
> + {
> + apr_size_t bytes_read = sizeof(buffer);
> + int wc;
> + svn_error_t *err = svn_io_file_read(stdin_handle, buffer,
> + &bytes_read, pool);
> + if (err && APR_STATUS_IS_EOF(err->apr_err))
> + break;
> +
> + if (err)
> + return svn_error_createf(SVN_ERR_EXTERNAL_PROGRAM, NULL,
> + "Error piping stdin to hook "
> + "script '%s'", cmd);
> +
> + wc = write(stdin_pipe[1], buffer, bytes_read);
> + if (wc == -1)
> + return svn_error_createf(SVN_ERR_EXTERNAL_PROGRAM, NULL,
> + "Error piping stdin to hook "
> + "script '%s'", cmd);
> + }
> +
> + /* Close the write end of the stdin pipe. */
> + if (close(stdin_pipe[1]) == -1)
> + return svn_error_createf(SVN_ERR_EXTERNAL_PROGRAM, NULL,
> + "Error closing write end of stdin pipe "
> + "to hook script '%s'", cmd);
> + }
> +

This is a deadlock if the stderr pipe fills up while you're writing to
the stdin of the hook script. You need to use poll/select to
read/write simultaneously.

Thanks,
//Peter

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Fri Mar 24 21:26:06 2006

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.