Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/ddb ddb: guard invocation of db_cmd_on_enter properly.



details:   https://anonhg.NetBSD.org/src/rev/c86ac07ba0ba
branches:  trunk
changeset: 365720:c86ac07ba0ba
user:      uwe <uwe%NetBSD.org@localhost>
date:      Wed Apr 20 19:06:35 2022 +0000

description:
ddb: guard invocation of db_cmd_on_enter properly.

db_command_loop - do not ignore the return value from setjmp used to
guard db_cmd_on_enter.  We do not want to re-execute the enter command
if it fails.  Note that "fails" includes e.g. aborting long output
from the enter command with "q" at the --db more-- prompt, which is
quite likely as the default enter command is "bt".

While here, don't even bother with the whole song and dance if the
enter command is not set.

diffstat:

 sys/ddb/db_command.c |  11 ++++++-----
 1 files changed, 6 insertions(+), 5 deletions(-)

diffs (38 lines):

diff -r 3cc22ce62671 -r c86ac07ba0ba sys/ddb/db_command.c
--- a/sys/ddb/db_command.c      Wed Apr 20 07:43:05 2022 +0000
+++ b/sys/ddb/db_command.c      Wed Apr 20 19:06:35 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: db_command.c,v 1.179 2021/10/10 18:08:12 thorpej Exp $ */
+/*     $NetBSD: db_command.c,v 1.180 2022/04/20 19:06:35 uwe Exp $     */
 
 /*
  * Copyright (c) 1996, 1997, 1998, 1999, 2002, 2009, 2019
@@ -61,7 +61,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: db_command.c,v 1.179 2021/10/10 18:08:12 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: db_command.c,v 1.180 2022/04/20 19:06:35 uwe Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_aio.h"
@@ -597,15 +597,16 @@
        /* save context for return from ddb */
        savejmp = db_recover;
        db_recover = &db_jmpbuf;
-       (void) setjmp(&db_jmpbuf);
 
        /*
         * Execute default ddb start commands only if this is the
         * first entry into DDB, in case the start commands fault
         * and we recurse into here.
         */
-       if (!savejmp)
-               db_execute_commandlist(db_cmd_on_enter);
+       if (savejmp == NULL && db_cmd_on_enter[0] != '\0') {
+               if (setjmp(&db_jmpbuf) == 0)
+                       db_execute_commandlist(db_cmd_on_enter);
+       }
 
        (void) setjmp(&db_jmpbuf);
        while (!db_cmd_loop_done) {



Home | Main Index | Thread Index | Old Index