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

Commit

Permalink
qcommon: fix potential buffer overflow in COM_StripFilename
Browse files Browse the repository at this point in the history
  • Loading branch information
Exagone313 committed Jan 28, 2019
1 parent fba998d commit 13326e2
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/cgame/cg_sound.c
Original file line number Diff line number Diff line change
Expand Up @@ -1327,7 +1327,7 @@ qboolean CG_SpeakerEditor_NoiseEdit_KeyDown(panel_button_t *button, int key)
int i, numfiles, filelen;
char *fileptr;

COM_StripFilename(button->text, dirname);
COM_StripFilename(button->text, dirname, sizeof(dirname));
Q_strncpyz(filename, COM_SkipPath(button->text), sizeof(filename));

if (!Q_stricmp(button->text, dirname))
Expand Down
4 changes: 2 additions & 2 deletions src/qcommon/q_shared.c
Original file line number Diff line number Diff line change
Expand Up @@ -166,11 +166,11 @@ qboolean COM_CompareExtension(const char *in, const char *ext)
* @param[in] in
* @param[out] out
*/
void COM_StripFilename(const char *in, char *out)
void COM_StripFilename(const char *in, char *out, size_t outsize)
{
char *end;

Q_strncpyz(out, in, strlen(in) + 1);
Q_strncpyz(out, in, outsize);
end = COM_SkipPath(out);
*end = 0;
}
Expand Down
2 changes: 1 addition & 1 deletion src/qcommon/q_shared.h
Original file line number Diff line number Diff line change
Expand Up @@ -610,7 +610,7 @@ void COM_FixPath(char *pathname);
const char *COM_GetExtension(const char *name);
void COM_StripExtension(const char *in, char *out, int destsize);
qboolean COM_CompareExtension(const char *in, const char *ext);
void COM_StripFilename(const char *in, char *out);
void COM_StripFilename(const char *in, char *out, size_t outsize);

void COM_DefaultExtension(char *path, size_t maxSize, const char *extension);

Expand Down

0 comments on commit 13326e2

Please sign in to comment.