From: Michael Tremer Date: Tue, 18 May 2021 15:12:31 +0000 (+0000) Subject: arch: Cut off vendor if it has any spaces X-Git-Tag: 0.9.28~1285^2~132 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=85cbd001d40c01e6e33f4777deea4f9ba82a7c3a;p=pakfire.git arch: Cut off vendor if it has any spaces Signed-off-by: Michael Tremer --- diff --git a/src/libpakfire/arch.c b/src/libpakfire/arch.c index f3d8922fb..e39650566 100644 --- a/src/libpakfire/arch.c +++ b/src/libpakfire/arch.c @@ -152,8 +152,20 @@ int __pakfire_arch_machine(char* buffer, size_t length, const char* arch, const if (!vendor) vendor = "unknown"; + // Create a working copy on the stack and sanitize it + char* suffix = strdupa(vendor); + if (!suffix) { + errno = ENOMEM; + return 1; + } + + // Cut off suffix if it contains spaces + char* space = strchr(suffix, ' '); + if (space) + *space = '\0'; + // Format string - int r = snprintf(buffer, length, "%s-%s-linux-gnu", arch, vendor); + int r = snprintf(buffer, length, "%s-%s-linux-gnu", arch, suffix); if (r < 0) return r;