[Libguestfs] [PATCH nbdkit] DDRESCUE: MISC FIXES
Richard W.M. Jones
rjones at redhat.com
Fri May 22 20:09:10 UTC 2020
On Fri, May 22, 2020 at 03:05:50PM -0500, Eric Blake wrote:
> On 5/22/20 2:53 PM, Richard W.M. Jones wrote:
> >Use vector type to store map ranges.
> >
> >Test filenames unique.
> >
> >Remove some unused variables.
> >
> >Break up long lines.
> >---
>
> >@@ -95,7 +95,8 @@ parse_mapfile (const char *filename)
> > continue;
> > }
> >- if (sscanf (line, "%" SCNi64 "\t%" SCNi64 "\t%c", &offset, &length, &status) == 3) {
> >+ if (sscanf (line, "%" SCNi64 "\t%" SCNi64 "\t%c",
> >+ &offset, &length, &status) == 3) {
>
> sscanf() cannot detect integer overflow. If you care about
> detecting overflow, you'll have to rewrite this into an open-coded
> loop using things like nbdkit_parse_size().
In the rest of nbdkit I've rewritten the easy sscanf cases and left
the difficult ones. The above would probably count as a difficult
case since you'd have to split up the string etc.
Really would be nice if POSIX/ISO could fix this, hint hint!
Rich.
--
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
Fedora Windows cross-compiler. Compile Windows programs, test, and
build Windows installers. Over 100 libraries supported.
http://fedoraproject.org/wiki/MinGW
More information about the Libguestfs
mailing list