Subject: Re: CVS commit: src/sbin/modload
To: Klaus Klein <kleink@reziprozitaet.de>
From: Jaromir Dolecek <jdolecek@NetBSD.org>
List: source-changes
Date: 02/11/2004 19:44:53
Klaus Klein wrote:
> was part of the PR. MAXPATHLEN+1 isn't necessary here since
> it includes the terminating NUL character.
>
> The following hunk is not mentioned in the log message, nor was
> it part of the PR:
>
> @@ -85,7 +85,7 @@
> const char *object,
> const char *ldscript)
> {
> - char cmdbuf[1024];
> + char cmdbuf[MAXPATHLEN+1];
> int error = 0;
>
> The use +1 is wrong for the reasons outlined above. Nor is this
> semantically more reasonable, or more correct than 1024 itself,
> for the path to the linker command itself may legally have a
> MAXPATHLEN path without letting sufficient room for its arguments.
> (MAXPATHLEN is defined to 1024, so there's no improvement in
> functionality either. Looking at the interface, this would be a
> good candidate for a linkcmd()-returned buffer, which could size
> it appropriately, or even do so dynamically.) Please back this one
> out.
I changed the code so that the buffer is allocated dynamically
(via asprintf()), so this part should be fine now. I wanted
to highlight the buffer needs to be at least as big as the pathname
when I did the change, that's why I changed it to MAXPATHNAME.
Jaromir
--
Jaromir Dolecek <jdolecek@NetBSD.org> http://www.NetBSD.cz/
-=- We should be mindful of the potential goal, but as the Buddhist -=-
-=- masters say, ``You may notice during meditation that you -=-
-=- sometimes levitate or glow. Do not let this distract you.'' -=-