Fix warning about sprintf() and NSTAT_HIST
The environment variable could contain format characters, causing problems. Better to just use it directly.
This commit is contained in:
parent
985f4578c6
commit
896ebd6c70
|
|
@ -445,7 +445,7 @@ static void usage(void)
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
char hist_name[128];
|
char *hist_name;
|
||||||
struct sockaddr_un sun;
|
struct sockaddr_un sun;
|
||||||
FILE *hist_fp = NULL;
|
FILE *hist_fp = NULL;
|
||||||
int ch;
|
int ch;
|
||||||
|
|
@ -526,10 +526,10 @@ int main(int argc, char *argv[])
|
||||||
patterns = argv;
|
patterns = argv;
|
||||||
npatterns = argc;
|
npatterns = argc;
|
||||||
|
|
||||||
if (getenv("NSTAT_HISTORY"))
|
if ((hist_name = getenv("NSTAT_HISTORY")) == NULL) {
|
||||||
snprintf(hist_name, sizeof(hist_name), getenv("NSTAT_HISTORY"));
|
hist_name = malloc(128);
|
||||||
else
|
|
||||||
sprintf(hist_name, "/tmp/.nstat.u%d", getuid());
|
sprintf(hist_name, "/tmp/.nstat.u%d", getuid());
|
||||||
|
}
|
||||||
|
|
||||||
if (reset_history)
|
if (reset_history)
|
||||||
unlink(hist_name);
|
unlink(hist_name);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue