public inbox for linux-nfs@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] cacheio: use intmax_t for formatted IO
@ 2018-12-01 18:16 Khem Raj
  2018-12-01 18:16 ` [PATCH] Do not pass null pointer to freeaddrinfo() Khem Raj
  0 siblings, 1 reply; 2+ messages in thread
From: Khem Raj @ 2018-12-01 18:16 UTC (permalink / raw)
  To: linux-nfs; +Cc: Khem Raj

time_t is not same size on x32 ABI (ILP32)

Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
 support/nfs/cacheio.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/support/nfs/cacheio.c b/support/nfs/cacheio.c
index 9dc4cf1..2086a95 100644
--- a/support/nfs/cacheio.c
+++ b/support/nfs/cacheio.c
@@ -17,6 +17,7 @@
 
 #include <nfslib.h>
 #include <stdio.h>
+#include <inttypes.h>
 #include <stdio_ext.h>
 #include <string.h>
 #include <ctype.h>
@@ -234,7 +235,7 @@ cache_flush(int force)
 	    stb.st_mtime > now)
 		stb.st_mtime = time(0);
 	
-	sprintf(stime, "%ld\n", stb.st_mtime);
+	sprintf(stime, "%jd\n", (intmax_t)stb.st_mtime);
 	for (c=0; cachelist[c]; c++) {
 		int fd;
 		sprintf(path, "/proc/net/rpc/%s/flush", cachelist[c]);
-- 
2.19.2


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [PATCH] Do not pass null pointer to freeaddrinfo()
  2018-12-01 18:16 [PATCH] cacheio: use intmax_t for formatted IO Khem Raj
@ 2018-12-01 18:16 ` Khem Raj
  0 siblings, 0 replies; 2+ messages in thread
From: Khem Raj @ 2018-12-01 18:16 UTC (permalink / raw)
  To: linux-nfs; +Cc: Khem Raj

Passing null pointer as input parameter to freeaddrinfo() is undefined
behaviour, some libcs e.g. glibc might just call free() which does
accept null pointer but other libcs e.g. musl might not and instead
cause the program to segfault. Therefore do not rely on undefined
behaviour instead make it deterministic

Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
 support/export/client.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Index: nfs-utils-2.3.2/support/export/client.c
===================================================================
--- nfs-utils-2.3.2.orig/support/export/client.c
+++ nfs-utils-2.3.2/support/export/client.c
@@ -309,7 +309,8 @@ client_lookup(char *hname, int canonical
 		init_addrlist(clp, ai);
 
 out:
-	freeaddrinfo(ai);
+	if (ai)
+		freeaddrinfo(ai);
 	return clp;
 }
 

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-12-01 18:16 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-12-01 18:16 [PATCH] cacheio: use intmax_t for formatted IO Khem Raj
2018-12-01 18:16 ` [PATCH] Do not pass null pointer to freeaddrinfo() Khem Raj

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox