[PATCH] inspect: get icon of Gentoo guests
by Pino Toscano
The icon is installed by x11-themes/gentoo-artwork, which is not
installed by default (and most probably only on "desktop"
installations), although it's the best hit so far...
---
lib/inspect-icon.c | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/lib/inspect-icon.c b/lib/inspect-icon.c
index 623591aa6..e785a2172 100644
--- a/lib/inspect-icon.c
+++ b/lib/inspect-icon.c
@@ -66,6 +66,7 @@ static char *icon_cirros (guestfs_h *g, size_t *size_r);
#endif
static char *icon_voidlinux (guestfs_h *g, size_t *size_r);
static char *icon_altlinux (guestfs_h *g, size_t *size_r);
+static char *icon_gentoo (guestfs_h *g, size_t *size_r);
#if CAN_DO_WINDOWS
static char *icon_windows (guestfs_h *g, const char *root, size_t *size_r);
#endif
@@ -166,6 +167,9 @@ guestfs_impl_inspect_get_icon (guestfs_h *g, const char *root, size_t *size_r,
else if (STREQ (distro, "altlinux")) {
r = icon_altlinux (g, &size);
}
+ else if (STREQ (distro, "gentoo")) {
+ r = icon_gentoo (g, &size);
+ }
}
else if (STREQ (type, "windows")) {
#if CAN_DO_WINDOWS
@@ -440,6 +444,15 @@ icon_altlinux (guestfs_h *g, size_t *size_r)
return get_png (g, ALTLINUX_ICON, size_r, 20480);
}
+/* Installed by x11-themes/gentoo-artwork. */
+#define GENTOO_ICON "/usr/share/icons/gentoo/48x48/gentoo.png"
+
+static char *
+icon_gentoo (guestfs_h *g, size_t *size_r)
+{
+ return get_png (g, GENTOO_ICON, size_r, 10240);
+}
+
#if CAN_DO_WINDOWS
/* Windows, as usual, has to be much more complicated and stupid than
--
2.20.1
5 years, 8 months
[PATCH nbdkit] server: utils: Fix nbdkit_parse_size to correctly handle negative values
by Mykola Ivanets
From: Nikolay Ivanets <stenavin(a)gmail.com>
nbdkit_parse_size() uses strtoumax() function to parse input strings
which states:
"if there was a leading minus sign, the negation of the result of the
conversion represented as an unsigned value, unless the original
(nonnegated) value would overflow."
Later validation doesn't catch the situation when parsed value is
within the valid range but original string passed to a function
represented negative number.
Thus nbdkit_parse_size() incorrectly parsed values in a range
[-UINT64_MAX; INT64_MIN -1] translating them into an unsigned range
of a valid values: [1; INT64_MAX].
In this patch:
1. strtoll() is used instead of strtoumax() to reflect the nature
of the 'size' which cannot be negative and isn't expected to exceed
INT64_MAX.
2. Error reporting separates cases where the string is parsed to a
negative value or parsed value overflows (greater then INT64_MAX).
Tests:
1. Some more tests were added to cover found bug.
2. Input strings where grouped into a set which lead to
valid/invalid/negative/overflow result.
3. Some strings with a leading '+' sign were added.
---
server/test-utils.c | 28 ++++++++++++++++++++++++----
server/utils.c | 19 ++++++++++++++-----
2 files changed, 38 insertions(+), 9 deletions(-)
diff --git a/server/test-utils.c b/server/test-utils.c
index f51f63a..3965fd3 100644
--- a/server/test-utils.c
+++ b/server/test-utils.c
@@ -62,14 +62,26 @@ test_nbdkit_parse_size (void)
{ "0x0", -1 },
{ "garbage", -1 },
{ "0garbage", -1 },
- { "-1", -1 },
- { "-2", -1 },
- { "9223372036854775808", -1 },
- { "-9223372036854775808", -1 },
{ "8E", -1 },
{ "8192P", -1 },
+
+ /* Strings leading to overflow */
+ { "9223372036854775808", -1 }, /* INT_MAX + 1 */
+ { "18446744073709551614", -1 }, /* UINT64_MAX - 1 */
+ { "18446744073709551615", -1 }, /* UINT64_MAX */
+ { "18446744073709551616", -1 }, /* UINT64_MAX + 1 */
{ "999999999999999999999999", -1 },
+ /* Strings representing negative values */
+ { "-1", -1 },
+ { "-2", -1 },
+ { "-9223372036854775809", -1 }, /* INT64_MIN - 1 */
+ { "-9223372036854775808", -1 }, /* INT64_MIN */
+ { "-9223372036854775807", -1 }, /* INT64_MIN + 1 */
+ { "-18446744073709551616", -1 }, /* -UINT64_MAX - 1 */
+ { "-18446744073709551615", -1 }, /* -UINT64_MAX */
+ { "-18446744073709551614", -1 }, /* -UINT64_MAX + 1 */
+
/* Strings we may want to support in the future */
{ "M", -1 },
{ "1MB", -1 },
@@ -77,8 +89,14 @@ test_nbdkit_parse_size (void)
{ "1.5M", -1 },
/* Valid strings */
+ { "-0", 0 },
{ "0", 0 },
+ { "+0", 0 },
{ " 08", 8 },
+ { "1", 1 },
+ { "+1", 1 },
+ { "1234567890", 1234567890 },
+ { "+1234567890", 1234567890 },
{ "9223372036854775807", INT64_MAX },
{ "1s", 512 },
{ "2S", 1024 },
@@ -88,12 +106,14 @@ test_nbdkit_parse_size (void)
{ "1K", 1024 },
{ "1m", 1024 * 1024 },
{ "1M", 1024 * 1024 },
+ { "+1M", 1024 * 1024 },
{ "1g", 1024 * 1024 * 1024 },
{ "1G", 1024 * 1024 * 1024 },
{ "1t", 1024LL * 1024 * 1024 * 1024 },
{ "1T", 1024LL * 1024 * 1024 * 1024 },
{ "1p", 1024LL * 1024 * 1024 * 1024 * 1024 },
{ "1P", 1024LL * 1024 * 1024 * 1024 * 1024 },
+ { "8191p", 1024LL * 1024 * 1024 * 1024 * 1024 * 8191 },
{ "1e", 1024LL * 1024 * 1024 * 1024 * 1024 * 1024 },
{ "1E", 1024LL * 1024 * 1024 * 1024 * 1024 * 1024 },
};
diff --git a/server/utils.c b/server/utils.c
index 18011fd..d711b88 100644
--- a/server/utils.c
+++ b/server/utils.c
@@ -88,21 +88,30 @@ nbdkit_absolute_path (const char *path)
int64_t
nbdkit_parse_size (const char *str)
{
- uint64_t size;
+ int64_t size;
char *end;
uint64_t scale = 1;
- /* Disk sizes cannot usefully exceed off_t (which is signed), so
- * scan unsigned, then range check later that result fits. */
+ /* Disk sizes cannot usefully exceed off_t (which is signed) and
+ * cannot be negative. */
/* XXX Should we also parse things like '1.5M'? */
/* XXX Should we allow hex? If so, hex cannot use scaling suffixes,
* because some of them are valid hex digits */
errno = 0;
- size = strtoumax (str, &end, 10);
- if (errno || str == end) {
+ size = strtoll (str, &end, 10);
+ if (str == end) {
nbdkit_error ("could not parse size string (%s)", str);
return -1;
}
+ if (size < 0) {
+ nbdkit_error ("size cannot be negative (%s)", str);
+ return -1;
+ }
+ if (errno) {
+ nbdkit_error ("size exceeds maximum value (%s)", str);
+ return -1;
+ }
+
switch (*end) {
/* No suffix */
case '\0':
--
2.17.2
5 years, 8 months
[PATCH 0/2] allow alternative guest tools directories for distributions
by Tomáš Golembiovský
First patch just fixes installing guest tools from directory that was broken.
Second patch revamps how virt-v2v chooses from which directory install guest
tools on Linux. Details in commit message.
Tomáš Golembiovský (2):
v2v: fix path to source when copying files from guest tools directory
v2v: allow alternative directories for distributions
v2v/windows_virtio.ml | 67 +++++++++++++++++++++++++------------------
1 file changed, 39 insertions(+), 28 deletions(-)
--
2.20.1
5 years, 8 months
[PATCH 0/3] inspect: icon improvements for Mageia & *SUSE
by Pino Toscano
See individual patches.
Pino Toscano (3):
inspect: bump size limit for Mageia guests
inspect: factor out find_png helper function
inspect: revamp icon extraction for *SUSE guests
lib/inspect-icon.c | 39 +++++++++++++++++++++++++--------------
1 file changed, 25 insertions(+), 14 deletions(-)
--
2.20.1
5 years, 8 months