public inbox for glibc-bugs@sourceware.org help / color / mirror / Atom feed
From: "fweimer at redhat dot com" <sourceware-bugzilla@sourceware.org> To: glibc-bugs@sourceware.org Subject: [Bug stdio/30039] New: __vsprintf_internal does not handle unespecified buffer length in fortify mode Date: Tue, 24 Jan 2023 09:44:56 +0000 [thread overview] Message-ID: <bug-30039-131@http.sourceware.org/bugzilla/> (raw) https://sourceware.org/bugzilla/show_bug.cgi?id=30039 Bug ID: 30039 Summary: __vsprintf_internal does not handle unespecified buffer length in fortify mode Product: glibc Version: 2.37 Status: NEW Severity: normal Priority: P1 Component: stdio Assignee: unassigned at sourceware dot org Reporter: fweimer at redhat dot com Target Milestone: --- From libio/iovsprintf.c: /* When called from fortified sprintf/vsprintf, erase the destination buffer and try to detect overflows. When called from regular sprintf/vsprintf, do not erase the destination buffer, because known user code relies on this behavior (even though its undefined by ISO C), nor try to detect overflows. */ if ((mode_flags & PRINTF_CHK) != 0) { string[0] = '\0'; __printf_buffer_init (&buf, string, maxlen, __printf_buffer_mode_sprintf_chk); } else { __printf_buffer_init (&buf, string, 0, __printf_buffer_mode_sprintf); buf.write_end = (char *) ~(uintptr_t) 0; /* End of address space. */ } However, in some cases, this code is called for an inline expansion of sprintf where the buffer size is not known and maxlen == -1. This makes buf->write_end == buf->write_ptr - 1 (so end before active write position). This causes an assertion failure in __printf_buffer_as_file_commit: Fatal glibc error: printf_buffer_as_file.c:31 (__printf_buffer_as_file_commit): assertion failed: file->stream._IO_write_ptr <= file->next->write_end I believe the assertion is not unreasonable, so I think we need to fix the buffer setup. -- You are receiving this mail because: You are on the CC list for the bug.
next reply other threads:[~2023-01-24 9:44 UTC|newest] Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top 2023-01-24 9:44 fweimer at redhat dot com [this message] 2023-01-24 9:45 ` [Bug stdio/30039] " fweimer at redhat dot com 2023-01-24 9:46 ` [Bug stdio/30039] __vsprintf_internal does not handle unspecified " fweimer at redhat dot com 2023-01-24 11:33 ` fweimer at redhat dot com 2023-01-25 10:19 ` fweimer at redhat dot com
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=bug-30039-131@http.sourceware.org/bugzilla/ \ --to=sourceware-bugzilla@sourceware.org \ --cc=glibc-bugs@sourceware.org \ /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: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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 read-only IMAP folder(s) and NNTP newsgroup(s).