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

ASAN/UBSAN fixes #582

Merged
merged 3 commits into from
Sep 21, 2024
Merged

ASAN/UBSAN fixes #582

merged 3 commits into from
Sep 21, 2024

Conversation

jengelh
Copy link
Contributor

@jengelh jengelh commented Sep 9, 2024

Pull Request Type

  • Runtime changes
    • Other changes

Description

lesser UBSAN fixes

Checklist

  • I have tested my changes locally and verified that they work as intended.
  • I have reviewed the changes to ensure they do not introduce any unnecessary complexity or duplicate code.
  • I understand that by submitting this pull request, I am agreeing to license my contributions under the project's license.

sndlib/mixer.cpp:496:61: runtime error: left shift of negative value -1
sndlib/mixer.cpp:333:74: runtime error: left shift of negative value -1
sndlib/mixer.cpp:331:115: runtime error: left shift of negative value -2

x<<y is UB for y<0 or x<0. Using a multiply side-steps this (and compilers
optimize multiplies to the same ASM anyway).
lib/grdefs.h Outdated Show resolved Hide resolved
lib/grdefs.h Show resolved Hide resolved
$GIT/lib/grdefs.h:85:67: runtime error: left shift of negative value -1
$GIT/lib/grdefs.h:85:79: runtime error: left shift of negative value -1

This happens because of:

grtext/grtext.cpp:966
966           col = GR_RGB(str[i + 1], str[i + 2], str[i + 3]);
(gdb) p str
$2 = 0x46437fe <Grtext_buffer+62> "\001\377\377\377Max. Trans-Atmospheric"
(gdb) ptyp str
type = char *

Make GR_RGB take uint8_ts, which causes the desired conversion at
GR_RGB callsites.
Descent3/aipath.cpp:663:40: runtime error: index -1 out of bounds for type
'short unsigned int [5]'

Fixes: bb1d6f6
@winterheart
Copy link
Collaborator

Tested on Linux, no issues found.

@winterheart winterheart merged commit 39e128c into DescentDevelopers:main Sep 21, 2024
10 checks passed
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