fix version string buffer overflow (#327)
This commit is contained in:
parent
db940ef1dd
commit
cc330121b3
|
@ -3,7 +3,7 @@
|
|||
#include "types.h"
|
||||
|
||||
static char sVersionString[MAX_VERSION_LENGTH] = { 0 };
|
||||
static char sLocalVersionString[MAX_VERSION_LENGTH] = { 0 };
|
||||
static char sLocalVersionString[MAX_LOCAL_VERSION_LENGTH] = { 0 };
|
||||
|
||||
char* get_version(void) {
|
||||
snprintf(sVersionString, MAX_VERSION_LENGTH, "%s %d.%d", VERSION_TEXT, VERSION_NUMBER, MINOR_VERSION_NUMBER);
|
||||
|
@ -11,6 +11,9 @@ char* get_version(void) {
|
|||
}
|
||||
|
||||
char* get_version_local(void) {
|
||||
if (PATCH_VERSION_NUMBER <= 0) {
|
||||
return get_version();
|
||||
}
|
||||
snprintf(sLocalVersionString, MAX_LOCAL_VERSION_LENGTH, "%s %d.%d.%d", VERSION_TEXT, VERSION_NUMBER, MINOR_VERSION_NUMBER, PATCH_VERSION_NUMBER);
|
||||
return sLocalVersionString;
|
||||
}
|
||||
|
|
|
@ -4,10 +4,10 @@
|
|||
#define VERSION_TEXT "beta"
|
||||
#define VERSION_NUMBER 32
|
||||
#define MINOR_VERSION_NUMBER 0
|
||||
#define PATCH_VERSION_NUMBER 2
|
||||
#define PATCH_VERSION_NUMBER 3
|
||||
|
||||
#define MAX_VERSION_LENGTH 10
|
||||
#define MAX_LOCAL_VERSION_LENGTH 12
|
||||
#define MAX_LOCAL_VERSION_LENGTH 11
|
||||
char* get_version(void);
|
||||
char* get_version_local(void);
|
||||
|
||||
|
|
Loading…
Reference in New Issue