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> Signed-off-by: Allan McRae <allan@archlinux.org>
This commit is contained in:
parent
a2b776f6c9
commit
63087c31b5
1 changed files with 6 additions and 1 deletions
|
@ -271,10 +271,15 @@ static void setuseragent(void)
|
||||||
{
|
{
|
||||||
char agent[101];
|
char agent[101];
|
||||||
struct utsname un;
|
struct utsname un;
|
||||||
|
int len;
|
||||||
|
|
||||||
uname(&un);
|
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());
|
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);
|
setenv("HTTP_USER_AGENT", agent, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue