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

Conversation

1000TurquoisePogs
Copy link
Member

Like in the launcher, any code that's expected to be run with env vars set from JCL should also expect that env vars can come in with trailing spaces.
This is a little ugly but the version-checking code in this PR is expected to be entirely removed soon, so this is another stop-gap to get people able to use zowe on untested versions of zos.

Signed-off-by: 1000TurquoisePogs <[email protected]>
Signed-off-by: 1000TurquoisePogs <[email protected]>
if (!strcmp(continueWithWarning, "true")) {
/* using STDENV in JCL can result in env values that need trimming... */
char *trimmed[strlen(continueWithWarning)+1];
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.

@@ -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 *.

@@ -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.

Can you just save the length once and reuse it?

size_t valueLen = strlen(continueWithWarning);

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.

2 participants