Prevent shell execution also in the 'r ! dobad' case, pointed out by

Martijn van Duren, thanks!

XXX: pullup-8
This commit is contained in:
christos 2018-06-18 14:56:24 +00:00
parent 0c9686a5ea
commit 8adf28c539
1 changed files with 5 additions and 8 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: main.c,v 1.29 2018/04/05 18:44:57 christos Exp $ */ /* $NetBSD: main.c,v 1.30 2018/06/18 14:56:24 christos Exp $ */
/* main.c: This file contains the main control and user-interface routines /* main.c: This file contains the main control and user-interface routines
for the ed line editor. */ for the ed line editor. */
@ -39,7 +39,7 @@ __COPYRIGHT(
#if 0 #if 0
static char *rcsid = "@(#)main.c,v 1.1 1994/02/01 00:34:42 alm Exp"; static char *rcsid = "@(#)main.c,v 1.1 1994/02/01 00:34:42 alm Exp";
#else #else
__RCSID("$NetBSD: main.c,v 1.29 2018/04/05 18:44:57 christos Exp $"); __RCSID("$NetBSD: main.c,v 1.30 2018/06/18 14:56:24 christos Exp $");
#endif #endif
#endif /* not lint */ #endif /* not lint */
@ -865,14 +865,11 @@ exec_command(void)
printf("%ld\n", addr_cnt ? second_addr : addr_last); printf("%ld\n", addr_cnt ? second_addr : addr_last);
break; break;
case '!': case '!':
if (secure) {
seterrmsg("'!' not allowed");
return ERR;
}
if (addr_cnt > 0) { if (addr_cnt > 0) {
seterrmsg("unexpected address"); seterrmsg("unexpected address");
return ERR; return ERR;
} else if ((sflags = get_shell_command()) < 0) }
if ((sflags = get_shell_command()) < 0)
return ERR; return ERR;
GET_COMMAND_SUFFIX(); GET_COMMAND_SUFFIX();
if (sflags) printf("%s\n", shcmd + 1); if (sflags) printf("%s\n", shcmd + 1);
@ -994,7 +991,7 @@ get_shell_command(void)
int i = 0; int i = 0;
int j = 0; int j = 0;
if (red) { if (red || secure) {
seterrmsg("shell access restricted"); seterrmsg("shell access restricted");
return ERR; return ERR;
} else if ((s = ibufp = get_extended_line(&j, 1)) == NULL) } else if ((s = ibufp = get_extended_line(&j, 1)) == NULL)