From: Jeff Johnson <jellofan@gmail.com>
To: linux-kernel@vger.kernel.org
Subject: PROBLEM: linux 2.6.13.4 (snapgear-3.3.0) scripts/mod/modpost dumps core
Date: Fri, 18 Nov 2005 14:04:28 -0800 [thread overview]
Message-ID: <deb0cdf00511181404k70828875ged944bb3910069b5@mail.gmail.com> (raw)
I'm new at this, so hopefully this is OK. I'm working on an embedded
system using snapgear-3.3.0 (linux 2.6.13.4). The kernel build fails
when executing modpost -- it dumps core. I have debugged the problem.
In modpost.c:buf_printf() appears the following code:
len = vsnprintf(tmp, SZ, fmt, ap);
if (buf->size - buf->pos < len + 1) {
buf->size += 128;
buf->p = realloc(buf->p, buf->size);
}
strncpy(buf->p + buf->pos, tmp, len + 1);
What I have discovered is that in my environment, in some cases the
output from vsnprintf() exceeds 128 characters. So when the test for
"remaining space < len" fails, and the buf is realloc'ed, not enough
memory is allocated, and the subsequent strncpy overflows the buffer.
My solution was to change the assignment of buf->size as follows:
buf->size += 128 * ((len/128)+1);
This will cause buf->size to increment by enough 128 byte blocks to
hold the string. If it isn't important to increment in 128 byte
chunks, then I suppose you could just have:
buf->size += SZ;
Thanks
Jeff
reply other threads:[~2005-11-18 22:04 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=deb0cdf00511181404k70828875ged944bb3910069b5@mail.gmail.com \
--to=jellofan@gmail.com \
--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
all inboxes | Powered by JetHome®