commit 60dd2927fea43f88424ea6da3cd2e15cf5843a41
Author: rani <clagv.randomgames@gmail.com>
Date: Sun Jan 08 18:29:55 2023 +0000
diff --git a/src/opts.c b/src/opts.c
index 8c1f0ac..175a3c0 100644
--- a/src/opts.c
+++ b/src/opts.c
@@ -14624 +14625 @@ void read_config(void) {
bool done = false;
// read by line
+ char line[256];
+
while (!done) {
- char line[256] = {0}; // 0 initialize
- char * lp = line;
+ *line = '\0';
+
+ short len = 0; // only needs to go up to 255
// read line from file into buffer
int c;
while ((c = fgetc(fp)) != '\n') {
- if (c == EOF) {
- done = true;
+ if (len >= 255 || c == EOF) {
+ line[len] = '\0';
+ done = c == EOF; // only done at EOF
break;
}
- *lp++ = c;
+ line[len++] = c;
}
- if (!*line) break;
-
-
- parse_var(line);
+ if (*line) parse_var(line);
}
fclose(fp);