Re: Display of some multi-line links is cut off in the middle

Thomas Dickey <[email protected]>
Newsgroups gmane.comp.web.lynx.devel
Message-ID <[email protected]>
On Fri, Dec 31, 2021 at 08:18:33PM -0500, Mouse wrote:
> >> -	    strcat(linedata, p);
> >> +	    for (i = 0; (linedata[i] = p[i]) != '\0'; ++i) ;
> 
> > asan2 reported that this line had a strcpy whose source/destination
> > overlapped.

fwiw, that was my checkin comment.  asan2 probably had it right.

	strcat(linedata, p);

won't work well if p points into the string that starts at linedata.

> 
> Then asan2 is wrong; the original line (the - line above) does not have
> any strcpy at all.  It has a strcat.  (Perhaps the strcat source and
> destination overlap, and asan2 is wrong only in that it reports the
> wrong call in its complaint?)  But the replacement code (the + line
> above) implements (loosely put) strcpy, not strcat.  Perhaps it would
> work better to replace the strcat with code that actually concatenates,
> preserving the presumably-intended semantics?

probably.  But then -- I think that going back to the original strcat
AND seeing how to avoid the case where p/linedata overlap might be better.

(something to do early in the day rather than the evening :-)

> 
> Maybe something like (completely untested)
> 
> 	for (i=0,j=strlen(linedata);(linedata[j]=p[i]);i++,j++) ;
> 
> /~\ The ASCII				  Mouse
> \ / Ribbon Campaign
>  X  Against HTML		[email protected]
> / \ Email!	     7D C8 61 52 5D E7 2D 39  4E F1 31 3E E8 B3 27 4B
> 

-- 
Thomas E. Dickey <[email protected]>
https://invisible-island.net
ftp://ftp.invisible-island.net
signature.asc (application/pgp-signature, 659 B)
-----BEGIN PGP SIGNATURE-----

iQGzBAABCgAdFiEEGYgtkt2kxADCLA1WzCr0RyFnvgMFAmHPsTMACgkQzCr0RyFn
vgMhBwv/Vk3HoueJiY9tp4rHyUhzLHjERed9hnfGyeAxrAsxC0SvqGzC69umeaNz
/3ZMC6QzBPPZ7d7aYSRnnf8J8oqk627vvTsi9+hUp1Om1+dOJcjammuuv7BGdHsn
6VEZ+Ndrb+evqwO7KLUMEKzx2MN8ortxsZZjyR175PMqv5GC2OOYG9KLuB2nswtN
IJuCEzfGW6hl2U5HOMhoqwlonYvynKODlnX3XoVAjox7N8FwAE0P6b5mou80Z8cW
6d7hUuw+o5A00lvGpkbOFz0EjPIauzjZjesjD4kUnJsG9Gnhv/kcu+QtH4QnEv0d
JS31tliukkIxGgTERn/i/hCuN+zMIrcLvjEvte3AJ9qARmk1/kouqVMa4YzhwzGa
nnpGbtIOctyC3SXkSKTcKbv6Cbt0u63gl16CsD9HEQl9h5KYELAO3nhPBT3BU8IE
2aWx0U5J7nDjlUW1pw+VhxFxvTw6zYdjpDKUBVEqor4wZMq1x9JDYTBVItyYMikw
NAEe/Pzm
=ykcl
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.