projects
/
tinc
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix crash when no netname is specified.
[tinc]
/
src
/
tincctl.c
diff --git
a/src/tincctl.c
b/src/tincctl.c
index
b944e5c
..
ca354bc
100644
(file)
--- a/
src/tincctl.c
+++ b/
src/tincctl.c
@@
-187,11
+187,15
@@
static bool parse_options(int argc, char **argv) {
}
}
}
}
- if(!netname) {
- netname = getenv("NETNAME");
- if(netname)
- netname = xstrdup(netname);
- }
+ if(!netname && (netname = getenv("NETNAME")))
+ netname = xstrdup(netname);
+
+ /* netname "." is special: a "top-level name" */
+
+ if(netname && !strcmp(netname, ".")) {
+ free(netname);
+ netname = NULL;
+ }
return true;
}
return true;
}
@@
-1190,7
+1194,7
@@
static int cmd_config(int argc, char *argv[]) {
while(fgets(buf1, sizeof buf1, f)) {
buf1[sizeof buf1 - 1] = 0;
while(fgets(buf1, sizeof buf1, f)) {
buf1[sizeof buf1 - 1] = 0;
- str
cpy(buf2, buf1
);
+ str
ncpy(buf2, buf1, sizeof buf2
);
// Parse line in a simple way
char *bvalue;
// Parse line in a simple way
char *bvalue;
@@
-1234,6
+1238,14
@@
static int cmd_config(int argc, char *argv[]) {
fprintf(stderr, "Error writing to temporary file %s: %s\n", tmpfile, strerror(errno));
return 1;
}
fprintf(stderr, "Error writing to temporary file %s: %s\n", tmpfile, strerror(errno));
return 1;
}
+
+ // Add newline if it is missing...
+ if(*buf1 && buf1[strlen(buf1) - 1] != '\n') {
+ if(fputc('\n', tf) < 0) {
+ fprintf(stderr, "Error writing to temporary file %s: %s\n", tmpfile, strerror(errno));
+ return 1;
+ }
+ }
}
// Make sure we read everything...
}
// Make sure we read everything...