]> git.ipfire.org Git - pakfire.git/commitdiff
arch: Cut off vendor if it has any spaces
authorMichael Tremer <michael.tremer@ipfire.org>
Tue, 18 May 2021 15:12:31 +0000 (15:12 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Tue, 18 May 2021 15:12:31 +0000 (15:12 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/libpakfire/arch.c

index f3d8922fbc35a15a6bc44740f25c4fb08ab1b8bb..e39650566ab63e269faf410e5b941ab19624d4bf 100644 (file)
@@ -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;