Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Corinna Vinschen <vinschen@redhat.com>
To: gdb-patches@sourceware.org
Subject: Re: Add system(NULL) to fileio
Date: Mon, 12 Jun 2006 12:11:00 -0000	[thread overview]
Message-ID: <20060612121124.GA19317@calimero.vinschen.de> (raw)
In-Reply-To: <4489D824.40605@codesourcery.com>

On Jun  9 21:20, Nathan Sidwell wrote:
> We noticed that system(NULL) has a special meaning.  This patch augments the
> fileio protocol to support it.
> 
> Fortunately the current protocol's LENGTH field is strlen + 1, so it can never
> legitimately be zero.  So I use that to indicate a NULL string is being passed
> -- we don't have to presume a NULL pointer is all bits zero  :)
> 
> Tested with a modified libgloss for an m68k target. ok?
> [...]

As for the actual code, since I wrote the original fileio stuff, I thought
I could have a look.

> !   if (length)
> !     {
> !       /* Request commandline using 'm' packet */
> !       cmdline = alloca (length);
> !       retlength = remote_read_bytes (ptrval, (gdb_byte *) cmdline, length);
> !       if (retlength != length)
> ! 	{
> ! 	  remote_fileio_ioerror ();
> ! 	  return;
> ! 	}
> !     }
> !   
> !   /* Check if system(3) has been explicitely allowed using the
> !      `set remote system-call-allowed 1' command.  If not, return
> !      EPERM */

Wouldn't it be better to add a short comment here explaining the !length
case, something along the lines of "A zero length indicates a NULL
argument to system(3) ... handled according to POSIX (check if shell
exists) even if the system call hasn't been allowed by the user"?

> !   if (!remote_fio_system_call_allowed)
>       {
> !       if (!length)
> ! 	remote_fileio_return_success (0);
> !       else
> ! 	remote_fileio_reply (-1, FILEIO_EPERM);
>         return;
>       }
>   
>     remote_fio_no_longjmp = 1;
>     ret = system (cmdline);
>   
> !   if (!length)
> !     remote_fileio_return_success (ret);
> !   else if (ret == -1)
>       remote_fileio_return_errno (-1);
>     else
>       remote_fileio_return_success (WEXITSTATUS (ret));

Everything else looks good to me.


Corinna

-- 
Corinna Vinschen
Cygwin Project Co-Leader
Red Hat


  parent reply	other threads:[~2006-06-12 12:11 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-06-09 20:21 Nathan Sidwell
2006-06-10  7:37 ` Eli Zaretskii
2006-06-10 11:52   ` Nathan Sidwell
2006-06-10 21:40     ` Eli Zaretskii
2006-06-12 12:11 ` Corinna Vinschen [this message]
2006-06-13  8:31   ` Nathan Sidwell
2006-06-13 13:29 ` Nathan Sidwell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20060612121124.GA19317@calimero.vinschen.de \
    --to=vinschen@redhat.com \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox