<div dir="ltr">This change looks good.  I wonder if there are any other such places in the<div>code; I remember using that trick a few places.</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Sun, Aug 6, 2017 at 4:40 PM, Darrin B. Jewell <span dir="ltr"><<a href="mailto:dbj@mit.edu" target="_blank">dbj@mit.edu</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
I compiled dvips on a macos system running a recent clang:<br>
<br>
$ sw_vers<br>
ProductName:    Mac OS X<br>
ProductVersion: 10.12.5<br>
BuildVersion:   16F2073<br>
<br>
$ uname -a<br>
Darwin Quiteria.local 16.6.0 Darwin Kernel Version 16.6.0: Fri Apr 14 16:13:31 PDT 2017; root:xnu-3789.60.24~4/RELEASE_<wbr>X86_64 x86_64<br>
<br>
$ clang --version<br>
Apple LLVM version 8.1.0 (clang-802.0.42)<br>
Target: x86_64-apple-darwin16.6.0<br>
Thread model: posix<br>
<br>
$ xcodebuild -version<br>
Xcode 8.3.3<br>
Build version 8E3004b<br>
<br>
Unfortunately, dvips crashes with an abort in strcpy (__strcpy_chk)<br>
because the clang compiler and libraries are adding extra buffer overflow<br>
checks in the implementation of strcpy when copying into the colordat<br>
field of struct colorpage.  Since the code treats this as a variable<br>
length field by mallocing extra room in the struct, the easy fix is<br>
to use the c99 syntax for specifying variable length fields in<br>
the end of structs.<br>
<br>
The patch below fixes the problem.<br>
<br>
Thanks,<br>
Darrin<br>
<br>
*** texlive-20170524-source.dist/<wbr>texk/dvipsk/color.c    2016-11-25 10:08:46.000000000 -0800<br>
--- texlive-20170524-source/texk/<wbr>dvipsk/color.c 2017-08-06 16:31:59.000000000 -0700<br>
***************<br>
*** 37,43 ****<br>
     struct colorpage *next;<br>
     integer boploc; /* we use the bop loc as a page indicator */<br>
     char *bg;<br>
!    char colordat[2];<br>
  } *colorhash[COLORHASH];<br>
  static char *cstack, *csp, *cend, *bg;<br>
  /*<br>
--- 37,43 ----<br>
     struct colorpage *next;<br>
     integer boploc; /* we use the bop loc as a page indicator */<br>
     char *bg;<br>
!    char colordat[];<br>
  } *colorhash[COLORHASH];<br>
  static char *cstack, *csp, *cend, *bg;<br>
  /*<br>
***************<br>
*** 216,222 ****<br>
        }<br>
     } else {<br>
        p = (struct colorpage *)mymalloc((integer)<br>
!                   (strlen(cstack) + sizeof(struct colorpage) + MAXCOLORLEN));<br>
        p->next = colorhash[h];<br>
        p->boploc = pageloc;<br>
        strcpy(p->colordat, cstack);<br>
--- 216,222 ----<br>
        }<br>
     } else {<br>
        p = (struct colorpage *)mymalloc((integer)<br>
!                   (strlen(cstack) + sizeof(struct colorpage) + MAXCOLORLEN + 2));<br>
        p->next = colorhash[h];<br>
        p->boploc = pageloc;<br>
        strcpy(p->colordat, cstack);<br>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div>--  <a href="http://cube20.org/" target="_blank">http://cube20.org/</a>  --  <a href="http://golly.sf.net/" target="_blank">http://golly.sf.net/</a>  --</div></div></div></div></div>
</div>