From: Anders Peter Fugmann <afu@fugmann.dhs.org>
To: linux-kernel <linux-kernel@vger.kernel.org>
Subject: Q: procfs entry.
Date: Sat, 19 May 2001 01:33:38 +0200 [thread overview]
Message-ID: <3B05B152.3000904@fugmann.dhs.org> (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
reply other threads:[~2001-05-18 23:33 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=3B05B152.3000904@fugmann.dhs.org \
--to=afu@fugmann.dhs.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox