Re: Changing argv[0] under Linux.

Richard B. Johnson (root@chaos.analogic.com)
Tue, 14 Jan 2003 14:10:23 -0500 (EST)


On Tue, 14 Jan 2003, DervishD wrote:

> Hi all :))
>
> I'm not sure whether this issue belongs to the kernel or to the
> libc, but I think that is more on the kernel side, that's why I ask
> here.
>

Last time I checked argv[0] was 512 bytes. Many daemons overwrite
it with no problem.

PID TTY STAT TIME COMMAND
126 4 S 0:00 /sbin/agetty 38400 tty4
127 5 S 0:00 /sbin/agetty 38400 tty5
128 6 S 0:00 /sbin/agetty 38400 tty6
5241 2 S 0:00 -bash
13476 1 S 0:00 How-long-do-you-want-this-string-to-be?--is-this-long-enoug
13489 3 R 0:00 ps
27498 3 S 0:00 -bash
31011 1 S 0:00 -bash

#include <stdio.h>
#include <string.h>
int main(int cnt, char *argv[]) {
strcpy(argv[0], "How-long-do-you-want-this-string-to-be?--is-this-long-enough?");
pause();
return 0;
}

Cheers,
Dick Johnson
Penguin : Linux version 2.4.18 on an i686 machine (797.90 BogoMips).
Why is the government concerned about the lunatic fringe? Think about it.

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/