From: Todd C. Miller Date: Sun, 1 Nov 2015 22:13:28 +0000 (-0700) Subject: Add debug_return_ssize_t X-Git-Tag: SUDO_1_8_16^2~108 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=8b12390abf20c79228dbdc905a3f65fa17dd2b73;p=sudo Add debug_return_ssize_t --- diff --git a/include/sudo_debug.h b/include/sudo_debug.h index 938c13744..ba151d1bc 100644 --- a/include/sudo_debug.h +++ b/include/sudo_debug.h @@ -137,6 +137,14 @@ struct sudo_conf_debug_file_list; return sudo_debug_rval; \ } while (0) +#define debug_return_ssize_t(rval) \ + do { \ + ssize_t sudo_debug_rval = (rval); \ + sudo_debug_exit_ssize_t(__func__, __FILE__, __LINE__, sudo_debug_subsys,\ + sudo_debug_rval); \ + return sudo_debug_rval; \ + } while (0) + #define debug_return_long(rval) \ do { \ long sudo_debug_rval = (rval); \ @@ -224,6 +232,7 @@ __dso_public void sudo_debug_exit_int_v1(const char *func, const char *file, int __dso_public void sudo_debug_exit_long_v1(const char *func, const char *file, int line, int subsys, long rval); __dso_public void sudo_debug_exit_ptr_v1(const char *func, const char *file, int line, int subsys, const void *rval); __dso_public void sudo_debug_exit_size_t_v1(const char *func, const char *file, int line, int subsys, size_t rval); +__dso_public void sudo_debug_exit_ssize_t_v1(const char *func, const char *file, int line, int subsys, ssize_t rval); __dso_public void sudo_debug_exit_str_v1(const char *func, const char *file, int line, int subsys, const char *rval); __dso_public void sudo_debug_exit_str_masked_v1(const char *func, const char *file, int line, int subsys, const char *rval); __dso_public pid_t sudo_debug_fork_v1(void); @@ -247,6 +256,7 @@ __dso_public void sudo_debug_write2_v1(int fd, const char *func, const char *fil #define sudo_debug_exit_long(_a, _b, _c, _d, _e) sudo_debug_exit_long_v1((_a), (_b), (_c), (_d), (_e)) #define sudo_debug_exit_ptr(_a, _b, _c, _d, _e) sudo_debug_exit_ptr_v1((_a), (_b), (_c), (_d), (_e)) #define sudo_debug_exit_size_t(_a, _b, _c, _d, _e) sudo_debug_exit_size_t_v1((_a), (_b), (_c), (_d), (_e)) +#define sudo_debug_exit_ssize_t(_a, _b, _c, _d, _e) sudo_debug_exit_ssize_t_v1((_a), (_b), (_c), (_d), (_e)) #define sudo_debug_exit_str(_a, _b, _c, _d, _e) sudo_debug_exit_str_v1((_a), (_b), (_c), (_d), (_e)) #define sudo_debug_exit_str_masked(_a, _b, _c, _d, _e) sudo_debug_exit_str_masked_v1((_a), (_b), (_c), (_d), (_e)) #define sudo_debug_fork() sudo_debug_fork_v1() diff --git a/lib/util/parseln.c b/lib/util/parseln.c index 55f26815b..a1aae0d89 100644 --- a/lib/util/parseln.c +++ b/lib/util/parseln.c @@ -114,6 +114,6 @@ sudo_parseln_v1(char **bufp, size_t *bufsizep, unsigned int *lineno, FILE *fp) } while (continued); free(line); if (len == -1 && total == 0) - debug_return_size_t((size_t)-1); - debug_return_size_t(total); + debug_return_ssize_t(-1); + debug_return_ssize_t(total); } diff --git a/lib/util/sudo_debug.c b/lib/util/sudo_debug.c index 28907085f..5a990c419 100644 --- a/lib/util/sudo_debug.c +++ b/lib/util/sudo_debug.c @@ -456,6 +456,14 @@ sudo_debug_exit_size_t_v1(const char *func, const char *file, int line, "<- %s @ %s:%d := %zu", func, file, line, rval); } +void +sudo_debug_exit_ssize_t_v1(const char *func, const char *file, int line, + int subsys, ssize_t rval) +{ + sudo_debug_printf2(NULL, NULL, 0, subsys | SUDO_DEBUG_TRACE, + "<- %s @ %s:%d := %zd", func, file, line, rval); +} + void sudo_debug_exit_bool_v1(const char *func, const char *file, int line, int subsys, bool rval) diff --git a/plugins/sudoers/timestamp.c b/plugins/sudoers/timestamp.c index 15ea13bcb..431c97e90 100644 --- a/plugins/sudoers/timestamp.c +++ b/plugins/sudoers/timestamp.c @@ -310,9 +310,9 @@ ts_write(int fd, const char *fname, struct timestamp_entry *entry, off_t offset) (long long)old_eof); } } - debug_return_size_t(-1); + debug_return_ssize_t(-1); } - debug_return_size_t(nwritten); + debug_return_ssize_t(nwritten); } /* @@ -553,7 +553,7 @@ done: if (should_unlock) timestamp_unlock_record(cookie->fd, cookie->pos, sizeof(*entry)); - debug_return_size_t(nread); + debug_return_ssize_t(nread); } /*