1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-01-25 01:02:24 +00:00

Suppress strncpy truncation warnings with GCC 8 and later.

These warnings are bogus as the code is correct so we suppress them in
the places they occur.
This commit is contained in:
Jonathan Liu 2018-09-26 23:20:25 +10:00 committed by Simon Tatham
parent 822d2fd4c3
commit b5c840431a
2 changed files with 14 additions and 0 deletions

View File

@ -1678,7 +1678,14 @@ Socket new_unix_listener(SockAddr listenaddr, Plug plug)
memset(&u, '\0', sizeof(u));
u.su.sun_family = AF_UNIX;
#if __GNUC__ >= 8
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Wstringop-truncation"
#endif // __GNUC__ >= 8
strncpy(u.su.sun_path, listenaddr->hostname, sizeof(u.su.sun_path)-1);
#if __GNUC__ >= 8
# pragma GCC diagnostic pop
#endif // __GNUC__ >= 8
addr = &u;
addrlen = sizeof(u.su);

View File

@ -193,10 +193,17 @@ static void setup_utmp(char *ttyname, char *location)
memset(&utmp_entry, 0, sizeof(utmp_entry));
utmp_entry.ut_type = USER_PROCESS;
utmp_entry.ut_pid = getpid();
#if __GNUC__ >= 8
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Wstringop-truncation"
#endif // __GNUC__ >= 8
strncpy(utmp_entry.ut_line, ttyname+5, lenof(utmp_entry.ut_line));
strncpy(utmp_entry.ut_id, ttyname+8, lenof(utmp_entry.ut_id));
strncpy(utmp_entry.ut_user, pw->pw_name, lenof(utmp_entry.ut_user));
strncpy(utmp_entry.ut_host, location, lenof(utmp_entry.ut_host));
#if __GNUC__ >= 8
# pragma GCC diagnostic pop
#endif // __GNUC__ >= 8
/*
* Apparently there are some architectures where (struct
* utmpx).ut_tv is not essentially struct timeval (e.g. Linux