shithub: plan9front

Download patch

ref: 4a83ce37c649dbcfb5a87c022aad626226904363
parent: 9e1d26893f8a92c32f3486883c46e8cdfff03e98
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Mon Mar 29 11:13:50 EDT 2021

libsunrpc: work around arm64 compiler bug in sunStringUnpack()

The sunStringUnpack() routine was miscompiled by 7c, as
pointer arithmetic is done in 64 bit but the constant -1
offset got expended to a unsigned 32 bit integer.

--- a/sys/src/libsunrpc/rpc.c	Tue Mar 23 19:33:32 2021
+++ b/sys/src/libsunrpc/rpc.c	Mon Mar 29 11:13:50 2021
@@ -428,8 +428,9 @@
 		goto Err;
 	/* slide string down over length to make room for NUL */
 	memmove(dat-1, dat, n);
-	dat[-1+n] = 0;
-	*s = (char*)(dat-1);
+	dat--;
+	dat[n] = 0;
+	*s = (char*)dat;
 	return 0;
 Err:
 	return -1;