[erlang-bugs] Patch for illegal memory access in open_port BIF.

Matthew Dempsky matthew@REDACTED
Thu Oct 4 19:57:31 CEST 2007


The open_port BIF assumes that if a tuple is passed as the first
argument, it will have at least one element.  This causes an illegal
memory access if open_port({}, []) is called.

--- erl_bif_port.c.orig	2007-10-04 10:50:05.000000000 -0700
+++ erl_bif_port.c	2007-10-04 10:49:03.000000000 -0700
@@ -613,6 +613,10 @@
 	tp = tuple_val(name);
 	arity = *tp++;

+	if (arity == make_arityval(0)) {
+	    OPEN_PORT_ERROR(-3);
+	}
+
 	if (*tp == am_spawn) {	/* A process port */
 	    if (arity != make_arityval(2)) {
 		OPEN_PORT_ERROR(-3);



More information about the erlang-bugs mailing list