[openssh-commits] [openssh] 01/01: upstream: Move up null check and simplify process_escapes.

git+noreply at mindrot.org git+noreply at mindrot.org
Mon Apr 3 18:35:50 AEST 2023


This is an automated email from the git hooks/post-receive script.

dtucker pushed a commit to branch master
in repository openssh.

commit 09d8da0849e2791b2500267cda333cd238f38754
Author: dtucker at openbsd.org <dtucker at openbsd.org>
Date:   Mon Apr 3 08:10:54 2023 +0000

    upstream: Move up null check and simplify process_escapes.
    
    Based on Coverity CID 291863 which points out we check the channel
    pointer for NULLness after dereferencing it.  Move this to the start
    of the function, and while there simplify initialization of efc a bit.
    ok djm@
    
    OpenBSD-Commit-ID: de36e5ad6fde0fe263ca134e986b9095dc59380a
---
 clientloop.c | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/clientloop.c b/clientloop.c
index baa988af..99846a97 100644
--- a/clientloop.c
+++ b/clientloop.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: clientloop.c,v 1.391 2023/03/31 04:04:15 djm Exp $ */
+/* $OpenBSD: clientloop.c,v 1.392 2023/04/03 08:10:54 dtucker Exp $ */
 /*
  * Author: Tatu Ylonen <ylo at cs.hut.fi>
  * Copyright (c) 1995 Tatu Ylonen <ylo at cs.hut.fi>, Espoo, Finland
@@ -1005,14 +1005,12 @@ process_escapes(struct ssh *ssh, Channel *c,
 	u_int i;
 	u_char ch;
 	char *s;
-	struct escape_filter_ctx *efc = c->filter_ctx == NULL ?
-	    NULL : (struct escape_filter_ctx *)c->filter_ctx;
+	struct escape_filter_ctx *efc;
 
-	if (c->filter_ctx == NULL)
+	if (c == NULL || c->filter_ctx == NULL || len <= 0)
 		return 0;
 
-	if (len <= 0)
-		return (0);
+	efc = (struct escape_filter_ctx *)c->filter_ctx;
 
 	for (i = 0; i < (u_int)len; i++) {
 		/* Get one character at a time. */
@@ -1109,7 +1107,7 @@ process_escapes(struct ssh *ssh, Channel *c,
 				continue;
 
 			case '&':
-				if (c && c->ctl_chan != -1)
+				if (c->ctl_chan != -1)
 					goto noescape;
 				/*
 				 * Detach the program (continue to serve

-- 
To stop receiving notification emails like this one, please contact
djm at mindrot.org.


More information about the openssh-commits mailing list