All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] pyalsa: fix integer overflow in alsaseq.c
@ 2009-08-18 21:36 Chris Coleman
  2009-08-18 21:37 ` Chris Coleman
  0 siblings, 1 reply; 4+ messages in thread
From: Chris Coleman @ 2009-08-18 21:36 UTC (permalink / raw)
  To: alsa-devel

Hello alsa-devel,

I've been using the alsaseq python module and I found a bug. Sometimes
the SEQ_* constants have extremely large and incorrect values. For
example, 25769803811 instead of 35. The lower 32-bits are always
correct.

Obviously, I'm running a 64-bit operating system.

The problem is that the `value` member of the `ConstantObject`
structure is an `unsigned int` whereas it should be a `long`. I've
attached a patch. It's against the latest released version, 1.0.20.

Regards,
Chris Coleman

Signed-off-by: Chris Coleman <chris.coleman83 at gmail.com>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] pyalsa: fix integer overflow in alsaseq.c
  2009-08-18 21:36 [PATCH] pyalsa: fix integer overflow in alsaseq.c Chris Coleman
@ 2009-08-18 21:37 ` Chris Coleman
  2009-08-20 19:13   ` Chris Coleman
  0 siblings, 1 reply; 4+ messages in thread
From: Chris Coleman @ 2009-08-18 21:37 UTC (permalink / raw)
  To: alsa-devel

[-- Attachment #1: Type: text/plain, Size: 737 bytes --]

Sorry, here's the patch.

Signed-off-by: Chris Coleman <chris.coleman83 at gmail.com>

2009/8/18 Chris Coleman <chris.coleman83@gmail.com>:
> Hello alsa-devel,
>
> I've been using the alsaseq python module and I found a bug. Sometimes
> the SEQ_* constants have extremely large and incorrect values. For
> example, 25769803811 instead of 35. The lower 32-bits are always
> correct.
>
> Obviously, I'm running a 64-bit operating system.
>
> The problem is that the `value` member of the `ConstantObject`
> structure is an `unsigned int` whereas it should be a `long`. I've
> attached a patch. It's against the latest released version, 1.0.20.
>
> Regards,
> Chris Coleman
>
> Signed-off-by: Chris Coleman <chris.coleman83 at gmail.com>
>

[-- Attachment #2: pyalsa-1.0.20-alsaseq.patch --]
[-- Type: text/x-patch, Size: 613 bytes --]

--- pyalsa-1.0.20.orig/pyalsa/alsaseq.c	2009-05-06 08:07:28.000000000 +0100
+++ pyalsa-1.0.20/pyalsa/alsaseq.c	2009-08-18 07:08:21.504628168 +0100
@@ -439,7 +439,7 @@ typedef struct {
   ;
 
   /* value of constant */
-  unsigned int value;
+  long value;
   /* name of constant */
   const char *name;
   /* type of constant */
@@ -468,7 +468,7 @@ Constant_create(const char *name, long v
 /** alsaseq.Constant tp_repr */
 static PyObject *
 Constant_repr(ConstantObject *self) {
-  return PyString_FromFormat("%s(0x%x)",
+  return PyString_FromFormat("%s(0x%lx)",
 			     self->name,
 			     self->value);
 }

[-- 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	[flat|nested] 4+ messages in thread

* Re: [PATCH] pyalsa: fix integer overflow in alsaseq.c
  2009-08-18 21:37 ` Chris Coleman
@ 2009-08-20 19:13   ` Chris Coleman
  2009-08-21  9:54     ` Takashi Iwai
  0 siblings, 1 reply; 4+ messages in thread
From: Chris Coleman @ 2009-08-20 19:13 UTC (permalink / raw)
  To: alsa-devel

[-- Attachment #1: Type: text/plain, Size: 1183 bytes --]

I just noticed that `PyString_FromFormat` in Python 2.6 doesn't handle
`%lx` in format strings, so my patch breaks `repr(Constant)`.

In addition to that, it was not necessary to change the signedness of `value`.

With those two things in mind, the patch perhaps ought to look like
this (see attached).

Signed-off-by: Chris Coleman <chris.coleman83 at gmail.com>

2009/8/18 Chris Coleman <chris.coleman83@gmail.com>:
> Sorry, here's the patch.
>
> Signed-off-by: Chris Coleman <chris.coleman83 at gmail.com>
>
> 2009/8/18 Chris Coleman <chris.coleman83@gmail.com>:
>> Hello alsa-devel,
>>
>> I've been using the alsaseq python module and I found a bug. Sometimes
>> the SEQ_* constants have extremely large and incorrect values. For
>> example, 25769803811 instead of 35. The lower 32-bits are always
>> correct.
>>
>> Obviously, I'm running a 64-bit operating system.
>>
>> The problem is that the `value` member of the `ConstantObject`
>> structure is an `unsigned int` whereas it should be a `long`. I've
>> attached a patch. It's against the latest released version, 1.0.20.
>>
>> Regards,
>> Chris Coleman
>>
>> Signed-off-by: Chris Coleman <chris.coleman83 at gmail.com>
>>
>

[-- Attachment #2: pyalsa-1.0.20-alsaseq.patch --]
[-- Type: text/x-patch, Size: 579 bytes --]

--- pyalsa-1.0.20.orig/pyalsa/alsaseq.c	2009-05-06 08:07:28.000000000 +0100
+++ pyalsa-1.0.20/pyalsa/alsaseq.c	2009-08-20 19:49:04.004648265 +0100
@@ -439,7 +439,7 @@ typedef struct {
   ;
 
   /* value of constant */
-  unsigned int value;
+  unsigned long int value;
   /* name of constant */
   const char *name;
   /* type of constant */
@@ -470,7 +470,7 @@ static PyObject *
 Constant_repr(ConstantObject *self) {
   return PyString_FromFormat("%s(0x%x)",
 			     self->name,
-			     self->value);
+			     (unsigned int)self->value);
 }
 
 /** alsaseq.Constant tp_str */

[-- 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	[flat|nested] 4+ messages in thread

* Re: [PATCH] pyalsa: fix integer overflow in alsaseq.c
  2009-08-20 19:13   ` Chris Coleman
@ 2009-08-21  9:54     ` Takashi Iwai
  0 siblings, 0 replies; 4+ messages in thread
From: Takashi Iwai @ 2009-08-21  9:54 UTC (permalink / raw)
  To: Chris Coleman; +Cc: alsa-devel

At Thu, 20 Aug 2009 20:13:45 +0100,
Chris Coleman wrote:
> 
> I just noticed that `PyString_FromFormat` in Python 2.6 doesn't handle
> `%lx` in format strings, so my patch breaks `repr(Constant)`.
> 
> In addition to that, it was not necessary to change the signedness of `value`.
> 
> With those two things in mind, the patch perhaps ought to look like
> this (see attached).
> 
> Signed-off-by: Chris Coleman <chris.coleman83 at gmail.com>

Thanks, applied now.


Takashi

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2009-08-21  9:54 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-08-18 21:36 [PATCH] pyalsa: fix integer overflow in alsaseq.c Chris Coleman
2009-08-18 21:37 ` Chris Coleman
2009-08-20 19:13   ` Chris Coleman
2009-08-21  9:54     ` Takashi Iwai

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.