shithub: riscv

Download patch

ref: 668318b2e69edd4aa71a21ff31731fa81dbe7095
parent: eeb96dca21dfc28afa69f3d00fa6f2cdb7e9b1b8
author: ftrvxmtrx <ftrvxmtrx@gmail.com>
date: Fri Feb 12 18:52:50 EST 2016

ip/chandial: fail with Ebadarg instead of printing memory contents

--- a/sys/src/9/ip/chandial.c
+++ b/sys/src/9/ip/chandial.c
@@ -40,7 +40,7 @@
 	ds.ctlp = ctlp;
 
 	_dial_string_parse(dest, &ds);
-	if(ds.netdir == 0)
+	if(ds.netdir == nil)
 		ds.netdir = "/net";
 
 	/* no connection server, don't translate */
@@ -109,11 +109,13 @@
 		ds->rem = ds->buf;
 	} else {
 		if(*ds->buf != '/' && *ds->buf != '#'){
-			ds->netdir = 0;
+			ds->netdir = nil;
 			ds->proto = ds->buf;
 		} else {
-			for(p2 = p; *p2 != '/'; p2--)
+			for(p2 = p; *p2 != '/' && p2 != ds->buf; p2--)
 				;
+			if(p2 == ds->buf)
+				error(Ebadarg);
 			*p2++ = 0;
 			ds->netdir = ds->buf;
 			ds->proto = p2;