Increased maximum path length from 180 to 255, and replaced sprintf with snprintf to prevent buffer overflow.

This commit is contained in:
vraatikka
2013-08-23 22:27:40 +03:00
parent 68a5a389ee
commit c9ff06e0f5

View File

@ -57,15 +57,18 @@ int i;
static MAXKEYS * static MAXKEYS *
secrets_readKeys() secrets_readKeys()
{ {
char secret_file[180]; char secret_file[255];
char *home; char *home;
MAXKEYS *keys; MAXKEYS *keys;
struct stat secret_stats; struct stat secret_stats;
int fd; int fd;
if ((home = getenv("MAXSCALE_HOME")) == NULL) home = getenv("MAXSCALE_HOME");
home = "/usr/local/skysql/MaxScale";
sprintf(secret_file, "%s/etc/.secrets", home); if (home == NULL) {
home = "/usr/local/skysql/MaxScale";
}
snprintf(secret_file, 255, "%s/etc/.secrets", home);
/* Silently check for a .secrets file */ /* Silently check for a .secrets file */
if (access(secret_file, R_OK) == -1) if (access(secret_file, R_OK) == -1)