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

Various enhancements for zopen tools #58

Open
wants to merge 40 commits into
base: main
Choose a base branch
from
Open

Conversation

IgorTodorovskiIBM
Copy link
Collaborator

@IgorTodorovskiIBM IgorTodorovskiIBM commented Apr 22, 2024

  • pthread_create-created threads do not set autocvt by default. This can be problematic if _BPXK_AUTOCVT is unset in the user environment. This PR adds a change to override pthread_create which sets AUTOCVT=ON in a similar way to the startup routine in zos.cc.
  • adds netinet/in_systm.h is missing, affects honggfuzz and nmap
  • adds getline and getdelim - affects honggfuzz, libssh2 and moreutils
  • Adds _SC_NPROCESSORS_ONLN to sysconf - encountered too many times and rather than editing the application code, I extended sysconf to support _SC_NPROCESSORS_ONLN
  • It also modifies the untagged read heuristic to remove the restriction on the min required bytes (currently set to 8 bytes). The reason for this is that there are <8 byte EBCDIC files such as /etc/syslog.pid and /etc/sshd.pid and based on user experience, untagged files which are small in size typically contain EBCDIC data and not binary data or ascii data so we should lean towards marking it as EBCDIC. Additionally, all z/OS Open Tools tag their data. Note, the __UNTAGGED_READ_MODE environment variable still takes precedence when set but most users do not set this environment variable.
  • Also changes chgfdccsid to not set the txtflag when ccsid = 0
  • Adds more tests

@IgorTodorovskiIBM IgorTodorovskiIBM marked this pull request as draft April 22, 2024 23:47
if (ccsid == 1047 && len == cnt) {
if (no_tag_read_behaviour == __NO_TAG_READ_DEFAULT_WITHWARNING) {
if (name) {
len = strlen(name) + 1;
Copy link
Collaborator

Choose a reason for hiding this comment

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

minor thing but i would typically have len be the strlen and then allocate the buffer to len+1 since you don't need to convert a 0 to a 0.
But perhaps just me.

}
} // cnt > 8
fdcache.set_attribute(fd, 0x0000000000020000UL);
Copy link
Collaborator

Choose a reason for hiding this comment

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

use a name for the magic number?

src/zos-io.cc Outdated
size_t pos = 0;

if (*lineptr == NULL || *n == 0) {
*n = 128;
Copy link
Collaborator

Choose a reason for hiding this comment

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

why 128? and why 2 farther down? would those be good to have as buffer length and growth size macros (assuming that's what they are?)

src/zos-io.cc Outdated
int c;

if (buf == NULL || bufsize == 0) {
bufsize = 128;
Copy link
Collaborator

Choose a reason for hiding this comment

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

same comment as above.

Copy link
Collaborator

@MikeFultonDev MikeFultonDev left a comment

Choose a reason for hiding this comment

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

reviewed - minor comments.

@IgorTodorovskiIBM
Copy link
Collaborator Author

Added a readlink override to address zopencommunity/coreutilsport#74 and zopencommunity/gitport#122

src/zos-io.cc Outdated
*lineptr = (char *)malloc(*n);
if (*lineptr == NULL || *n == 0) {
*n = 120;
*lineptr = (char *)realloc(*lineptr, *n);
Copy link

@AnthonyGiorgio AnthonyGiorgio Jul 16, 2024

Choose a reason for hiding this comment

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

Calling realloc() this way is incorrect. If the memory allocation fails, then the original value of lineptr is lost, and the memory it pointed to is leaked. cppcheck complains about this, and suggests you use a temporary pointer to hold the return value, and then assign it to lineptr after validation.

https://stackoverflow.com/questions/21006707/proper-usage-of-realloc

@IgorTodorovskiIBM IgorTodorovskiIBM marked this pull request as ready for review July 16, 2024 17:43
Comment on lines 129 to 131
void *cur_dsa = __dsa();

__iterate_stack_and_get(cur_dsa, &si);
Copy link
Member

Choose a reason for hiding this comment

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

Suggest checking return value from these two functions; if NULL, perhaps set the entry_name in the json entry to indicate that the stack could not be traversed. Same for the exit function below.

size_t len = l_len - s_len + 1;
for (size_t i = 0; i < len; i++)
if (cs[0] == cl[i] && memcmp(cl + i, cs, s_len) == 0)
return (void *)(cl + i);
Copy link
Member

Choose a reason for hiding this comment

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

Extra indentation spaces here and in strverscmp() below.

@@ -36,6 +36,10 @@ COMMAND /bin/as -mgoff -o ${CELQUOPT_OBJECT} ${CELQUOPT_SOURCE}
VERBATIM
)

if(${CMAKE_C_COMPILER} MATCHES clang)
Copy link
Member

Choose a reason for hiding this comment

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

Suggest checking if ! xlclang, since compiler can also be ibm-clang.

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.

8 participants