/* config.h.in. Generated from configure.ac by autoheader. */
+/* apply the noreturn attribute to a function that exits the program */
+#undef ATTR_NORETURN
+
/* Directory to chroot to */
#undef CHROOT_DIR
/* Whether the C compiler accepts the "format" attribute */
#undef HAVE_ATTR_FORMAT
+/* Whether the C compiler accepts the "noreturn" attribute */
+#undef HAVE_ATTR_NORETURN
+
/* Whether the C compiler accepts the "unused" attribute */
#undef HAVE_ATTR_UNUSED
fi
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C compiler (${CC-cc}) accepts the \"noreturn\" attribute" >&5
+$as_echo_n "checking whether the C compiler (${CC-cc}) accepts the \"noreturn\" attribute... " >&6; }
+if ${ac_cv_c_noreturn_attribute+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ ac_cv_c_noreturn_attribute=no
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+ #include <stdio.h>
+__attribute__((noreturn)) void f(int x) { printf("%d", x); }
+
+int
+main ()
+{
+
+ f(1);
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+ ac_cv_c_noreturn_attribute="yes"
+else
+ ac_cv_c_noreturn_attribute="no"
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+
+fi
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_noreturn_attribute" >&5
+$as_echo "$ac_cv_c_noreturn_attribute" >&6; }
+if test $ac_cv_c_noreturn_attribute = yes; then
+
+$as_echo "#define HAVE_ATTR_NORETURN 1" >>confdefs.h
+
+
+$as_echo "#define ATTR_NORETURN __attribute__((__noreturn__))" >>confdefs.h
+
+fi
+
+
if test "$srcdir" != "."; then
CPPFLAGS="$CPPFLAGS -I$srcdir"
fi
AC_MSG_RESULT($ac_cv_c_weak_attribute)
if test $ac_cv_c_weak_attribute = yes; then
AC_DEFINE(HAVE_ATTR_WEAK, 1, [Whether the C compiler accepts the "weak" attribute])
+ AC_DEFINE(ATTR_WEAK, [__attribute__((weak))], [apply the weak attribute to a symbol])
fi
])dnl End of CHECK_WEAK_ATTRIBUTE
CHECK_WEAK_ATTRIBUTE
+AC_DEFUN([CHECK_NORETURN_ATTRIBUTE],
+[AC_REQUIRE([AC_PROG_CC])
+AC_MSG_CHECKING(whether the C compiler (${CC-cc}) accepts the "noreturn" attribute)
+AC_CACHE_VAL(ac_cv_c_noreturn_attribute,
+[ac_cv_c_noreturn_attribute=no
+AC_TRY_COMPILE(
+[ #include <stdio.h>
+__attribute__((noreturn)) void f(int x) { printf("%d", x); }
+], [
+ f(1);
+],
+[ac_cv_c_noreturn_attribute="yes"],
+[ac_cv_c_noreturn_attribute="no"])
+])
+
+AC_MSG_RESULT($ac_cv_c_noreturn_attribute)
+if test $ac_cv_c_noreturn_attribute = yes; then
+ AC_DEFINE(HAVE_ATTR_NORETURN, 1, [Whether the C compiler accepts the "noreturn" attribute])
+ AC_DEFINE(ATTR_NORETURN, [__attribute__((__noreturn__))], [apply the noreturn attribute to a function that exits the program])
+fi
+])dnl End of CHECK_NORETURN_ATTRIBUTE
+
+CHECK_NORETURN_ATTRIBUTE
+
if test "$srcdir" != "."; then
CPPFLAGS="$CPPFLAGS -I$srcdir"
fi
}
}
argc -= optind;
- argv += optind;
+ /* argv += optind; not using further arguments */
if(winopt) {
#ifdef UB_ON_WINDOWS
13 September 2018: Wouter
- Fix seed for random backup code to use explicit zero when wiped.
+ - exit log routine is annotated as noreturn function.
+ - free memory leaks in config strlist and str2list insert functions.
+ - do not move unused argv variable after getopt.
+ - Remove unused if clause in testcode.
11 September 2018: Wouter
- Fixed unused return value warnings in contrib/fastrpz.patch for
alloc_init(&ctx->superalloc, NULL, 0);
seed = (unsigned int)time(NULL) ^ (unsigned int)getpid();
if(!(ctx->seed_rnd = ub_initstate(seed, NULL))) {
- seed = 0;
+ explicit_bzero(&seed, sizeof(seed));
ub_randfree(ctx->seed_rnd);
free(ctx);
errno = ENOMEM;
return NULL;
}
- seed = 0;
+ explicit_bzero(&seed, sizeof(seed));
lock_basic_init(&ctx->qqpipe_lock);
lock_basic_init(&ctx->rrpipe_lock);
lock_basic_init(&ctx->cfglock);
}
if(!cfg_strlist_insert(&ctx->env->cfg->trust_anchor_list, dup)) {
lock_basic_unlock(&ctx->cfglock);
- free(dup);
return UB_NOMEM;
}
lock_basic_unlock(&ctx->cfglock);
}
if(!cfg_strlist_insert(&ctx->env->cfg->trust_anchor_file_list, dup)) {
lock_basic_unlock(&ctx->cfglock);
- free(dup);
return UB_NOMEM;
}
lock_basic_unlock(&ctx->cfglock);
if(!cfg_strlist_insert(&ctx->env->cfg->auto_trust_anchor_file_list,
dup)) {
lock_basic_unlock(&ctx->cfglock);
- free(dup);
return UB_NOMEM;
}
lock_basic_unlock(&ctx->cfglock);
}
if(!cfg_strlist_insert(&ctx->env->cfg->trusted_keys_file_list, dup)) {
lock_basic_unlock(&ctx->cfglock);
- free(dup);
return UB_NOMEM;
}
lock_basic_unlock(&ctx->cfglock);
return UB_NOMEM;
}
if(!cfg_strlist_insert(&s->addrs, dupl)) {
- free(dupl);
lock_basic_unlock(&ctx->cfglock);
errno=ENOMEM;
return UB_NOMEM;
}
if(!cfg_strlist_insert(&elem->addrs, a)) {
lock_basic_unlock(&ctx->cfglock);
- free(a);
errno = ENOMEM;
return UB_NOMEM;
}
ins)) {
lock_basic_unlock(&ctx->cfglock);
fclose(in);
- free(ins);
errno=ENOMEM;
return UB_NOMEM;
}
if(!w->is_bg || w->is_bg_thread) {
lock_basic_unlock(&ctx->cfglock);
}
- seed = 0;
+ explicit_bzero(&seed, sizeof(seed));
libworker_delete(w);
return NULL;
}
hash_set_raninit((uint32_t)ub_random(w->env->rnd));
}
}
- seed = 0;
+ explicit_bzero(&seed, sizeof(seed));
if(eb)
w->base = comm_base_create_event(eb);
}
}
argc -= optind;
- argv += optind;
+ /* argv += optind; not using further arguments */
if(argc != 0)
usage();
if(!tcp_relay_write(p->server_s, &p->querylist,
&p->querylast, now))
delete_it = 1;
- if(p->querylist && p->server_s != -1 &&
+ if(p->querylist &&
dl_tv_smaller(&p->querylist->wait, now))
FD_SET(FD_SET_T p->server_s, worig);
else FD_CLR(FD_SET_T p->server_s, worig);
}
fclose(in);
at += len;
- avail -= len;
+ /* avail -= len; unused */
if(SSL_write(ssl, buf, at-buf) <= 0) {
/* write failure */
}
snprintf(at, avail, "\r\n");
r = strlen(at);
at += r;
- avail -= r;
+ /* avail -= r; unused */
}
/* send chunk */
if(SSL_write(ssl, buf, at-buf) <= 0) {
while(go) {
struct sockaddr_storage from;
socklen_t flen = (socklen_t)sizeof(from);
- int s = accept(fd, (struct sockaddr*)&from, &flen);
+ int s;
+ memset(&from, 0, sizeof(from));
+ s = accept(fd, (struct sockaddr*)&from, &flen);
if(verb) fflush(stdout);
if(s != -1) {
SSL* ssl = setup_ssl(s, sslctx);
}
}
argc -= optind;
- argv += optind;
+ /* argv += optind; not using further arguments */
if(argc != 0)
usage();
case 'h':
default:
testbound_usage();
- return 1;
+ exit(1);
}
}
argc -= optind;
- argv += optind;
+ /* argv += optind; not using further arguments */
if(argc != 0) {
testbound_usage();
- return 1;
+ exit(1);
}
log_info("Start of %s testbound program.", PACKAGE_STRING);
if(atexit(&remove_configfile) != 0)
#endif
/** logging routine, provided by caller */
void verbose(enum verbosity_value lvl, const char* msg, ...) ATTR_FORMAT(printf, 2, 3);
+static void error(const char* msg, ...) ATTR_NORETURN;
/** print error and exit */
static void error(const char* msg, ...)
cfg_strlist_insert(struct config_strlist** head, char* item)
{
struct config_strlist *s;
- if(!item || !head)
+ if(!item || !head) {
+ free(item);
return 0;
+ }
s = (struct config_strlist*)calloc(1, sizeof(struct config_strlist));
- if(!s)
+ if(!s) {
+ free(item);
return 0;
+ }
s->str = item;
s->next = *head;
*head = s;
cfg_str2list_insert(struct config_str2list** head, char* item, char* i2)
{
struct config_str2list *s;
- if(!item || !i2 || !head)
+ if(!item || !i2 || !head) {
+ free(item);
+ free(i2);
return 0;
+ }
s = (struct config_str2list*)calloc(1, sizeof(struct config_str2list));
- if(!s)
+ if(!s) {
+ free(item);
+ free(i2);
return 0;
+ }
s->str = item;
s->str2 = i2;
s->next = *head;
* @param head: pointer to strlist head variable.
* @param item: new item. malloced by caller. If NULL the insertion fails.
* @return: true on success.
+ * on fail, the item is free()d.
*/
int cfg_strlist_insert(struct config_strlist** head, char* item);
* @param item: new item. malloced by caller. If NULL the insertion fails.
* @param i2: 2nd string, malloced by caller. If NULL the insertion fails.
* @return: true on success.
+ * on fail, the item and i2 are free()d.
*/
int cfg_str2list_insert(struct config_str2list** head, char* item, char* i2);
* Pass printf formatted arguments. No trailing newline is needed.
* @param format: printf-style format string. Arguments follow.
*/
-void fatal_exit(const char* format, ...) ATTR_FORMAT(printf, 1, 2);
+void fatal_exit(const char* format, ...) ATTR_FORMAT(printf, 1, 2) ATTR_NORETURN;
/**
* va_list argument version of log_info.