From: "Richard W.M. Jones via Libc-alpha" <libc-alpha@sourceware.org>
To: Eric Blake <eblake@redhat.com>
Cc: Florian Weimer <fweimer@redhat.com>,
glibc list <libc-alpha@sourceware.org>,
"libguestfs@redhat.com" <libguestfs@redhat.com>
Subject: Re: RFC: *scanf vs. overflow
Date: Sat, 23 May 2020 08:06:54 +0100 [thread overview]
Message-ID: <20200523070654.GO3888@redhat.com> (raw)
In-Reply-To: <f3e5f1dc-d8cf-4fba-fa7f-97e6e5218660@redhat.com>
The context to this is that nbdkit uses sscanf to parse simple file
formats in various places, eg:
https://github.com/libguestfs/nbdkit/blob/b23f4f53cf71326f1dba481f64f7f182c20fa3dc/plugins/data/format.c#L171-L172
https://github.com/libguestfs/nbdkit/blob/b23f4f53cf71326f1dba481f64f7f182c20fa3dc/filters/ddrescue/ddrescue.c#L98
We can only do this safely where we can prove that overflow does not
matter. In other cases we've had to change sscanf uses to strto* etc
which is much more difficult to use correctly. Just look at how much
code is required to wrap strto* functions to use them safely:
https://github.com/libguestfs/nbdkit/blob/b23f4f53cf71326f1dba481f64f7f182c20fa3dc/server/public.c#L113-L296
Rich.
--
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
virt-p2v converts physical machines to virtual machines. Boot with a
live CD or over the network (PXE) and turn machines into KVM guests.
http://libguestfs.org/virt-v2v
next prev parent reply other threads:[~2020-05-23 7:07 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-05-22 20:59 RFC: *scanf vs. overflow Eric Blake via Libc-alpha
2020-05-23 1:16 ` Rich Felker
2020-05-23 3:06 ` Paul Eggert
2020-05-23 16:11 ` Rich Felker
2020-05-23 16:28 ` Paul Eggert
2020-05-23 16:45 ` Rich Felker
2020-05-23 17:18 ` Paul Eggert
2020-05-26 9:30 ` [Libguestfs] " Richard W.M. Jones via Libc-alpha
2020-05-23 7:06 ` Richard W.M. Jones via Libc-alpha [this message]
2020-05-23 15:25 ` Paul Eggert
2020-05-23 16:21 ` 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
List information: https://www.gnu.org/software/libc/involved.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200523070654.GO3888@redhat.com \
--to=libc-alpha@sourceware.org \
--cc=eblake@redhat.com \
--cc=fweimer@redhat.com \
--cc=libguestfs@redhat.com \
--cc=rjones@redhat.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.
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).