dnl Checks for typedefs, structures, and compiler characteristics.
tinc_ATTRIBUTE(__malloc__)
+tinc_ATTRIBUTE(__nonnull__)
tinc_ATTRIBUTE(__warn_unused_result__)
AC_CHECK_TYPES([struct ether_header, struct arphdr, struct ether_arp, struct ip, struct icmp, struct ip6_hdr, struct icmp6_hdr, struct nd_neighbor_solicit, struct nd_opt_hdr], , ,
// Get the address and port of the first listening socket
char *localhost = NULL;
- sockaddr_t sa;
+ sockaddr_t sa = {0};
socklen_t len = sizeof(sa);
// Make sure we have a valid address, and map 0.0.0.0 and :: to 127.0.0.1 and ::1.
- if(getsockname(listen_socket[0].tcp.fd, (struct sockaddr *)&sa, &len)) {
+ if(getsockname(listen_socket[0].tcp.fd, &sa.sa, &len)) {
xasprintf(&localhost, "127.0.0.1 port %s", myport);
} else {
if(sa.sa.sa_family == AF_INET) {
if(!tty) {
if(!hostname) {
fprintf(stderr, "Could not determine the external address or hostname. Please set Address manually.\n");
+ free(port);
return NULL;
}
if(!fgets(line, sizeof(line), stdin)) {
fprintf(stderr, "Error while reading stdin: %s\n", strerror(errno));
free(hostname);
+ free(port);
return NULL;
}
}
static bool finalize_join(void) {
- char *name = xstrdup(get_value(data, "Name"));
+ const char *name = get_value(data, "Name");
if(!name) {
fprintf(stderr, "No Name found in invitation!\n");
myself->incipher = NULL;
} else if(!(myself->incipher = cipher_open_by_name(cipher))) {
logger(DEBUG_ALWAYS, LOG_ERR, "Unrecognized cipher type!");
+ free(cipher);
return false;
}
myself->indigest = NULL;
} else if(!(myself->indigest = digest_open_by_name(digest, maclength))) {
logger(DEBUG_ALWAYS, LOG_ERR, "Unrecognized digest type!");
+ free(digest);
return false;
}
return success;
}
-int check_port(char *name) {
+int check_port(const char *name) {
if(try_bind(655)) {
return 655;
}
free(line);
rl_basic_word_break_characters = "\t\n ";
line = readline(prompt);
-
- if(line) {
- copy = xstrdup(line);
- }
+ copy = line ? xstrdup(line) : NULL;
} else {
line = fgets(buf, sizeof(buf), stdin);
}
}
if(!strcasecmp(nargv[argc], "exit") || !strcasecmp(nargv[argc], "quit")) {
+#ifdef HAVE_READLINE
+ free(copy);
+#endif
free(nargv);
return result;
}
}
}
+#ifdef HAVE_READLINE
+ free(copy);
+#endif
free(nargv);
if(tty) {
extern bool connect_tincd(bool verbose);
extern bool sendline(int fd, char *format, ...);
extern bool recvline(int fd, char *line, size_t len);
-extern int check_port(char *name);
+extern int check_port(const char *name);
extern FILE *fopenmask(const char *filename, const char *mode, mode_t perms);
extern ecdsa_t *get_pubkey(FILE *f);
return p;
}
-static inline char *xstrdup(const char *s) __attribute__((__malloc__));
+static inline char *xstrdup(const char *s) __attribute__((__malloc__, __nonnull__));
static inline char *xstrdup(const char *s) {
char *p = strdup(s);