Comment 11 for bug 1818285

Revision history for this message
Iain Lane (laney) wrote :

* An archaic GNU extension to scanf, under which '%as', '%aS', and
  '%a[...]' meant to scan a string and allocate space for it with
  malloc, is now restricted to programs compiled in C89 or C++98 mode
  with _GNU_SOURCE defined. This extension conflicts with C99's use of
  '%a' to scan a hexadecimal floating-point number, which is now
  available to programs compiled as C99 or C++11 or higher, regardless
  of _GNU_SOURCE.

  POSIX.1-2008 includes the feature of allocating a buffer for string input
  with malloc, using the modifier letter 'm' instead. Programs using
  '%as', '%aS', or '%a[...]' with the old GNU meaning should change to
  '%ms', '%mS', or '%m[...]' respectively. Programs that wish to use
  the C99 '%a' no longer need to avoid _GNU_SOURCE.

  GCC's -Wformat warnings can detect most uses of this extension, as
  long as all functions that call vscanf, vfscanf, or vsscanf are
  annotated with __attribute__ ((format (scanf, ...))).

I should think the bug is due to this, from the glibc 2.29 update. partman-base uses '%as' a lot. Indeed the build log does show warnings along those lines:

parted_server.c: In function ‘scan_device_name’:
parted_server.c:1187:25: warning: format ‘%a’ expects argument of type ‘float *’, but argument 3 has type ‘char **’ [-Wformat=]
         if (1 != iscanf("%as", &device_name))
                         ^~~~~ ~~~~~~~~~~~~

I've locally tested a change to replace '%as' (and one occurrence of '%a[...]') with '%ms' ('%m[...]') and my first test (running 30parted directly) works.