From owner-cvs-gnu Sat Jun 8 01:47:03 1996 Return-Path: owner-cvs-gnu Received: (from root@localhost) by freefall.freebsd.org (8.7.5/8.7.3) id BAA12879 for cvs-gnu-outgoing; Sat, 8 Jun 1996 01:47:03 -0700 (PDT) Received: from godzilla.zeta.org.au (godzilla.zeta.org.au [203.2.228.19]) by freefall.freebsd.org (8.7.5/8.7.3) with SMTP id BAA12803; Sat, 8 Jun 1996 01:46:44 -0700 (PDT) Received: (from bde@localhost) by godzilla.zeta.org.au (8.6.12/8.6.9) id SAA27094; Sat, 8 Jun 1996 18:41:18 +1000 Date: Sat, 8 Jun 1996 18:41:18 +1000 From: Bruce Evans Message-Id: <199606080841.SAA27094@godzilla.zeta.org.au> To: rgrimes@gndrsh.aac.dev.com, wpaul@freefall.freebsd.org Subject: Re: cvs commit: src/gnu/usr.bin/ld ld.c Cc: CVS-committers@freefall.freebsd.org, cvs-all@freefall.freebsd.org, cvs-gnu@freefall.freebsd.org Sender: owner-cvs-gnu@FreeBSD.ORG X-Loop: FreeBSD.org Precedence: bulk >More ``complete'' fix, use the compiler to do the right thing for you...: >#define TMP_EXTENSION ".tmp" >... > case 'O': > output_filename = malloc(strlen(arg)+sizeof(TMP_EXTENSION)); > strcpy(output_filename, arg); > strcat(output_filename, TMP_EXTENSION); > real_output_filename = arg; > return; I'm not sure if naming the string literal is worth the trouble in this case. There are a few more bugs: - the value returned by malloc() isn't checked. - (style consistency) xmalloc() isn't used. - (style consistency) ld seems to use strcpy(str1 + offset, str2) in preference to strcat() or sprintf(). It should probably use sprintf() except where efficiency is important. - (style) there are no spaces before and after the '+'. Bruce