Date: Wed, 9 Oct 2002 02:53:27 -0700 From: Maxime Henrion <mux@freebsd.org> To: "Vladimir B. Grebenschikov" <vova@sw.ru> Cc: freebsd-current@freebsd.org Subject: Re: DDB sysctl function Message-ID: <20021009095327.GQ57622@elvis.mu.org> In-Reply-To: <20021009094616.GP57622@elvis.mu.org> References: <1034097697.1548.2.camel@vbook.express.ru> <20021008182532.GM57622@elvis.mu.org> <1034110999.1146.3.camel@vbook.express.ru> <1034154560.900.6.camel@vbook.express.ru> <20021009094616.GP57622@elvis.mu.org>
next in thread | previous in thread | raw e-mail | index | archive | help
Maxime Henrion wrote: [...] > > > > - There is a TOK_STRING_SIZE macro which defines the size of the the > > > > db_tok_string variable. Use it instead of declaring several 1k > > > > variables on the stack. > > > > > > It is not token buffers - it is buffers for sysctl data interchange, > > > const 1024 changed to SYSCTL_DATA_BUFSIZE define. > > Yes, that's better, but you still do a strcpy() which assumes that > SYSCTL_DATA_BUFSIZE >= TOK_STRING_SIZE, and there are still quite big > variables on the stack, which can be a problem if someone invokes ddb > while deep in the stack. > > What I meant in my previous mail is that you could malloc() these > objects instead of putting them on the stack. Also, you don't need > buffers that big since the size you need is bounded at max(sizeof(int), > TOK_STRING_SIZE), which is likely to be TOK_STRING_SIZE :-). To be even more precise, you could just have an int and a char * as local variables, use the int in the tNUMBER case and malloc() the char * to TOK_STRING_SIZE in the tIDENT case. Cheers, Maxime To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20021009095327.GQ57622>