From: Alexander Bluhm Date: Sat, 20 Aug 2016 05:57:13 +0000 (-0700) Subject: On OpenBSD 6.0 the test t/exotic_names.t fails sometimes. (RT#117072) X-Git-Tag: v0.20~2 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=f90d35bed922539c764e57e02848e9e485e14242;p=p5sagit%2FSub-Name.git On OpenBSD 6.0 the test t/exotic_names.t fails sometimes. (RT#117072) Program received signal SIGSEGV, Segmentation fault. 0x00000a9bf44b686a in XS_Sub__Name_subname (cv=Variable "cv" is not available. ) at Name.xs:72 72 else if (*s && s[-1] == '\'') { (gdb) print s $1 = 0xa9c6d507000 "test::SOME_y_STASH::SOME_y_NAME" With OpenBSD malloc randomisation the storage for nameptr is sometimes at the beginning of the page. Then accessing s[-1] with s == nameptr is fatal. --- diff --git a/Name.xs b/Name.xs index 3484085..9a4d493 100644 --- a/Name.xs +++ b/Name.xs @@ -63,13 +63,13 @@ subname(name, sub) croak("Not a subroutine reference"); for (s = nameptr; s <= nameptr + namelen; s++) { - if (*s == ':' && s[-1] == ':') { + if (s > nameptr && *s == ':' && s[-1] == ':') { end = s - 1; begin = ++s; if (seen_quote) need_subst++; } - else if (*s && s[-1] == '\'') { + else if (s > nameptr && *s != '\0' && s[-1] == '\'') { end = s - 1; begin = s; if (seen_quote++)