From: walter harms <wharms@bfs.de>
To: Dan Carpenter <error27@gmail.com>,
Armin Schindler <armin@melware.de>,
Karsten Keil <isdn@linux-pingi.de>,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
kernel-janitors@vger.kernel.org
Subject: Re: [patch] eicon: make buffer larger
Date: Wed, 06 Oct 2010 10:16:10 +0200 [thread overview]
Message-ID: <4CAC304A.8040306@bfs.de> (raw)
In-Reply-To: <20101006074714.GE5409@bicker>
Dan Carpenter schrieb:
> On Wed, Oct 06, 2010 at 09:25:44AM +0200, Armin Schindler wrote:
>> On Mon, 4 Oct 2010, Dan Carpenter wrote:
>>> In diva_mnt_add_xdi_adapter() we do this:
>>> strcpy (clients[id].drvName, tmp);
>>> strcpy (clients[id].Dbg.drvName, tmp);
>>>
>>> The "clients[id].drvName" is a 128 character buffer and
>>> "clients[id].Dbg.drvName" was originally a 16 character buffer but I've
>>> changed it to 128 as well. We don't actually use 128 characters but we
>>> do use more than 16.
>> I don't see any reason for that change. The driver names here do not use
>> more than 16 characters and when filled, the length is checked anyway.
>> Please avoid changing the size of that structure.
>>
>
> drivers/isdn/hardware/eicon/debug.c diva_mnt_add_xdi_adapter()
> 874 sprintf (tmp, "ADAPTER:%d SN:%u-%d",
> 12345678 90123 45 67
>
> That's a minimum 17 characters.
>
> 875 (int)logical,
> 876 serial & 0x00ffffff,
> 877 (byte)(((serial & 0xff000000) >> 24) + 1));
> 878 } else {
> 879 sprintf (tmp, "ADAPTER:%d SN:%u", (int)logical, serial);
> 880 }
>
for that reason i am a fan of kasprintf().
Maybe this a solution here also ? samething like:
kasprintf (&buf, "ADAPTER:%d SN:%u-%d",12345678,90123,45,67):
...
kstrncpy(tmp,buf,sizeof(buf));
....
free(buf);
that would keep overflows away until the changes in the structure are ready.
re,
wh
next prev parent reply other threads:[~2010-10-06 8:16 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-10-04 19:24 [patch] eicon: make buffer larger Dan Carpenter
2010-10-06 7:25 ` Armin Schindler
2010-10-06 7:47 ` Dan Carpenter
2010-10-06 8:16 ` walter harms [this message]
2010-10-06 8:21 ` Armin Schindler
2010-10-06 8:31 ` Dan Carpenter
2010-10-06 8:44 ` Armin Schindler
2010-10-06 12:11 ` Dan Carpenter
2010-10-06 12:49 ` Armin Schindler
2010-10-07 6:30 ` David Miller
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=4CAC304A.8040306@bfs.de \
--to=wharms@bfs.de \
--cc=armin@melware.de \
--cc=error27@gmail.com \
--cc=isdn@linux-pingi.de \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@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;
as well as URLs for NNTP newsgroup(s).