inspect: os-release: fix single-number version parsing (RHBZ#1321620)

Use the proper length modifier for asprintf, instead of a padding
modifier.  This fixes the parsing of versions in VERSION_ID which are a
single number (i.e. "X" and not "X.Y", etc).

Bug introduced with commit 32d19e3289, but
uncovered recently with the switch away from VLAs, i.e.
commit 07c496c53c.
This commit is contained in:
Pino Toscano
2016-03-30 15:49:16 +02:00
parent 88d5186eb4
commit ca4516d94c

View File

@@ -232,7 +232,7 @@ parse_os_release (guestfs_h *g, struct inspect_fs *fs, const char *filename)
return -1;
} else {
CLEANUP_FREE char *buf =
safe_asprintf (g, "%*s", (int) value_len, value);
safe_asprintf (g, "%.*s", (int) value_len, value);
major_version = guestfs_int_parse_unsigned_int (g, buf);
/* Handle cases where VERSION_ID is not a number. */
if (major_version != -1)