compile with address sanitizer as a test + add deps to configure.ac

This commit is contained in:
9pfs 2024-04-24 04:25:06 +00:00
parent 139cee97e5
commit 690f419189
Signed by: 9pfs
SSH key fingerprint: SHA256:TOcGxMQCfy4VvRM8AzgXErKXdkAtaTcpGXgYMpyoJoY
3 changed files with 7 additions and 3 deletions

View file

@ -21,7 +21,7 @@ void check_users() {
struct passwd *res; struct passwd *res;
errno = 0; errno = 0;
res = getpwnam(CHECK_USERS_CANARY_USER); res = getpwnam(CHECK_USERS_CANARY_USER);
if(res == NULL) { if(res == NULL || getenv("NEST_SANITY_CHECK_USERS_DEBUG")!=NULL) {
/* If we've already reported it, let's not report it again */ /* If we've already reported it, let's not report it again */
if(check_users_state == 1) return; if(check_users_state == 1) return;
int res_errno; int res_errno;
@ -37,6 +37,7 @@ void check_users() {
snprintf(notification_payload, notification_payload_len, notification_payload_fmt, res_err_txt, res_errno); snprintf(notification_payload, notification_payload_len, notification_payload_fmt, res_err_txt, res_errno);
int send_alarm_result; int send_alarm_result;
send_alarm_result = send_alarm(notification_payload); send_alarm_result = send_alarm(notification_payload);
free(notification_payload);
/* We only set this to 1 if we successfully reported the issue. */ /* We only set this to 1 if we successfully reported the issue. */
if(send_alarm_result == 0) check_users_state = 1; if(send_alarm_result == 0) check_users_state = 1;
} }

View file

@ -15,11 +15,14 @@ PKG_PROG_PKG_CONFIG
PKG_CHECK_MODULES([LIBCURL], [libcurl]) PKG_CHECK_MODULES([LIBCURL], [libcurl])
# Checks for header files. # Checks for header files.
AC_CHECK_HEADER_STDBOOL
AC_CHECK_HEADERS([unistd.h])
# Checks for typedefs, structures, and compiler characteristics. # Checks for typedefs, structures, and compiler characteristics.
# Checks for library functions. # Checks for library functions.
AC_FUNC_MALLOC AC_FUNC_MALLOC
AC_CHECK_FUNCS([strerror])
AC_CONFIG_FILES([Makefile]) AC_CONFIG_FILES([Makefile])
AC_OUTPUT AC_OUTPUT

View file

@ -56,8 +56,8 @@ const char *build_prefixed_report(const char *report) {
* adds prefixes and calls the report send function */ * adds prefixes and calls the report send function */
int report_len = strlen(report); int report_len = strlen(report);
int notification_prefix_len = strlen(NOTIFICATION_PREFIX); int notification_prefix_len = strlen(NOTIFICATION_PREFIX);
int post_payload_len = report_len + notification_prefix_len + 1; int post_payload_len = report_len + notification_prefix_len;
char *post_payload = malloc(post_payload_len); char *post_payload = malloc(post_payload_len+1);
for(int a=0;a<notification_prefix_len;a++) { for(int a=0;a<notification_prefix_len;a++) {
post_payload[a] = NOTIFICATION_PREFIX[a]; post_payload[a] = NOTIFICATION_PREFIX[a];
} }