diff options
author | Andrew Gregory <andrew.gregory.8@gmail.com> | 2017-05-11 00:38:35 +0200 |
---|---|---|
committer | Andrew Gregory <andrew.gregory.8@gmail.com> | 2017-05-11 00:50:34 +0200 |
commit | 9dd02034bf70d8503014da5cb67b43ce9b509eea (patch) | |
tree | b0d8486c9fb3a8f201e8bea47ad6a2c39daafeff | |
parent | fb8ded213d2d5791ae2c024141f56900fc7c0e88 (diff) | |
download | pacman-9dd02034bf70d8503014da5cb67b43ce9b509eea.tar.gz pacman-9dd02034bf70d8503014da5cb67b43ce9b509eea.tar.xz |
check for overflow when setting HTTP_USER_AGENT
gcc7 issues a warning about a potential overflow if left unchecked.
Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
-rw-r--r-- | src/pacman/pacman.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/pacman/pacman.c b/src/pacman/pacman.c index 605aec3e..11b7e6f0 100644 --- a/src/pacman/pacman.c +++ b/src/pacman/pacman.c @@ -271,10 +271,15 @@ static void setuseragent(void) { char agent[101]; struct utsname un; + int len; uname(&un); - snprintf(agent, 100, "pacman/%s (%s %s) libalpm/%s", + len = snprintf(agent, 100, "pacman/%s (%s %s) libalpm/%s", PACKAGE_VERSION, un.sysname, un.machine, alpm_version()); + if(len >= 100) { + pm_printf(ALPM_LOG_WARNING, _("HTTP_USER_AGENT truncated\n")); + } + setenv("HTTP_USER_AGENT", agent, 0); } |