-
Notifications
You must be signed in to change notification settings - Fork 28
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
Resolving the buffer accessed out of bound issue #86
Conversation
While packing shared buffer with names of all shared objects present in custom DSP_LIBRARY_PATH , their is a possibility of buffer overflow if the shared object names are exceeding the desired limit.The change makes sure the limit is not exceeded thus avoiding buffer overflow. Also, the buffer was allocated with 1KB memory which might fall short to accomodate all the needed shared object names so, increasing this size to 2KB. Signed-off-by: Anand Kulkarni <quic_anankulk@quicinc.com>
if (concat_len + std_strlen(file) > MAX_NON_PRELOAD_LIBS_LEN) { | ||
FARF(ALWAYS,"ERROR: Failed to pack library names in custom DSP_LIBRARY_PATH as required buffer size exceeds Max limit (%d).", MAX_NON_PRELOAD_LIBS_LEN); | ||
nErr = AEE_EBUFFERTOOSMALL; | ||
goto bail; |
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.
Please ensure to call closedir(dir) after opendir(path) to prevent a possible resource leak. This is crucial for proper resource management.
VERIFYC(NULL != (data_paths = calloc(1, sizeof(char) * ENV_PATH_LEN)), AEE_ENOMEMORY); | ||
VERIFY(AEE_SUCCESS == (nErr = apps_std_getenv(DSP_LIBRARY_PATH, data_paths, ENV_PATH_LEN, &env_list_len))); | ||
VERIFYC(AEE_SUCCESS == apps_std_getenv(DSP_LIBRARY_PATH, data_paths, ENV_PATH_LEN, &env_list_len), AEE_EGETENV); |
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.
instead of fixing the size of ENV_PATH_LEN to 256, Can we read the size of ENV_PATH_LEN by std_strlen(DSP_SEARCH_PATH)+1 and allocate the same amount of memory to data_paths
@@ -22,6 +22,8 @@ | |||
#define PROC_SHAREDBUF_SIZE (4*1024) | |||
#define ENV_PATH_LEN 256 |
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.
Can we define all these macros in apps_std_internal.h
where our DSP_LIBRARY_PATH macro is defined.
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.
Please ensure to call closedir(dir) after opendir(path) to prevent a possible resource leak. This is crucial for proper resource management.
Instead of fixing the size of ENV_PATH_LEN to 256, can we determine the size of ENV_PATH_LEN using strlen(DSP_SEARCH_PATH) + 1 and allocate the same amount of memory to data_paths?
Additionally, consider relocating all macros to the header file.
New PR created: #113 |
While packing shared buffer with names of all shared objects present in custom DSP_LIBRARY_PATH , their is a possibility of buffer overflow if the shared object names are exceeding the desired limit.The change makes sure the limit is not exceeded thus avoiding buffer overflow. Also, the buffer was allocated with 1KB memory which might fall short to accomodate all the needed shared object names so, increasing this size to 2KB.