Skip to content
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

Closed
wants to merge 1 commit into from

Conversation

anankulk
Copy link

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.

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;
Copy link
Contributor

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);
Copy link
Contributor

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
Copy link
Contributor

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.

Copy link
Contributor

@quic-mtharu quic-mtharu left a 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.

@quic-ekangupt
Copy link
Contributor

New PR created: #113

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants