* [PATCH] Fix possible sprintf overrun in snd_pcm_hw_open
@ 2010-12-08 10:16 David Henningsson
2010-12-08 12:12 ` Clemens Ladisch
0 siblings, 1 reply; 4+ messages in thread
From: David Henningsson @ 2010-12-08 10:16 UTC (permalink / raw)
To: ALSA Development Mailing List; +Cc: Takashi Iwai
[-- Attachment #1: Type: text/plain, Size: 274 bytes --]
I spotted this while reading code a few weeks ago, and I ran it through
the Ubuntu security team just to be sure.
They decided it was not needing any security embargo or similar, so here
comes the patch.
--
David Henningsson, Canonical Ltd.
http://launchpad.net/~diwic
[-- Attachment #2: 0001-Fix-possible-sprintf-overrun-in-snd_pcm_hw_open.patch --]
[-- Type: text/x-patch, Size: 970 bytes --]
>From 3333d9bb8d8f9cc95f9dbf68d0a703a4e832a948 Mon Sep 17 00:00:00 2001
From: David Henningsson <david.henningsson@canonical.com>
Date: Wed, 8 Dec 2010 11:06:59 +0100
Subject: [PATCH] Fix possible sprintf overrun in snd_pcm_hw_open
BugLink: http://launchpad.net/bugs/668487
Possible buffer overrun if the number of "card" and "device"
are absurdly high, especially on 64-bit platforms.
Signed-off-by: David Henningsson <david.henningsson@canonical.com>
---
src/pcm/pcm_hw.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/src/pcm/pcm_hw.c b/src/pcm/pcm_hw.c
index 9d243d5..ce74ad4 100644
--- a/src/pcm/pcm_hw.c
+++ b/src/pcm/pcm_hw.c
@@ -1270,7 +1270,7 @@ int snd_pcm_hw_open(snd_pcm_t **pcmp, const char *name,
SNDERR("invalid stream %d", stream);
return -EINVAL;
}
- sprintf(filename, filefmt, card, device);
+ snprintf(filename, sizeof(filename), filefmt, card, device);
__again:
if (attempt++ > 3) {
--
1.7.1
[-- Attachment #3: Type: text/plain, Size: 160 bytes --]
_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] Fix possible sprintf overrun in snd_pcm_hw_open
2010-12-08 10:16 [PATCH] Fix possible sprintf overrun in snd_pcm_hw_open David Henningsson
@ 2010-12-08 12:12 ` Clemens Ladisch
2010-12-08 12:56 ` David Henningsson
0 siblings, 1 reply; 4+ messages in thread
From: Clemens Ladisch @ 2010-12-08 12:12 UTC (permalink / raw)
To: David Henningsson; +Cc: Takashi Iwai, ALSA Development Mailing List
David Henningsson wrote:
> Possible buffer overrun if the number of "card" and "device"
> are absurdly high, especially on 64-bit platforms.
The size of "int" is 32 bits even on 64-bit platforms.
As far as I can see, there is no bug.
Regards,
Clemens
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] Fix possible sprintf overrun in snd_pcm_hw_open
2010-12-08 12:12 ` Clemens Ladisch
@ 2010-12-08 12:56 ` David Henningsson
2010-12-08 13:20 ` David Henningsson
0 siblings, 1 reply; 4+ messages in thread
From: David Henningsson @ 2010-12-08 12:56 UTC (permalink / raw)
To: Clemens Ladisch; +Cc: Takashi Iwai, ALSA Development Mailing List
On 2010-12-08 13:12, Clemens Ladisch wrote:
> David Henningsson wrote:
>> Possible buffer overrun if the number of "card" and "device"
>> are absurdly high, especially on 64-bit platforms.
>
> The size of "int" is 32 bits even on 64-bit platforms.
Seems you're right, then I learned something new today :-)
Although this might be compiler dependent, and some exotic platform
might decide otherwise in the future?
> As far as I can see, there is no bug.
Even for 32-bit platforms, you would still overrun the buffer if you set
card = device = −2147483647.
--
David Henningsson, Canonical Ltd.
http://launchpad.net/~diwic
_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] Fix possible sprintf overrun in snd_pcm_hw_open
2010-12-08 12:56 ` David Henningsson
@ 2010-12-08 13:20 ` David Henningsson
0 siblings, 0 replies; 4+ messages in thread
From: David Henningsson @ 2010-12-08 13:20 UTC (permalink / raw)
To: Clemens Ladisch; +Cc: Takashi Iwai, ALSA Development Mailing List
On 2010-12-08 13:56, David Henningsson wrote:
> On 2010-12-08 13:12, Clemens Ladisch wrote:
>> David Henningsson wrote:
>>> Possible buffer overrun if the number of "card" and "device"
>>> are absurdly high, especially on 64-bit platforms.
>>
>> The size of "int" is 32 bits even on 64-bit platforms.
>
> Seems you're right, then I learned something new today :-)
>
> Although this might be compiler dependent, and some exotic platform
> might decide otherwise in the future?
>
>> As far as I can see, there is no bug.
>
> Even for 32-bit platforms, you would still overrun the buffer if you set
> card = device = −2147483647.
>
...or maybe not, forgot that the %d characters are removed. Oh well,
doesn't hurt to change it into snprintf anyway ;-)
--
David Henningsson, Canonical Ltd.
http://launchpad.net/~diwic
_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2010-12-08 13:20 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-12-08 10:16 [PATCH] Fix possible sprintf overrun in snd_pcm_hw_open David Henningsson
2010-12-08 12:12 ` Clemens Ladisch
2010-12-08 12:56 ` David Henningsson
2010-12-08 13:20 ` David Henningsson
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.