[comp.sys.mac.programmer] PLstrcat bug in MPW QR1

anders@verity.com (Anders Wallgren) (12/22/90)

I think I've found a bug in the PLstrcat routine in the MPW QR1
libraries (on ETO #1): if the second string (the one being concated to
the end of the first one) is zero-length, the routine will trash
memory.

This seems to happen because it subtracts one from the length of the
second string without checking the length for zero first.  Since this
number is then used to control the loop that does the actual copying,
this causes it to concat 255 bytes to the end of the first string,
writing past the end if it already has characters in it.

An easy workaround is to just check the length of the second string
and not make the call if it's zero.


anders

ldo@waikato.ac.nz (Lawrence D'Oliveiro, Waikato University) (12/24/90)

Ack! Obviously there are still *more* people inside Apple who don't
know how to use a DBRA instruction properly...

Lawrence D'Oliveiro                       fone: +64-71-562-889
Computer Services Dept                     fax: +64-71-384-066
University of Waikato            electric mail: ldo@waikato.ac.nz
Hamilton, New Zealand    37^ 47' 26" S, 175^ 19' 7" E, GMT+13:00