Skip to content

Handle returnValue and add rc/rsn to socket trace - #548

Open
1000TurquoisePogs wants to merge 3 commits into
v3.x/stagingfrom
feature/ipv4-get-host-by-name
Open

Handle returnValue and add rc/rsn to socket trace#548
1000TurquoisePogs wants to merge 3 commits into
v3.x/stagingfrom
feature/ipv4-get-host-by-name

Conversation

@1000TurquoisePogs

Copy link
Copy Markdown
Member

To trace zowe/zss#794, I need to see rc/rsn that aren't handled thus far.
This PR prints them in socketTrace
But also, I saw the TBD message about that none of them are even inspected. I added handling of returnValue.

Signed-off-by: 1000TurquoisePogs <sgrady@rocketsoftware.com>
@github-actions github-actions Bot added the stale-reopen-if-needed An issue closed due to inactivity. No indication of completion or validity. label Feb 10, 2026
@sonarqubecloud

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
C Maintainability Rating on New Code (required ≥ A)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

@github-actions github-actions Bot removed the stale-reopen-if-needed An issue closed due to inactivity. No indication of completion or validity. label Mar 11, 2026
JoeNemo added 2 commits August 8, 2026 01:47
The socket trace claimed to print the hostent address but printed
*((int*)hostEntPtr) -- the first four bytes of the struct, which is half
of its name pointer, under a label saying otherwise. On z/OS that is the
high half, so for storage below the bar it printed zero whether the
lookup succeeded or failed. Anyone who switched socketTrace on to
diagnose a resolution problem was reading a number that meant nothing.

%p prints what the label promises and does not follow the pointer, which
also removes a dereference that ran before anything established the
pointer was usable.

hostEntPtr is now initialised. BPXGHN leaves Hostent_ptr alone when the
lookup fails, so it held whatever the stack contained; getV4HostEntByName
returns it directly, so callers were handed that. Verified with
MemorySanitizer against the real function: staging reports
use-of-uninitialized-value on a failed lookup with tracing off and on,
and neither reports it after this change.

Signed-off-by: JoeNemo <joe.devlin@gmail.com>
hostent->length is the width of one address -- 4 for IPv4 -- not how
many addresses came back, so using it as a loop bound reads up to four
entries regardless of how many exist. AddressSanitizer reports a
stack-buffer-overflow on a host that resolves to an empty list: the
array holds only its terminator and the loop reads three entries past
it. addrList is null-terminated, so the terminator is the bound.

Selecting the first address is unchanged: verified identical for one
address, several addresses, an empty list, and a list whose first
non-null entry is late.

The trace now prints the address that was found, dotted-quad and hex,
rather than the pointer holding it -- which is what someone turning
socketTrace on to diagnose a lookup wants to see. It walks the whole
list, since knowing a name resolved to more than one address is part of
the diagnosis.

Dropped an unused local.

Signed-off-by: JoeNemo <joe.devlin@gmail.com>
@JoeNemo
JoeNemo force-pushed the feature/ipv4-get-host-by-name branch from c7eb6d3 to ec65753 Compare August 8, 2026 06:26
@sonarqubecloud

sonarqubecloud Bot commented Aug 8, 2026

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
3.6% Duplication on New Code (required ≤ 3%)

See analysis details on SonarQube Cloud

@JoeNemo JoeNemo left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I don't think this code is called. But your intent for this PR was valid and I can't remove a public API mid-release. But I needed to do some fixes for things that were latent memory errors, not introduced by your change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

2 participants