public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* Buggy fmemopen
@ 2011-02-22 10:13 lumumba
  2011-02-22 16:08 ` Corinna Vinschen
  0 siblings, 1 reply; 2+ messages in thread
From: lumumba @ 2011-02-22 10:13 UTC (permalink / raw)
  To: cygwin


This function causes SIGSEGV when it's called with buf == NULL. Also it
returns EINVAL with mode != "a".
It appears it wasn't tested with buf == NULL at all:
fmemopen.c:309
  if (!buf)
    {
      /* r+/w+/a+, and no buf: file starts empty.  */
      c->buf = (char *) (c + 1);
      *(char *) buf = '\0'; // Should be c->buf?
      c->pos = c->eof = 0;
      c->append = (flags & __SAPP) != 0;
    }
This condition looks strange:
fmemopen.c:284
  if (!size || !(buf || flags & __SAPP)) // Why?
    {
      ptr->_errno = EINVAL;
      return NULL;
    }

-- 
View this message in context: http://old.nabble.com/Buggy-fmemopen-tp30984430p30984430.html
Sent from the Cygwin list mailing list archive at Nabble.com.


--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Buggy fmemopen
  2011-02-22 10:13 Buggy fmemopen lumumba
@ 2011-02-22 16:08 ` Corinna Vinschen
  0 siblings, 0 replies; 2+ messages in thread
From: Corinna Vinschen @ 2011-02-22 16:08 UTC (permalink / raw)
  To: cygwin

On Feb 22 02:13, lumumba wrote:
> 
> This function causes SIGSEGV when it's called with buf == NULL. Also it
> returns EINVAL with mode != "a".
> It appears it wasn't tested with buf == NULL at all:
> fmemopen.c:309
>   if (!buf)
>     {
>       /* r+/w+/a+, and no buf: file starts empty.  */
>       c->buf = (char *) (c + 1);
>       *(char *) buf = '\0'; // Should be c->buf?
>       c->pos = c->eof = 0;
>       c->append = (flags & __SAPP) != 0;
>     }
> This condition looks strange:
> fmemopen.c:284
>   if (!size || !(buf || flags & __SAPP)) // Why?
>     {
>       ptr->_errno = EINVAL;
>       return NULL;
>     }

This is a newlib issue in the first place, so the right mailing list
would have been newlib AT sourceware DOT org.  However, I just applied a
patch which should fix the issue.


Thanks for the report,
Corinna

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Project Co-Leader          cygwin AT cygwin DOT com
Red Hat

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2011-02-22 16:08 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-02-22 10:13 Buggy fmemopen lumumba
2011-02-22 16:08 ` Corinna Vinschen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).