Skip to content

Commit

Permalink
Make sure error messages can't overflow a buffer.
Browse files Browse the repository at this point in the history
  Fixes Bugzilla #840.
  • Loading branch information
icculus committed Oct 12, 2009
1 parent 75e512a commit e00b9e9
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
2 changes: 2 additions & 0 deletions timidity/config.h
Expand Up @@ -22,6 +22,8 @@
#include "SDL_config.h"
#include "SDL_endian.h"

#define TIMIDITY_ERROR_SIZE 1024

/* When a patch file can't be opened, one of these extensions is
appended to the filename and the open is tried again.
*/
Expand Down
2 changes: 1 addition & 1 deletion timidity/sdl_c.c
Expand Up @@ -115,7 +115,7 @@ static int cmsg(int type, int verbosity_level, char *fmt, ...)
ctl.verbosity<verbosity_level)
return 0;
va_start(ap, fmt);
vsprintf(timidity_error, fmt, ap);
SDL_vsnprintf(timidity_error, TIMIDITY_ERROR_SIZE, fmt, ap);
va_end(ap);
return 0;
#endif
Expand Down
3 changes: 2 additions & 1 deletion timidity/timidity.c
Expand Up @@ -367,8 +367,9 @@ int Timidity_Init(int rate, int format, int channels, int samples)
return(0);
}

char timidity_error[1024] = "";
char timidity_error[TIMIDITY_ERROR_SIZE] = "";
const char *Timidity_Error(void)
{
return(timidity_error);
}

0 comments on commit e00b9e9

Please sign in to comment.