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:49 UTC

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

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);