Subject: Re: CVS commit: src/sbin/modload
To: None <jdolecek@netbsd.org>
From: Klaus Klein <kleink@reziprozitaet.de>
List: source-changes
Date: 02/10/2004 23:52:46
On Tuesday 10 February 2004 13:30, Jaromir Dolecek wrote:
> Module Name:	src
> Committed By:	jdolecek
> Date:		Tue Feb 10 12:30:22 UTC 2004
>
> Modified Files:
> 	src/sbin/modload: modload.c
>
> Log Message:
> use MAXPATHLEN-sized buffer for module paths
> reported and fix provided in bin/24379 by Nicolas Joly

This isn't quite the case.  Note that only this hunk

@@ -251,7 +251,7 @@
        char *post = NULL;
        char *ldscript = NULL;
        char *modobj;
-       char modout[80], *p;
+       char modout[MAXPATHLEN+1], *p;
        struct stat stb;
        int strtablen;
        size_t modsize; /* XXX */

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.


- Klaus