]> git.lizzy.rs Git - plan9front.git/commitdiff
libsunrpc: work around arm64 compiler bug in sunStringUnpack()
authorcinap_lenrek <cinap_lenrek@felloff.net>
Mon, 29 Mar 2021 15:13:50 +0000 (17:13 +0200)
committercinap_lenrek <cinap_lenrek@felloff.net>
Mon, 29 Mar 2021 15:13:50 +0000 (17:13 +0200)
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.

sys/src/libsunrpc/rpc.c

index 657e04233ac222d04f3addd71eb2c5f346712c60..ee075c57c01e1167a1edf443b84916dabd182c63 100644 (file)
@@ -428,8 +428,9 @@ sunStringUnpack(uchar *a, uchar *ea, uchar **pa, char **s, u32int max)
                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;