projects
/
tinc
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
b6b302c
)
Fix the "network" command in tinc shell.
author
Guus Sliepen
<guus@tinc-vpn.org>
Sun, 17 Apr 2016 16:11:04 +0000
(18:11 +0200)
committer
Guus Sliepen
<guus@tinc-vpn.org>
Sun, 17 Apr 2016 16:11:04 +0000
(18:11 +0200)
src/names.c
patch
|
blob
|
history
src/tincctl.c
patch
|
blob
|
history
diff --git
a/src/names.c
b/src/names.c
index
a640fe4
..
6c518f2
100644
(file)
--- a/
src/names.c
+++ b/
src/names.c
@@
-137,4
+137,12
@@
void free_names(void) {
free(logfilename);
free(confbase);
free(confdir);
free(logfilename);
free(confbase);
free(confdir);
+
+ identname = NULL;
+ netname = NULL;
+ unixsocketname = NULL;
+ pidfilename = NULL;
+ logfilename = NULL;
+ confbase = NULL;
+ confdir = NULL;
}
}
diff --git
a/src/tincctl.c
b/src/tincctl.c
index
9687ba4
..
4231cce
100644
(file)
--- a/
src/tincctl.c
+++ b/
src/tincctl.c
@@
-2284,26
+2284,29
@@
static int cmd_exchange_all(int argc, char *argv[]) {
}
static int switch_network(char *name) {
}
static int switch_network(char *name) {
+ if(strcmp(name, ".")) {
+ if(!check_netname(name, false)) {
+ fprintf(stderr, "Invalid character in netname!\n");
+ return 1;
+ }
+
+ if(!check_netname(name, true))
+ fprintf(stderr, "Warning: unsafe character in netname!\n");
+ }
+
if(fd >= 0) {
close(fd);
fd = -1;
}
if(fd >= 0) {
close(fd);
fd = -1;
}
- free(confbase);
- confbase = NULL;
- free(pidfilename);
- pidfilename = NULL;
- free(logfilename);
- logfilename = NULL;
- free(unixsocketname);
- unixsocketname = NULL;
+ free_names();
+ netname = strcmp(name, ".") ? xstrdup(name) : NULL;
+ make_names(false);
+
free(tinc_conf);
free(hosts_dir);
free(prompt);
free(tinc_conf);
free(hosts_dir);
free(prompt);
- free(netname);
- netname = strcmp(name, ".") ? xstrdup(name) : NULL;
-
xasprintf(&tinc_conf, "%s" SLASH "tinc.conf", confbase);
xasprintf(&hosts_dir, "%s" SLASH "hosts", confbase);
xasprintf(&prompt, "%s> ", identname);
xasprintf(&tinc_conf, "%s" SLASH "tinc.conf", confbase);
xasprintf(&hosts_dir, "%s" SLASH "hosts", confbase);
xasprintf(&prompt, "%s> ", identname);