Mail Archives: djgpp-workers/2002/03/04/16:50:34
Hello.
Waldemar Schultz wrote:
[snip]
This patch seems like a good idea, but:
> ! dosmemget(__tb, sizeof(u->nodename), u->nodename);
> ! i = strlen(u->nodename);
> do {
> u->nodename[i--] = 0;
> } while (i && u->nodename[i] <= ' ');
[snip]
This is dangerous. What if the nodename is 32 (or more) characters long? Then
u->nodename may not be terminated and strlen(u->nodename) could be very long
=> buffer overrun.
Now it's possible that the DOS interrupt returns 31 chars + nul at most for
the node (aka hostname), but it's not clear from the code. It doesn't seem
like a good idea to rely on that behaviour either.
Also, the patch had some commented code in it. Presumably we should discuss
that? It looks like you want to allow $HOSTNAME from the environment to
override the node name returned by uname()?
Thanks, bye, Rich =]
--
Richard Dawe [ http://www.phekda.freeserve.co.uk/richdawe/ ]
- Raw text -