Skip to contentSkip to conversation

Q: procfs entry.

DISCUSSION Anders Peter Fugmann 1 participant 1 message May 18, 2001

lore
Share & tools
lore
#0 lore raw

Hi again.

I have a question about the function parsed for reading a procfs entry.

I've used the skeleton from drivers/char/misc.c, and all works perfectly, but I see a potential flaw.

static int misc_read_proc(char *buf, char **start, off_t offset,
int len, int *eof, void *private)
{
.
.

	written=0;
        for (p = misc_list.next; p != &misc_list && written < len;
		p = p->next) {

                written += sprintf(buf+written, "%3i %s\n",p->minor,
			p->name ?: "");
                if (written < offset) {
                        offset -= written;
                        written = 0;
                }
        }

.
.

As I see it, there is a possibility to write beyond buf+len. (if len<5)
If so is it ok, or should this be avoided at all cost?

TIA
Anders Fugmann