This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
Re: procfs.c thinks pid's can't be bigger than 99999
- To: John Hughes <john at Calva dot COM>
- Subject: Re: procfs.c thinks pid's can't be bigger than 99999
- From: Andrew Cagney <ac131313 at cygnus dot com>
- Date: Tue, 03 Jul 2001 14:55:35 -0400
- Cc: gdb-patches at sourceware dot cygnus dot com
- References: <CDENKKMHIFMALMCCKPCFKEEJCAAA.john@Calva.COM>
> but on some systems, for example UnixWare NSC they
> can be quite a lot bigger.
>
> --- procfs.c.orig Tue May 15 02:03:36 2001
> +++ procfs.c Mon Jul 2 14:40:05 2001
> @@ -295,7 +295,7 @@
> # define AS_PROC_NAME_FMT "/proc/%d/as"
> # define MAP_PROC_NAME_FMT "/proc/%d/map"
> # define STATUS_PROC_NAME_FMT "/proc/%d/status"
> -# define MAX_PROC_NAME_SIZE sizeof("/proc/99999/lwp/8096/lstatus")
> +# define MAX_PROC_NAME_SIZE sizeof("/proc/1048576/lwp/8096/lstatus")
> # endif
> /* the name of the proc status struct depends on the implementation */
> typedef pstatus_t gdb_prstatus_t;
Um, I think it would be a lot better to size the buffer dynamically.
xasprintf() is one way of doing that. Anyway, I think the main thing is
to fix the buffer overrun not hide it :-)
Andrew