projects
/
tinc
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
tincctl: Use replace_name to properly replace and validate input hostnames
[tinc]
/
src
/
utils.c
diff --git
a/src/utils.c
b/src/utils.c
index
797bc3f
..
8fbc710
100644
(file)
--- a/
src/utils.c
+++ b/
src/utils.c
@@
-18,11
+18,10
@@
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
+#include "logger.h"
#include "system.h"
#include "system.h"
-#include "xalloc.h"
-
-#include "../src/logger.h"
#include "utils.h"
#include "utils.h"
+#include "xalloc.h"
static const char hexadecimals[] = "0123456789ABCDEF";
static const char base64_original[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
static const char hexadecimals[] = "0123456789ABCDEF";
static const char base64_original[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
@@
-181,6
+180,17
@@
unsigned int bitfield_to_int(const void *bitfield, size_t size) {
return value;
}
return value;
}
+bool check_id(const char *id) {
+ if(!id || !*id)
+ return false;
+
+ for(; *id; id++)
+ if(!isalnum(*id) && *id != '_')
+ return false;
+
+ return true;
+}
+
char *replace_name(const char *name) {
char *ret_name;
char *replace_name(const char *name) {
char *ret_name;