From: "Knott, Isabelle" <Isabelle.Knott@amd.com>
To: "musl@lists.openwall.com" <musl@lists.openwall.com>
Subject: [musl] [bug] Cannot fprintf/fwprintf numbers to a wmemstream
Date: Wed, 7 Sep 2022 18:53:06 +0000 [thread overview]
Message-ID: <DM4PR12MB62074B95160717EB43FFB21780419@DM4PR12MB6207.namprd12.prod.outlook.com> (raw)
[AMD Official Use Only - General]
Hello, I have found that fprintf or fwprintf fails to write numbers to wmemstreams specifically, and also incorrectly reports how many characters were actually written:
Here is some sample code that reproduces the issue
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
#include <wchar.h>
int main() {
wchar_t* buf;
size_t buf_size;
FILE* fd = open_wmemstream(&buf, &buf_size);
if(fd == 0)
{
return -1;
}
//int chars_written = fprintf(fd, "%d", 40); // this also doesn't work
int chars_written = fwprintf(fd, L"%d", 40);
fclose(fd);
printf("chars_written: %d\n", chars_written);
printf("buf_size: %ld\n", buf_size);
fwprintf(stdout, L"expected: \"%d\"\n", 40);
printf("actual: \"%ls\"\n", buf);
free(buf);
return 0;
}
with musl-gcc compiles from 1.2.3:
chars_written: 2
buf_size: 0
expected: "40"
actual: ""
with glibc 2.35, using fprintf on the wmemstream fails, but fwprintf succeeds, though it won't write to stdout for some reason:
chars_written: 2
buf_size: 2
actual: "40"
Thanks!
-Isabelle
next reply other threads:[~2022-09-07 19:03 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-07 18:53 Knott, Isabelle [this message]
2022-09-07 20:44 ` Rich Felker
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=DM4PR12MB62074B95160717EB43FFB21780419@DM4PR12MB6207.namprd12.prod.outlook.com \
--to=isabelle.knott@amd.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).