Skip to contentSkip to conversation

cacheio: use intmax_t for formatted IO

PATCH New Khem Raj 1 participant 2 messages Dec 1, 2018

Subsystems (2)
lore
Share & tools
lore

Khem Raj

author
#0 lore raw

PATCH 1/1 cacheio: use intmax_t for formatted IO

time_t is not same size on x32 ABI (ILP32)

---
 support/nfs/cacheio.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
support/nfs/cacheio.c +2 -1
index 9dc4cf1..2086a95 100644
@@ -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]);
Signature · 1 line
2.19.2
author
#1 lore raw

PATCH 1/1 Do not pass null pointer to freeaddrinfo()

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

---
 support/export/client.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
support/export/client.c +2 -1
Index: 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;
 }