Fedora 28: Fix misc bounds check compiler warnings

Fix a bunch of (mostly) sprintf/snprintf truncation compiler
warnings that show up on Fedora 28 (GCC 8.0.1).

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Tony Hutter <hutter2@llnl.gov>
Closes #7361 
Closes #7368
This commit is contained in:
Tony Hutter
2018-04-04 10:16:47 -07:00
committed by Brian Behlendorf
parent 1724eb62de
commit 21a4f5cc86
10 changed files with 77 additions and 34 deletions
@@ -30,13 +30,16 @@ main(int argc, char *argv[])
struct sockaddr_un sock;
int fd;
char *path;
size_t size;
if (argc != 2) {
fprintf(stderr, "usage: %s /path/to/socket\n", argv[0]);
exit(1);
}
path = argv[1];
strncpy(sock.sun_path, (char *)path, sizeof (sock.sun_path));
size = sizeof (sock.sun_path);
strncpy(sock.sun_path, (char *)path, size - 1);
sock.sun_path[size - 1] = '\0';
sock.sun_family = AF_UNIX;
if ((fd = socket(AF_UNIX, SOCK_DGRAM, 0)) == -1) {
perror("socket");