www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/1998/08/23/16:35:24

Message-ID: <35E0974D.FC66A85A@gmx.net>
Date: Sun, 23 Aug 1998 22:27:25 +0000
From: Robert Hoehne <robert DOT hoehne AT gmx DOT net>
Organization: none provided
MIME-Version: 1.0
To: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
CC: djgpp-workers <djgpp-workers AT delorie DOT com>
Subject: Re: Bug in crt1.c (alpha 980712)
References: <Pine DOT SUN DOT 3 DOT 91 DOT 980823161841 DOT 1451A-100000 AT is>

Eli Zaretskii wrote :
> 
> This is ANSI requirement: strncpy should pad with zeroes if the second
> argument is shorter than what the third specifies.

That was the reason, why I said, I don't know, since I don't
know the ANSI spec.

> 
> Then why not just calloc(17)?  Or, better yet, use strncat?
> 

That might be all correct, but can someone tell me, why
my patch is not good. What do you have against using
strcpy()? I really don't understand why you try to make
such an easy thing such complicated.

If I would write it in _MY_ code, I would write the two
lines from crt1.c

  prog_name = (char *)calloc(1, strlen(fc) + 1);
  strncpy(prog_name, fc, 16);

such

  prog_name = strdup(fc);

(or have I missed something?)

Robert


- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019