Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID:
 <HE1PR04MB30817A979774EB8803BE4B0490649@HE1PR04MB3081.eurprd04.prod.outlook.com>
Date: Thu, 11 Aug 2022 11:14:09 +0000
From: "Buchholz, Robert" <robert.buchholz@...e.com>
To: "musl@...ts.openwall.com" <musl@...ts.openwall.com>
Subject: Bug: ftell() after fopen(..., "ab") returns 0 unless an explicit
 fseek() is used first

I'm running Alpine Linux with MUSL as its standard library within a Docker container based on the official openjdk:16-jdk-alpine3.13 Alpine image.

I've used the following minimal test case:
========
#include <stdio.h>

int main()
{
  FILE* f = fopen("foo", "wb");
  fwrite("42", 3, 1, f);
  fclose(f);

  f = fopen("foo", "ab");
  printf("%d ", (int)ftell(f));
  fwrite("42", 3, 1, f);
  fseek(f, 0, SEEK_END);
  printf("%d\n", (int)ftell(f));
}
=======
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. So, with MUSL the second fwrite() correctly appends to the existing file, but ftell() nevertheless reports that the initial position within the file after opening it for appending is 0 and not 3.

My GCC version is "gcc (Alpine 10.2.1_pre1) 10.2.1 20201203", ldd confirms that the compiled output is linked only against "/lib/ld-musl-x86_64.so.1" and not against glibc.

I'm not subscribed to the MUSL mailing list, please CC me on replies.

Best Regards,
Robert Buchholz

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.