pyalsa: fix integer overflow in alsaseq.c
PATCH 1/1 pyalsa: fix integer overflow in alsaseq.c
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
Sorry, here's the patch.
2009/8/18 Chris Coleman <[email protected]>:
Quoted 9 lines
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.
Quoted 9 lines
The problem is that the
valuemember of theConstantObjectstructure is anunsigned intwhereas it should be along. I've attached a patch. It's against the latest released version, 1.0.20.Regards,
Chris ColemanSigned-off-by Chris Coleman <chris.coleman83 at gmail.com>
pyalsa/alsaseq.c +2 -2
@@ -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); }
_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
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).
2009/8/18 Chris Coleman <[email protected]>:
Quoted 24 lines
Sorry, here's the patch.
Signed-off-by Chris Coleman <chris.coleman83 at gmail.com>2009/8/18 Chris Coleman <[email protected]>:
Quoted 18 lines
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
valuemember of theConstantObjectstructure is anunsigned intwhereas it should be along. I've attached a patch. It's against the latest released version, 1.0.20.Regards,
Chris ColemanSigned-off-by Chris Coleman <chris.coleman83 at gmail.com>
pyalsa/alsaseq.c +2 -2
@@ -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 */
_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
Takashi Iwai
AppliedAt Thu, 20 Aug 2009 20:13:45 +0100,
Quoted 10 lines · Chris Coleman
I just noticed that
PyString_FromFormatin Python 2.6 doesn't handle%lxin format strings, so my patch breaksrepr(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