[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: user/4073: lint does not concatenate strings correctly



The following reply was made to PR user/4073; it has been noted by GNATS.

From: "Todd C. Miller" <Todd_(_dot_)_Miller_(_at_)_courtesan_(_dot_)_com>
To: ca+OpenBSD_(_at_)_zardoc_(_dot_)_endmail_(_dot_)_org
Cc: gnats_(_at_)_openbsd_(_dot_)_org
Subject: Re: user/4073: lint does not concatenate strings correctly 
Date: Sat, 22 Jan 2005 21:56:55 -0700

 I don't see an off-by-one (length does not include space for the
 NUL), however, I believe:
 
     strg1->st_len += len2 * sizeof (wchar_t);
 
 should be:
 
     strg1->st_len += len2;
 
 since st_len is the number of chars (narrow or wide), not a byte
 count.
 
 So this reduces to:
 
 Index: usr.bin/xlint/lint1/tree.c
 ===================================================================
 RCS file: /home/cvs/openbsd/src/usr.bin/xlint/lint1/tree.c,v
 retrieving revision 1.6
 diff -u -r1.6 tree.c
 --- usr.bin/xlint/lint1/tree.c	16 Feb 2002 21:27:59 -0000	1.6
 +++ usr.bin/xlint/lint1/tree.c	23 Jan 2005 04:55:58 -0000
 @@ -3838,6 +3838,7 @@
  			     (len2 + 1) * sizeof (wchar_t));
  		free(strg2->st_wcp);
  	}
 +	strg1->st_len = len;
  	free(strg2);
  
  	return (strg1);



Visit your host, monkey.org