mkiiskila commented on a change in pull request #420: sys/console: fix console compatibility URL: https://github.com/apache/mynewt-core/pull/420#discussion_r127755892
########## File path: sys/console/minimal/src/console.c ########## @@ -86,11 +86,17 @@ console_read(char *str, int cnt, int *newline) } cmd = ev->ev_arg; len = strlen(cmd->line); + if ((cnt - 1) < len) { len = cnt - 1; + if (len > 0) { + memcpy(str, cmd->line, len); + str[len] = '\0'; + } else { + str[len] = cmd->line[0]; + } Review comment: This is broken. The common case, where cnt > len, would copy no bytes to str. Also, I don't understand line 96 here. Why are you setting last character in str to be first character of input? ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services