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

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

commit 93a850c8c979c27bd2f512a6ff840664e10c6883
Author: Christopher Collins <ccoll...@apache.org>
AuthorDate: Fri Jun 12 23:09:04 2020 -0700

    shell_nlip: trim trailing '\n' on input lines
    
    The base64 decode code was recently changed to reject invalid input.
    This broke nlip receive.
    
    The fix is to trim the trailing newline character before passing input
    to base64_decode().
---
 sys/shell/src/shell_nlip.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/sys/shell/src/shell_nlip.c b/sys/shell/src/shell_nlip.c
index 21f5ff3..82b38f4 100644
--- a/sys/shell/src/shell_nlip.c
+++ b/sys/shell/src/shell_nlip.c
@@ -58,6 +58,12 @@ shell_nlip_process(char *data, int len)
     struct os_mbuf *m;
     uint16_t crc;
 
+    /* Trim trailing newline. */
+    if (len >= 1 && data[len - 1] == '\n') {
+        data[len - 1] = '\0';
+        len--;
+    }
+
     rc = base64_decode(data, data);
     if (rc < 0) {
         goto err;

Reply via email to