As pointed out by Paul Jackson <pj@sgi.com>, sometimes 99 chars is not enough.
We currently get a page from sysfs: that code should check we haven't overrun
it.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Signed-off-by: Paul Jackson <pj@sgi.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
cpumask_t mask = node_dev->cpumap;
int len;
- /* FIXME - someone should pass us a buffer size (count) or
- * use seq_file or something to avoid buffer overrun risk. */
- len = cpumask_scnprintf(buf, 99 /* XXX FIXME */, mask);
+ /* 2004/06/03: buf currently PAGE_SIZE, need > 1 char per 4 bits. */
+ BUILD_BUG_ON(NR_CPUS/4 > PAGE_SIZE/2);
+
+ len = cpumask_scnprintf(buf, PAGE_SIZE-1, mask);
len += sprintf(buf + len, "\n");
return len;
}
return -ENOMEM;
count = ops->show(kobj,attr,buffer->page);
+ BUG_ON(count > PAGE_SIZE);
if (count >= 0)
buffer->count = count;
else