mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Geraldo Netto <geraldonetto@gmail.com>
To: musl@lists.openwall.com
Subject: Re: fwrite() - possible division by zero
Date: Fri, 16 Feb 2018 00:58:14 -0200	[thread overview]
Message-ID: <CACepeQ-PenLZviP9vGfLOF_JXEy=+sHW7DP76zzVcu65WR02EQ@mail.gmail.com> (raw)
In-Reply-To: <20180215042042.GR1627@brightrain.aerifal.cx>

[-- Attachment #1: Type: text/plain, Size: 2415 bytes --]

Hello Guys,

Thanks for your support/assistance and my apologies for the trouble
I'm trying to learn more about musl to upgrade musl version on osv
But as you could notice, i'm completely newbie in this, oops!

Anyway, let's keep in touch


Kind Regards,

Geraldo Netto
Sapere Aude => Non dvcor, dvco
http://exdev.sf.net/

On 15 February 2018 at 02:20, Rich Felker <dalias@libc.org> wrote:

> On Wed, Feb 14, 2018 at 04:47:46PM -0500, Andrew Bell wrote:
> > On Wed, Feb 14, 2018 at 4:15 PM, Szabolcs Nagy <nsz@port70.net> wrote:
> >
> > > * Andrew Bell <andrew.bell.ia@gmail.com> [2018-02-14 15:11:34 -0500]:
> > > > On Wed, Feb 14, 2018 at 3:07 PM, Markus Wichmann <nullplan@gmx.net>
> > > wrote:
> > > >
> > > > > On Wed, Feb 14, 2018 at 02:48:14PM -0500, Andrew Bell wrote:
> > > > > > Why not early return if size == 0 and avoid the call to __fwritex
> > > > > > altogether?
> > > > > >
> > > > >
> > > > > Because it's a rare corner case? Here, there's also locking
> correctness
> > > > > to consider: fwrite() has to block until f is unlocked,
> irrespective of
> > > > > parameters. So there's no real benefit to doing an early return.
> > > > >
> > > >
> > > > But it's already being checked to set nmemb to 0.  Couldn't you just
> > > return
> > > > 0 and avoid the lock as well?
> > >
> > > the lock must not be avoided.
> > >
> > > otherwise fwrite would make progress on a FILE locked by
> > > another thread which is non-conforming.
> >
> >
> > That's not how I read this: http://port70.net/~nsz/c/c11/
> n1570.html#7.21.2p8
> >
> > "All functions that read, write, position, or query the position of a
> > stream lock the stream before accessing it.
> > They release the lock associated with the stream when the access is
> > complete."
> >
> > When size == 0, the FILE doesn't need to be accessed so no lock should be
> > necessary.
> > Perhaps language of this document has been superseded?
> >
> > But it doesn't much matter.  It just seemed to make the code more clear
> to
> > me and would have avoided the initial question.
>
> It's a POSIX requirement:
>
>         "All functions that reference (FILE *) objects, except those
>         with names ending in _unlocked, shall behave as if they use
>         flockfile() and funlockfile() internally to obtain ownership
>         of these (FILE *) objects."
>
> http://pubs.opengroup.org/onlinepubs/9699919799/functions/flockfile.html
>
> Rich
>

[-- Attachment #2: Type: text/html, Size: 4086 bytes --]

      reply	other threads:[~2018-02-16  2:58 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-14 18:24 Geraldo Netto
2018-02-14 19:39 ` Markus Wichmann
2018-02-14 19:48   ` Andrew Bell
2018-02-14 20:07     ` Markus Wichmann
2018-02-14 20:11       ` Andrew Bell
2018-02-14 21:15         ` Szabolcs Nagy
2018-02-14 21:47           ` Andrew Bell
2018-02-15  4:20             ` Rich Felker
2018-02-16  2:58               ` Geraldo Netto [this message]

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='CACepeQ-PenLZviP9vGfLOF_JXEy=+sHW7DP76zzVcu65WR02EQ@mail.gmail.com' \
    --to=geraldonetto@gmail.com \
    --cc=musl@lists.openwall.com \
    /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.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

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 NNTP newsgroup(s).