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

Suspicious places in the application source code #334

Closed
Yugend opened this issue Dec 7, 2023 · 1 comment
Closed

Suspicious places in the application source code #334

Yugend opened this issue Dec 7, 2023 · 1 comment

Comments

@Yugend
Copy link

Yugend commented Dec 7, 2023

I was looking through the source code of sudo and found four suspicious places:

  1. The first one is in the plugins/sudoers/sudoreplay.c file, 634 line. The second statement "if" looks strange, as if it's a misprint.
  2. The next place is in the same directory in tsdump.c file, 223, 228 lines. The 'first' variable is initialized True value, does not change in any way, and is then used when checking in the printf function call.
  3. The third one is in the lib/protobuf-c/protobuf.c file, 2572 and 2574 lines. the pointer 'pstr' is checked twice for NULL, probably the second time it is not necessary..
  4. And the last one I found in the plugins/sample/sample_plugin.c file, 162, 172 lines. In line 172 the pointer 'cp' is used which can be NULL if the 'strchr' function does not find a colon in the 'path' variable. As far as I know, this can lead to undefined behavior.

Perhaps there is some sense in this, but I did not understand it. In that case, I'm sorry to disturb you.


sid@itb.spb.ru | "Innovative Technologies in Business" LLC | https://www.itb.spb.ru/

@millert
Copy link
Collaborator

millert commented Dec 7, 2023

  1. Thanks, that was an editor error. It is fixed by d17e28a.
  2. "first" is negated after the first flag is printed, which causes subsequent flags to be separated by a comma. The static analyzer you used probably complained that "first" is always true for line 228. That is intentional as it keeps the code to print the flags consistent.
  3. That code comes from the protobuf-c project, I try to avoid making unnecessary changes.
  4. This doesn't really matter since "path" is unused if cp is NULL.

@millert millert closed this as completed Dec 7, 2023
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

2 participants