Skip to content

Commit 37f6eaf

Browse files
committed
inivar: get rid of LINELEN-sized buffers where unneeded
1 parent 118a8fc commit 37f6eaf

File tree

1 file changed

+7
-11
lines changed

1 file changed

+7
-11
lines changed

src/libnml/inifile/inivar.cc

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,9 @@ int main(int argc, char *argv[])
3535
{
3636
int t;
3737
int num = 1;
38-
char _variable[LINELEN] = "";
39-
char *variable = 0;
40-
char _section[LINELEN] = "";
41-
char *section = 0;
42-
char path[LINELEN] = "emc.ini";
38+
const char *variable = 0;
39+
const char *section = 0;
40+
const char *path = "emc.ini";
4341
const char *inistring;
4442
int retval;
4543
bool tildeexpand=false;
@@ -53,7 +51,7 @@ int main(int argc, char *argv[])
5351
"%s: ini file not specified after -ini\n", argv[0]);
5452
exit(1);
5553
} else {
56-
strncpy(path, argv[t + 1], LINELEN);
54+
path = argv[t+1];
5755
t++; /* step over following arg */
5856
}
5957
} else if (!strcmp(argv[t], "-var")) {
@@ -63,8 +61,7 @@ int main(int argc, char *argv[])
6361
"%s: variable name not specified after -var\n", argv[0]);
6462
exit(1);
6563
} else {
66-
strncpy(_variable, argv[t + 1], LINELEN);
67-
variable = _variable;
64+
variable = argv[t+1];
6865
t++; /* step over following arg */
6966
}
7067
} else if (!strcmp(argv[t], "-sec")) {
@@ -74,8 +71,7 @@ int main(int argc, char *argv[])
7471
"%s: section name not specified after -sec\n", argv[0]);
7572
exit(1);
7673
} else {
77-
strncpy(_section, argv[t + 1], LINELEN);
78-
section = _section;
74+
section = argv[t+1];
7975
t++; /* step over following arg */
8076
}
8177
} else if (!strcmp(argv[t], "-num")) {
@@ -97,7 +93,7 @@ int main(int argc, char *argv[])
9793
} else{
9894
/* invalid argument */
9995
fprintf(stderr,
100-
"%s: -var <variable> {-sec <section>} {<-ini inifile>} [-num <nth item>]\n",
96+
"%s: -var <variable> {-tildeexpand} {-sec <section>} {<-ini inifile>} [-num <nth item>]\n",
10197
argv[0]);
10298
exit(1);
10399
}

0 commit comments

Comments
 (0)