Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Wed, 24 Oct 2012 22:16:01 +0200
From: Paul Schutte <sjpschutte@...il.com>
To: musl@...ts.openwall.com
Subject: Re: Possible file stream bug

Hi

While investigating this, I stumbled upon another bug:

#include <unistd.h>
#include <stdio.h>

int main() {
        FILE *fstream;
        int len;

        fclose(stdout);

        len=printf("test this\n");

        fprintf(stderr,"%d\n",len);

        return 0;
}

Musl's printf gives the amount of bytes no matter whether it succeeds or
fails.
It should return a negative value in case of failure.

Regards
Paul

On Wed, Oct 24, 2012 at 9:36 PM, Paul Schutte <sjpschutte@...il.com> wrote:

> Hi
>
> I compiled and linked libwebserver-0.5.3 against musl.
>
> It would just strangely break halfway through a request. After hours of
> searching, I found the problem.
>
> I can demonstrate it with the following code:
>
> #include <unistd.h>
> #include <stdio.h>
>
> int main() {
>     FILE *fstream;
>
>     fclose(stdout);
>
>     fstream=freopen("/dev/tty","w",stdout);
>
>     if (fstream==NULL) {
>         fprintf(stderr,"freopen failed\n");
>     }
>
>     printf("test this\n");
>
>
>     return 0;
> }
>
> This snippet works fine when using glibc.
>
> Regards
> Paul
>
>
>

Content of type "text/html" skipped

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.