apps/system: replace CONFIG_NSH_LINELEN to LINE_MAX#2918
Conversation
Signed-off-by: chao an <anchao@lixiang.com>
Signed-off-by: chao an <anchao@lixiang.com>
Signed-off-by: chao an <anchao@lixiang.com>
Applications should not depend on any properties of nshlib Signed-off-by: chao an <anchao@lixiang.com>
|
[Experimental Bot, please feedback here] No, this PR does not fully meet the NuttX requirements. While it provides a summary of changes, it lacks crucial details. Here's a breakdown of what's missing:
Example of how to improve the PR: Summary: This PR addresses potential buffer overflows and improves portability in nshlib and related applications. Applications were depending on the internal Related NuttX Issue: (If one exists, link it here) Impact:
Testing:
Testing logs before change: Testing logs after change: |
| #if (!defined(CONFIG_NSH_DISABLE_MEMDUMP) && defined(NSH_HAVE_WRITEFILE)) || \ | ||
| !defined(CONFIG_NSH_DISABLEBG) || defined(CONFIG_NSH_PIPELINE) || \ | ||
| !defined(CONFIG_NSH_DISABLE_WATCH) | ||
| char templine[CONFIG_NSH_LINELEN]; |
There was a problem hiding this comment.
but this will increase the heap consumption for the temp use case.
There was a problem hiding this comment.
Compared with irregular heap access, shared template and will make it more deterministic
There was a problem hiding this comment.
could you split the rename from moving buffer to nsh_vtbl?
There was a problem hiding this comment.
the temp buffer is only used in few command, why move it to nsh_vtbl to extend the life to the whole session?
| /* Trace line buffer */ | ||
|
|
||
| #ifdef CONFIG_SCHED_INSTRUMENTATION_DUMP | ||
| char traceline[CONFIG_NSH_LINELEN]; |
There was a problem hiding this comment.
but traceline is used only when launching program, isn't good to keep the buffer in the whole nsh life cycle
| #if (!defined(CONFIG_NSH_DISABLE_MEMDUMP) && defined(NSH_HAVE_WRITEFILE)) || \ | ||
| !defined(CONFIG_NSH_DISABLEBG) || defined(CONFIG_NSH_PIPELINE) || \ | ||
| !defined(CONFIG_NSH_DISABLE_WATCH) | ||
| char templine[CONFIG_NSH_LINELEN]; |
There was a problem hiding this comment.
the temp buffer is only used in few command, why move it to nsh_vtbl to extend the life to the whole session?
| @@ -380,7 +380,7 @@ | |||
| /* Maximum size of one command line (telnet or serial) */ | |||
|
|
|||
| #ifndef CONFIG_NSH_LINELEN | |||
There was a problem hiding this comment.
let's remove CONFIG_NSH_LINELEN directly
cederom
left a comment
There was a problem hiding this comment.
Thank you @anchao :-) My questions:
- Where
LINE_MAXshould be used and whereCONFIG_NSH_LINELEN? - Where is
LINE_MAXdefined? - Wouldn't that create inconsistency?
- This seems to require a documentation update? Or at least mention on the change and what/where is preferred in regard to above two questions?
Yes, the patch plan to replace all XXX_LINELEN to LINE_MAX.
here: apache/nuttx#15344
no, it improves the consistency, since all places will use the standard macro defined by POSIX.
|
Specifically, limits.h: https://pubs.opengroup.org/onlinepubs/7908799/xsh/limits.h.html Minimum value is _POSIX2_LINE_MAX |
Yup, and the latest one https://pubs.opengroup.org/onlinepubs/9799919799/ :D Thank you @patacongo and @xiaoxiang781216 :-) |
cederom
left a comment
There was a problem hiding this comment.
Thank you @anchao :-)
- Please follow all @xiaoxiang781216 remarks, thank you @xiaoxiang781216 :-)
- Please update commit message
apps/system: replace CONFIG_NSH_LINELEN to LINE_MAXso it includes information that this change follows POSIX Specification https://pubs.opengroup.org/onlinepubs/9799919799/.
|
@anchao do we still need this patch? |
not anymore, let me abandon |
Summary
Applications should not depend on any properties of nshlib
Signed-off-by: chao an anchao@lixiang.com
Signed-off-by: chao an anchao@lixiang.com
Signed-off-by: chao an anchao@lixiang.com
Impact
N/A
Testing
sim/nsh ostest