Skip to content
This repository has been archived by the owner on May 16, 2020. It is now read-only.

qcommon: fix potential buffer overflow in COM_StripFilename #350

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

Exagone313
Copy link
Contributor

Fixes a potential buffer overflow and a compilation warning (warning: ‘strncpy’ specified bound depends on the length of the source argument [-Wstringop-overflow=]).
The COM_StripFilename function is only used once on a MAX_QPATH sized char array.
Also saw that Q_strncpyz function uses strncpy with len-1 and ensures a NUL at len-1 (so it is safe).

@ensiform
Copy link
Contributor

Probably better to rewrite it with buffer size in parameter list and possibly use strrchr for \ and / depending on platform or if its a qpath then you can do / only.

@Exagone313
Copy link
Contributor Author

Updated prototype of COM_StripFilename for outsize in first commit, and changed COM_SkipPath to use strrchr in the second (rebased just in case).

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
2 participants