fix off-by-one when printing fr_arg
authorjsg <jsg@openbsd.org>
Sat, 10 Feb 2024 07:10:13 +0000 (07:10 +0000)
committerjsg <jsg@openbsd.org>
Sat, 10 Feb 2024 07:10:13 +0000 (07:10 +0000)
found by "buffer overflow 'fp64->fr_arg' 6 <= 6" smatch error
ok miod@ claudio@

sys/arch/sparc64/sparc64/machdep.c

index 4b4466f..3e8de41 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: machdep.c,v 1.207 2023/03/08 04:43:07 guenther Exp $  */
+/*     $OpenBSD: machdep.c,v 1.208 2024/02/10 07:10:13 jsg Exp $       */
 /*     $NetBSD: machdep.c,v 1.108 2001/07/24 19:30:14 eeh Exp $ */
 
 /*-
@@ -862,7 +862,7 @@ stackdump(void)
        printf("Frame pointer is at %p\n", fp64);
        printf("Call traceback:\n");
        while (fp64 && ((u_long)fp64 >> PGSHIFT) == ((u_long)sfp >> PGSHIFT)) {
-               printf("%llx(%llx, %llx, %llx, %llx, %llx, %llx, %llx) "
+               printf("%llx(%llx, %llx, %llx, %llx, %llx, %llx) "
                    "fp = %llx\n",
                       (unsigned long long)fp64->fr_pc,
                       (unsigned long long)fp64->fr_arg[0],
@@ -871,7 +871,6 @@ stackdump(void)
                       (unsigned long long)fp64->fr_arg[3],
                       (unsigned long long)fp64->fr_arg[4],
                       (unsigned long long)fp64->fr_arg[5],     
-                      (unsigned long long)fp64->fr_arg[6],
                       (unsigned long long)fp64->fr_fp);
                fp64 = v9next_frame(fp64);
        }