diff --git a/lib/util/getdelim.c b/lib/util/getdelim.c index 78ac0481c0..d218e19e61 100644 --- a/lib/util/getdelim.c +++ b/lib/util/getdelim.c @@ -46,11 +46,12 @@ sudo_getdelim(char ** restrict buf, size_t * restrict bufsize, int delim, do { if (cp + 1 >= ep) { + const size_t used = (size_t)(cp - *buf); char *newbuf = reallocarray(*buf, *bufsize, 2); if (newbuf == NULL) goto bad; *bufsize *= 2; - cp = newbuf + (cp - *buf); + cp = newbuf + used; ep = newbuf + *bufsize; *buf = newbuf; } @@ -70,7 +71,7 @@ sudo_getdelim(char ** restrict buf, size_t * restrict bufsize, int delim, bad: /* Error, push back what was read if possible. */ while (cp > *buf) { - if (ungetc(*cp--, fp) == EOF) + if (ungetc((unsigned char)*--cp, fp) == EOF) break; } return -1; diff --git a/lib/util/json.c b/lib/util/json.c index a521a83a2c..78808a1688 100644 --- a/lib/util/json.c +++ b/lib/util/json.c @@ -235,7 +235,8 @@ sudo_json_open_object_v1(struct json_container *jsonc, const char *name) debug_return_bool(false); if (name != NULL) { - json_append_string(jsonc, name); + if (!json_append_string(jsonc, name)) + debug_return_bool(false); if (!json_append_buf(jsonc, jsonc->minimal ? ":{" : ": {")) debug_return_bool(false); } else { @@ -280,7 +281,8 @@ sudo_json_open_array_v1(struct json_container *jsonc, const char *name) debug_return_bool(false); if (name != NULL) { - json_append_string(jsonc, name); + if (!json_append_string(jsonc, name)) + debug_return_bool(false); if (!json_append_buf(jsonc, jsonc->minimal ? ":[" : ": [")) debug_return_bool(false); } else { diff --git a/lib/util/term.c b/lib/util/term.c index 17636eb38d..150979abb8 100644 --- a/lib/util/term.c +++ b/lib/util/term.c @@ -348,13 +348,6 @@ sudo_term_raw_v1(int fd, unsigned int flags) goto unlock; } - if (sudo_term_is_raw_int(&term)) { - sudo_debug_printf(SUDO_DEBUG_INFO, "%s: fd %d already in raw mode", - __func__, fd); - ret = true; - goto unlock; - } - /* * Set terminal to raw mode but optionally enable terminal signals * and/or preserve output flags.