Path: utzoo!mnetor!uunet!husc6!rutgers!ucla-cs!zen!ucbvax!OKEEFFE.BERKELEY.EDU!bostic From: bostic@OKEEFFE.BERKELEY.EDU (Keith Bostic) Newsgroups: comp.bugs.2bsd Subject: V1.21 (strncat is broken) Message-ID: <8801062002.AA15696@okeeffe.Berkeley.EDU> Date: 6 Jan 88 20:02:27 GMT Sender: daemon@ucbvax.BERKELEY.EDU Lines: 35 Subject: strncat is broken Index: lib/libc/pdp/gen/strncat.s 2.10BSD Description: strncat(3) doesn't truncate strings correctly. Repeat-By: The following program demonstrates the bug. #include #include main() { char *s = "This is a long string, but we'll truncate it at the comma"; s[21] = '\0'; printf("%s\n", s); strncat(s, "Arragh!!", 7); printf("%s\n", s); } Fix: Apply the following patch. *** strncat.s.orig Wed Jan 6 11:41:24 1988 --- strncat.s Wed Jan 6 11:41:34 1988 *************** *** 36,41 **** --- 36,42 ---- movb (r2)+,(r1)+ / copy s2 to the end of s1 stopping at the beq 3f / end of s2 or when n runs out ... sob r0,2b + clrb (r1) 3: mov (sp)+,r2 / restore r2 4: