From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/2191 Path: news.gmane.org!not-for-mail From: Paul Schutte Newsgroups: gmane.linux.lib.musl.general Subject: Re: Possible file stream bug Date: Wed, 24 Oct 2012 22:16:01 +0200 Message-ID: References: Reply-To: musl@lists.openwall.com NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=f46d042f949268d3b504ccd3c145 X-Trace: ger.gmane.org 1351109779 3270 80.91.229.3 (24 Oct 2012 20:16:19 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 24 Oct 2012 20:16:19 +0000 (UTC) To: musl@lists.openwall.com Original-X-From: musl-return-2192-gllmg-musl=m.gmane.org@lists.openwall.com Wed Oct 24 22:16:27 2012 Return-path: Envelope-to: gllmg-musl@plane.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by plane.gmane.org with smtp (Exim 4.69) (envelope-from ) id 1TR7NF-0008Cp-R1 for gllmg-musl@plane.gmane.org; Wed, 24 Oct 2012 22:16:21 +0200 Original-Received: (qmail 10177 invoked by uid 550); 24 Oct 2012 20:16:14 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: Original-Received: (qmail 10169 invoked from network); 24 Oct 2012 20:16:13 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=+e/ktpbalq/Vp1WFLf9m9qIROAGT7qLP6XAX2ku1hSA=; b=Cq6nSqHzQtl3WdKjtiapLCTkDrrAvJ2jXppbjq9JlbimKOd1DVg0X6wwGSlNYuYrJn 4CWBRmxLvbTvYMjE3rc6IBbegAgtepRqhY5y3jVnm89nTcknb5rX4t8K6KNsOc+06ocd NFJY9H6zmfCqHQValBHp+dLbH4L9tVIKMF2Yq4cOz/WmmUKGCfa6pVkt3nWiqefhczqB SKlP50D04xPWybdlhSi+rmW385kKyQIh/hUQyfxz+YQjmSNxBr2vhC+dBZ/XtkINP677 PXJqGwGnIfBtiXhm916u0Zwo2cyiQVmAhDGOo7r5OaBrBTJR23auBy2mQi3BCTK1OR3y oqbQ== In-Reply-To: Xref: news.gmane.org gmane.linux.lib.musl.general:2191 Archived-At: --f46d042f949268d3b504ccd3c145 Content-Type: text/plain; charset=ISO-8859-1 Hi While investigating this, I stumbled upon another bug: #include #include 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 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 > #include > > 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 > > > --f46d042f949268d3b504ccd3c145 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Hi

While investigating this, I stumbled upon another bug:

#in= clude <unistd.h>
#include <stdio.h>

int main() {
= =A0=A0=A0=A0=A0=A0=A0 FILE *fstream;
=A0=A0=A0=A0=A0=A0=A0 int len;
<= br>=A0=A0=A0=A0=A0=A0=A0 fclose(stdout);

=A0=A0=A0=A0=A0=A0=A0 len=3Dprintf("test this\n");

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

=A0=A0=A0= =A0=A0=A0=A0 return 0;
}

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

Regards
Pau= l

On Wed, Oct 24, 2012 at 9:36 PM, Paul S= chutte <sjpschutte@gmail.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()= {
=A0=A0=A0 FILE *fstream;

=A0=A0=A0 fclose(stdout);

=A0= =A0=A0 fstream=3Dfreopen("/dev/tty","w",stdout);
=A0=A0=A0 if (fstream=3D=3DNULL) {
=A0=A0=A0 =A0=A0=A0 fprintf(stderr,"freopen failed\n");
=A0=A0= =A0 }

=A0=A0=A0 printf("test this\n");
=A0=A0=A0
=A0=A0=A0 return 0;
}

This snippet works fine when using glibc.=

Regards
Paul



--f46d042f949268d3b504ccd3c145--