2004-06-23 13:33:14

by tom st denis

[permalink] [raw]
Subject: proc_misc.c comments

I was toying around with the idea of making /proc/meminfo use KiB as
the unit instead of KB [just something to waste 10 mins] when I noticed
that you guys have prototypes like

static int meminfo_read_proc(char *page, char **start, off_t off,
int count, int *eof, void *data)


Then do things like

len = sprintf(page,

Wouldn't it be safer to pass the size of "page" into the function and
use snprintf to prevent any possible buffer overflows?

Sure right now it's not a problem but it would make the code easier to
review, say when someone wants to add a /proc/thingymagingy later on in
the future.

I'm still a kernel newbie so I'll defer the coding work to other people
;-) Just thought I would point that out.

Tom




__________________________________
Do you Yahoo!?
Yahoo! Mail Address AutoComplete - You start. We finish.
http://promotions.yahoo.com/new_mail


2004-06-23 14:01:27

by Jörn Engel

[permalink] [raw]
Subject: Re: proc_misc.c comments

On Wed, 23 June 2004 06:33:09 -0700, tom st denis wrote:
>
> I was toying around with the idea of making /proc/meminfo use KiB as
> the unit instead of KB

Not an option. The layout of files in /proc/ is effectively a user
interface. Any change can break any program.

J?rn

--
Those who come seeking peace without a treaty are plotting.
-- Sun Tzu