Module Name: src
Committed By: maya
Date: Wed Jan 17 00:22:29 UTC 2018
Modified Files:
src/tests/fs/tmpfs: h_tools.c
Log Message:
- Add inttypes.h #include for PR* macros.
- close fd when done to prevent leak.
- use correct socket length when calling bind(2).
>From Ngie Cooper in PR bin/51870
To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/tests/fs/tmpfs/h_tools.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/tests/fs/tmpfs/h_tools.c
diff -u src/tests/fs/tmpfs/h_tools.c:1.4 src/tests/fs/tmpfs/h_tools.c:1.5
--- src/tests/fs/tmpfs/h_tools.c:1.4 Sat Jun 11 18:03:17 2011
+++ src/tests/fs/tmpfs/h_tools.c Wed Jan 17 00:22:29 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: h_tools.c,v 1.4 2011/06/11 18:03:17 christos Exp $ */
+/* $NetBSD: h_tools.c,v 1.5 2018/01/17 00:22:29 maya Exp $ */
/*
* Copyright (c) 2005, 2006 The NetBSD Foundation, Inc.
@@ -45,6 +45,7 @@
#include <err.h>
#include <errno.h>
#include <fcntl.h>
+#include <inttypes.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -230,12 +231,13 @@ sockets_main(int argc, char **argv)
return EXIT_FAILURE;
}
+ memset(&addr, 0, sizeof(addr));
(void)strlcpy(addr.sun_path, argv[1], sizeof(addr.sun_path));
addr.sun_family = PF_UNIX;
-
- error = bind(fd, (struct sockaddr *)&addr, sizeof(addr));
+ error = bind(fd, (struct sockaddr *)&addr, SUN_LEN(&addr));
if (error == -1) {
warn("connect");
+ (void)close(fd);
return EXIT_FAILURE;
}