-
Notifications
You must be signed in to change notification settings - Fork 565
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
apps/system: replace CONFIG_NSH_LINELEN to LINE_MAX #2918
base: master
Are you sure you want to change the base?
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but this will increase the heap consumption for the temp use case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Compared with irregular heap access, shared template and will make it more deterministic
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could you split the rename from moving buffer to nsh_vtbl?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's remove CONFIG_NSH_LINELEN directly
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you @anchao :-) My questions:
- Where
LINE_MAX
should be used and whereCONFIG_NSH_LINELEN
? - Where is
LINE_MAX
defined? - 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 :-) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you @anchao :-)
- Please follow all @xiaoxiang781216 remarks, thank you @xiaoxiang781216 :-)
- Please update commit message
apps/system: replace CONFIG_NSH_LINELEN to LINE_MAX
so it includes information that this change follows POSIX Specification https://pubs.opengroup.org/onlinepubs/9799919799/.
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