Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <87tu6jt3jy.fsf@oldenburg.str.redhat.com>
Date: Thu, 11 Aug 2022 13:36:33 +0200
From: Florian Weimer <fweimer@...hat.com>
To: "Buchholz, Robert" <robert.buchholz@...e.com>
Cc: "musl@...ts.openwall.com" <musl@...ts.openwall.com>
Subject: Re: Bug: ftell() after fopen(..., "ab") returns 0 unless an
 explicit fseek() is used first

* Robert Buchholz:

> On my Alpine/MUSL setup this prints "0 6" while on Ubuntu 22.04 with
> glibc it prints "3 6" - which I'm assuming is the expected output.

Both behaviors are acceptable.  C11 (7.21.3p1) says this:

| If a file can support positioning requests (such as a disk file, as
| opposed to a terminal), then a file position indicator associated with
| the stream is positioned at the start (character number zero) of the
| file, unless the file is opened with append mode in which case it is
| implementation-defined whether the file position indicator is initially
| positioned at the beginning or the end of the file.

musl is likely not the only libc with this type of behavior, given that
it's explicitly allowed by the standard.

Thanks,
Florian

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.