From 3dc95902344b71c9b9eb89ab0a9d6e7706959013 Mon Sep 17 00:00:00 2001 From: Andreas Baumann Date: Tue, 14 May 2019 20:39:36 +0200 Subject: increased machine size in pacman.c by one fixed around letting machine not NUL-terminated when architecture is 'petntium4' --- src/pacman/pacman.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/pacman/pacman.c b/src/pacman/pacman.c index abb6f933..34aace6c 100644 --- a/src/pacman/pacman.c +++ b/src/pacman/pacman.c @@ -274,12 +274,15 @@ static void setuseragent(void) int len; uname(&un); - char machine[8]; - strncpy(machine, un.machine, 8); + char machine[9]; + strncpy(machine, un.machine, sizeof machine); + machine[sizeof machine-1] = '\0'; if(strcmp(machine, "i686") == 0) { __builtin_cpu_init(); - if (__builtin_cpu_supports("sse2")) - strncpy(machine, "pentium4", 8); + if (__builtin_cpu_supports("sse2")) { + strncpy(machine, "pentium4", sizeof machine); + machine[sizeof machine-1] = '\0'; + } } len = snprintf(agent, 100, "pacman/%s (%s %s) libalpm/%s", PACKAGE_VERSION, un.sysname, machine, alpm_version()); -- cgit v1.2.3