git: 6d78f3a6310d - stable/13 - mail: add volatile in grabh()

From: Mark Johnston <markj_at_FreeBSD.org>
Date: Fri, 19 Jan 2024 14:27:00 UTC
The branch stable/13 has been updated by markj:

URL: https://cgit.FreeBSD.org/src/commit/?id=6d78f3a6310d0f873a8515541e6fbf62ef7237d6

commit 6d78f3a6310d0f873a8515541e6fbf62ef7237d6
Author:     Lexi Winter <lexi@le-Fay.ORG>
AuthorDate: 2024-01-04 22:34:58 +0000
Commit:     Mark Johnston <markj@FreeBSD.org>
CommitDate: 2024-01-19 14:26:53 +0000

    mail: add volatile in grabh()
    
    setjmp() requires that any stack variables modified between the setjmp
    call and the longjmp() must be volatile.  This means that 'saveint' in
    grabh() must be volatile, since it's modified after the setjmp().
    Otherwise, the signal handler is not properly restored, resulting in a
    crash (SIGBUS) if ^C is typed twice while composing.
    
    PR:             276119
    Reported by:    Christopher Davidson <christopher.davidson@gmail.com>
    MFC after:      2 weeks
    Pull Request:   https://github.com/freebsd/freebsd-src/pull/993
    
    (cherry picked from commit 6c951b37170f1fb2ae8b4827070743e61b6eaed2)
---
 usr.bin/mail/tty.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/usr.bin/mail/tty.c b/usr.bin/mail/tty.c
index 62f42fc43e5d..f7e2aa148dc2 100644
--- a/usr.bin/mail/tty.c
+++ b/usr.bin/mail/tty.c
@@ -60,7 +60,7 @@ int
 grabh(struct header *hp, int gflags)
 {
 	struct termios ttybuf;
-	sig_t saveint;
+	volatile sig_t saveint;
 	sig_t savetstp;
 	sig_t savettou;
 	sig_t savettin;