You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by an...@apache.org on 2018/11/22 20:18:47 UTC

[mynewt-core] branch master updated (8055fb2 -> 822e46e)

This is an automated email from the ASF dual-hosted git repository.

andk pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git.


    from 8055fb2  hw/mcu/nordic: Fix stop on I2C write
     new 961b60a  hw/drivers/lp5523: Fix invalid payload in set_n_regs
     new 822e46e  hw/drivers/lp5523: Fix potential stack corruption

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 hw/drivers/led/lp5523/src/lp5523.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)


[mynewt-core] 01/02: hw/drivers/lp5523: Fix invalid payload in set_n_regs

Posted by an...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

andk pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git

commit 961b60a3d58be6d0abeef0a73c1af35c62a64195
Author: Andrzej Kaczmarek <an...@codecoup.pl>
AuthorDate: Thu Nov 22 18:19:28 2018 +0100

    hw/drivers/lp5523: Fix invalid payload in set_n_regs
---
 hw/drivers/led/lp5523/src/lp5523.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/hw/drivers/led/lp5523/src/lp5523.c b/hw/drivers/led/lp5523/src/lp5523.c
index 894a5fc..1525cca 100644
--- a/hw/drivers/led/lp5523/src/lp5523.c
+++ b/hw/drivers/led/lp5523/src/lp5523.c
@@ -129,17 +129,16 @@ lp5523_set_n_regs(struct led_itf *itf, enum lp5523_registers addr,
     uint8_t *vals, uint8_t len)
 {
     int rc;
-    uint8_t regs[LP5523_MAX_PAYLOAD] = {0};
+    uint8_t payload[LP5523_MAX_PAYLOAD] = {0};
 
     struct hal_i2c_master_data data_struct = {
         .address = itf->li_addr,
         .len = len + 1,
-        .buffer = regs
+        .buffer = payload,
     };
 
-    memcpy(regs, vals, len + 1);
-
-    regs[0] = addr;
+    payload[0] = addr;
+    memcpy(&payload[1], vals, len);
 
     rc = led_itf_lock(itf, MYNEWT_VAL(LP5523_ITF_LOCK_TMO));
     if (rc) {
@@ -151,7 +150,7 @@ lp5523_set_n_regs(struct led_itf *itf, enum lp5523_registers addr,
 
     if (rc) {
         LP5523_LOG(ERROR, "Failed to write to 0x%02X:0x%02X\n", itf->li_addr,
-                   regs[0]);
+                   addr);
         STATS_INC(g_lp5523stats, read_errors);
     }
 


[mynewt-core] 02/02: hw/drivers/lp5523: Fix potential stack corruption

Posted by an...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

andk pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git

commit 822e46ed20a72de15c4c213891006b65f4e44f5c
Author: Andrzej Kaczmarek <an...@codecoup.pl>
AuthorDate: Thu Nov 22 18:21:34 2018 +0100

    hw/drivers/lp5523: Fix potential stack corruption
    
    Make sure caller does not try to write more registers at once than
    supported by driver.
---
 hw/drivers/led/lp5523/src/lp5523.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/hw/drivers/led/lp5523/src/lp5523.c b/hw/drivers/led/lp5523/src/lp5523.c
index 1525cca..8ef7907 100644
--- a/hw/drivers/led/lp5523/src/lp5523.c
+++ b/hw/drivers/led/lp5523/src/lp5523.c
@@ -137,6 +137,10 @@ lp5523_set_n_regs(struct led_itf *itf, enum lp5523_registers addr,
         .buffer = payload,
     };
 
+    if (len >= LP5523_MAX_PAYLOAD) {
+        return -1;
+    }
+
     payload[0] = addr;
     memcpy(&payload[1], vals, len);