Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!lll-lcc!styx!ames!amdcad!rpw3 From: rpw3@amdcad.AMD.COM (Rob Warnock) Newsgroups: comp.os.minix Subject: Re: Bug in library routine getenv() Message-ID: <16545@amdcad.AMD.COM> Date: Tue, 5-May-87 22:09:11 EDT Article-I.D.: amdcad.16545 Posted: Tue May 5 22:09:11 1987 Date-Received: Thu, 7-May-87 06:07:27 EDT References: <3860@cae780.TEK.COM> Reply-To: rpw3@amdcad.UUCP (Rob Warnock) Distribution: world Organization: [Consultant] San Mateo, CA Lines: 22 Keywords: Bug, Fix, strncpy Summary: strncpy is NOT broken! (RT*M) In article <3860@cae780.TEK.COM> hubble@cae780.UUCP (Larry Hubble) writes: >Getenv() then seems to work properly. I believe there is also a bug in the >library routine strncpy -- it doesn't null terminate the string if the string >to copy is really longer that "n" characters. I have not verified or fixed >this yet, but will post it when I get a chance to cure it. This is *NOT* a bug, so don't try to "fix" it -- you will break many working programs! Read any System-V or POSIX man page for "strncpy": "...The result is not null-terminated if the source string contained 'n' or more characters..." This allows "strncpy" to be used to "insert" pieces of one string into another. (Sorry if it's not to your taste, but that's the way it was defined a long time ago...) Rob Warnock Systems Architecture Consultant UUCP: {amdcad,fortune,sun,attmail}!redwood!rpw3 ATTmail: !rpw3 DDD: (415)572-2607 USPS: 627 26th Ave, San Mateo, CA 94403