From: krw Date: Thu, 12 Aug 2021 17:30:52 +0000 (+0000) Subject: Oops. Lost a 'nitems()' chunk during last commit. Don't X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=487ccbeea249d8b6d162743faf5e37a4e74b5e54;p=openbsd Oops. Lost a 'nitems()' chunk during last commit. Don't segfault on invalid edit commands. --- diff --git a/sbin/fdisk/user.c b/sbin/fdisk/user.c index 3ea302e486d..5a9c49ad7f9 100644 --- a/sbin/fdisk/user.c +++ b/sbin/fdisk/user.c @@ -1,4 +1,4 @@ -/* $OpenBSD: user.c,v 1.71 2021/08/12 12:31:16 krw Exp $ */ +/* $OpenBSD: user.c,v 1.72 2021/08/12 17:30:52 krw Exp $ */ /* * Copyright (c) 1997 Tobias Weingartner @@ -100,7 +100,7 @@ again: if (!strcmp(cmd, "?")) i = 0; - if ((cmd_table[i].cmd_name == NULL) || (letoh64(gh.gh_sig) == + if (i >= nitems(cmd_table) || (letoh64(gh.gh_sig) == GPTSIGNATURE && cmd_table[i].cmd_gpt == 0)) { printf("Invalid command '%s'. Try 'help'.\n", cmd); continue;