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

Trim env var for startup check #395

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion c/le.c
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,12 @@ void abortIfUnsupportedCAA() {
#ifndef METTLE
if (zosVersion > LE_MAX_SUPPORTED_ZOS) {
const char *continueWithWarning = getenv("ZWE_zowe_launcher_unsafeDisableZosVersionCheck");
if (!strcmp(continueWithWarning, "true")) {
/* using STDENV in JCL can result in env values that need trimming... */
char *trimmed[strlen(continueWithWarning)+1];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JoeNemo just pointed to a bug here. This shouldn't have *.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you just save the length once and reuse it?

size_t valueLen = strlen(continueWithWarning);

strncpy(trimmed, continueWithWarning, strlen(continueWithWarning));
Copy link
Contributor

@ifakhrutdinov ifakhrutdinov Aug 23, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will leave the destination unterminated because trimmed isn't initialized to zeroes; trimRight may 0C4.

trimRight(trimmed, strlen(trimmed));

if (!strcmp(trimmed, "true")) {
printf("warning: z/OS version = 0x%08X, max supported version = 0x%08X - "
"CAA fields require verification\n", zosVersion, LE_MAX_SUPPORTED_ZOS);
} else {
Expand Down
Loading