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

Update prototype of copyinstr() #113

Open
kvanhees opened this issue Nov 21, 2024 · 0 comments
Open

Update prototype of copyinstr() #113

kvanhees opened this issue Nov 21, 2024 · 0 comments

Comments

@kvanhees
Copy link
Member

The copyinstr() subroutine is declared as:

stirng copyinstr(uintptr_t addr [, size_t maxlen])

which in some aspects makes sense because it is to read bytes from a given userspace address (up to a terminating 0-byte or a given maximum length if specified). However, this results in the odd circumstance that if a variable is of datatype char *, a (uintptr_t) cast is necessary because char * and uintptr_t are not compatible. But this subroutine is to be used explicitly for reading in strings from userspace and that is often done to get the value of USDT probe arguments and we have type information for those (by using the args[] elements). Also, even if we do not have type information, the very fact that we are trying to read a string seems to imply that requiring a char *) cast would be a lot more understandable than needing to cast char * to uintptr_t.

Changing the prototype of copyinstr() seems a sensible change. However, we should consider the impact that any scripts that people may already have written will likely include these crazy (uintptr_t) casts that would (with this change) result in a compilation failure, again, uintptr_t vs char *.

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

No branches or pull requests

1 participant