From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/8638 Path: news.gmane.org!not-for-mail From: Rich Felker Newsgroups: gmane.linux.lib.musl.general Subject: Re: open_memstream corner case Date: Thu, 8 Oct 2015 18:12:56 -0400 Message-ID: <20151008221256.GB8645@brightrain.aerifal.cx> References: <5613D23A.3010707@gmail.com> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1444342397 11239 80.91.229.3 (8 Oct 2015 22:13:17 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 8 Oct 2015 22:13:17 +0000 (UTC) To: musl@lists.openwall.com Original-X-From: musl-return-8650-gllmg-musl=m.gmane.org@lists.openwall.com Fri Oct 09 00:13:13 2015 Return-path: Envelope-to: gllmg-musl@m.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by plane.gmane.org with smtp (Exim 4.69) (envelope-from ) id 1ZkJR2-0000E7-VS for gllmg-musl@m.gmane.org; Fri, 09 Oct 2015 00:13:13 +0200 Original-Received: (qmail 20422 invoked by uid 550); 8 Oct 2015 22:13:10 -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 20398 invoked from network); 8 Oct 2015 22:13:09 -0000 Content-Disposition: inline In-Reply-To: <5613D23A.3010707@gmail.com> User-Agent: Mutt/1.5.21 (2010-09-15) Original-Sender: Rich Felker Xref: news.gmane.org gmane.linux.lib.musl.general:8638 Archived-At: On Tue, Oct 06, 2015 at 04:52:58PM +0300, Maxim Storchak wrote: > Hi, > > I discovered something strange with memstream subsystem in musl: if a > stream is opened for writing with open_memstream(3) but then closed > without writing anything, neither buffer pointer, nor buffer size gets > updated. I compared source code of glibc, uClibc and musl and discovered > that both uClibc and musl update buffer size on write, while glibc does > that on fclose or fsync, both of which is fine, according to > memstream(3) man page. While both uClibc and musl behave the same if > something is written to the buffer, they differ if no write happens. On > initialization uClibc sets buffer size to 0, and musl leaves it intact. > In case of no write it doesn't get updated and contains garbage. Here is > my test case: Thank you for the detailed report and test case. The bug should now be fixed by commit 7b9f57f207b51132f188f750161953b7baf32154. Please let me know if any problems remain or if you find other issues. Here is the commit link in case you want to apply it manually to an older version: http://git.musl-libc.org/cgit/musl/commit/?id=7b9f57f207b51132f188f750161953b7baf32154 Rich