[Armadeus-commitlog] armadeus branch, master, updated. release-3.3-377-gbdd9cbc
Brought to you by:
sszy
|
From: Fabien M <fa...@us...> - 2011-02-25 10:54:29
|
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "armadeus".
The branch, master has been updated
via bdd9cbcfc8232e37ef93c25928c189d8f97e3c02 (commit)
via a8cbce55da2bafe9a7dc881834f8745026cc8029 (commit)
from 8f6c257fea269709754f83936afa75974df8fe65 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit bdd9cbcfc8232e37ef93c25928c189d8f97e3c02
Author: Fabien Marteau <fab...@ar...>
Date: Fri Feb 25 11:53:26 2011 +0100
[as_devices] Check size of data for i2c functions
commit a8cbce55da2bafe9a7dc881834f8745026cc8029
Author: Fabien Marteau <fab...@ar...>
Date: Fri Feb 25 11:12:35 2011 +0100
[as_devices] Improvement to do in as_i2c python wrapper
-----------------------------------------------------------------------
Summary of changes:
target/packages/as_devices/c/as_i2c.c | 27 ++++++++++++++++++++
target/packages/as_devices/python/src/AsI2c_wrap.c | 19 ++++++++++++++
2 files changed, 46 insertions(+), 0 deletions(-)
diff --git a/target/packages/as_devices/c/as_i2c.c b/target/packages/as_devices/c/as_i2c.c
index d899c82..3c607c2 100644
--- a/target/packages/as_devices/c/as_i2c.c
+++ b/target/packages/as_devices/c/as_i2c.c
@@ -102,6 +102,10 @@ int32_t as_i2c_read(struct as_i2c_device *aDev,
ERROR("Slave address must be set before\n");
return -1;
}
+ if (n <= 0) {
+ ERROR("Size of data must be upper than 0\n");
+ return -1;
+ }
if (ioctl(aDev->fi2c, I2C_RDWR, &rdwr) < 0)
return -1;
@@ -119,6 +123,10 @@ int32_t as_i2c_write(struct as_i2c_device *aDev,
ERROR("Slave address must be set before\n");
return -1;
}
+ if (n <= 0) {
+ ERROR("Size of data must be upper than 0\n");
+ return -1;
+ }
if (ioctl(aDev->fi2c, I2C_RDWR, &rdwr) < 0)
return -1;
@@ -138,6 +146,11 @@ int32_t as_i2c_read_reg(struct as_i2c_device *aDev,
return -1;
}
+ if (n <= 0) {
+ ERROR("Size of data must be upper than 0\n");
+ return -1;
+ }
+
if (ioctl(aDev->fi2c, I2C_RDWR, &rdwr) < 0) {
ERROR("Can't write on i2c\n");
return -1;
@@ -164,6 +177,10 @@ int32_t as_i2c_write_reg(struct as_i2c_device *aDev,
ERROR("Slave address must be set before\n");
return -1;
}
+ if (n <= 0) {
+ ERROR("Size of data must be upper than 0\n");
+ return -1;
+ }
buf[0] = aReg;
memcpy(buf+1, aData, n);
@@ -213,6 +230,16 @@ int32_t as_i2c_read_msg(struct as_i2c_device *aDev,
ERROR("Slave address must be set before\n");
return -1;
}
+
+ if (aWriteSize <= 0) {
+ ERROR("Write size must be upper than 0\n");
+ return -1;
+ }
+ if (aReadSize <= 0) {
+ ERROR("Read size must be upper than 0\n");
+ return -1;
+ }
+
if (ioctl(aDev->fi2c, I2C_RDWR, &rdwr) < 0) {
ERROR("Can't write on i2c\n");
return -1;
diff --git a/target/packages/as_devices/python/src/AsI2c_wrap.c b/target/packages/as_devices/python/src/AsI2c_wrap.c
index dadb15c..9359db1 100644
--- a/target/packages/as_devices/python/src/AsI2c_wrap.c
+++ b/target/packages/as_devices/python/src/AsI2c_wrap.c
@@ -17,6 +17,9 @@
** You should have received a copy of the GNU Lesser General Public
** License along with this library; if not, write to the Free Software
** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*
+* TODO:
+* - Suppress MAX_DATA_SIZE macro
*/
#include "AsI2c_wrap.h"
#include "as_i2c.h"
@@ -167,6 +170,12 @@ static PyObject * i2c_read(PyObject *self, PyObject *args)
return NULL;
}
+ if (aSize > MAX_DATA_SIZE) {
+ PyErr_SetString(PyExc_IOError,
+ "Size can't be upper than "+str(MAX_DATA_SIZE));
+ return NULL;
+ }
+
ret = as_i2c_read(aDev, aData, aSize);
if (ret < 0)
{
@@ -220,6 +229,11 @@ static PyObject * i2c_read_reg(PyObject *self, PyObject *args)
"Wrong parameters.");
return NULL;
}
+ if (aSize > MAX_DATA_SIZE) {
+ PyErr_SetString(PyExc_IOError,
+ "Size can't be upper than "+str(MAX_DATA_SIZE));
+ return NULL;
+ }
ret = as_i2c_read_reg(aDev, aReg, aData, aSize);
if (ret < 0) {
@@ -302,6 +316,11 @@ static PyObject * i2c_read_msg(PyObject *self, PyObject *args)
"Wrong parameters.");
return NULL;
}
+ if (aReadSize > MAX_DATA_SIZE) {
+ PyErr_SetString(PyExc_IOError,
+ "Read size can't be upper than "+str(MAX_DATA_SIZE));
+ return NULL;
+ }
ret = as_i2c_read_msg(aDev, aWData, aWriteSize, RData, aReadSize);
if (ret < 0) {
hooks/post-receive
--
armadeus
|