From af26dea128c111434c188e5885a6f8a2d467691b Mon Sep 17 00:00:00 2001 From: Sebastian Reimers Date: Wed, 30 Aug 2023 18:08:01 +0200 Subject: [PATCH 1/2] fmt/print: improve print RE_VA_ARG debugging (#925) --- include/re_types.h | 4 +--- src/fmt/print.c | 16 +++++++++++++++- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/include/re_types.h b/include/re_types.h index 0f6ee9aab..888051d80 100644 --- a/include/re_types.h +++ b/include/re_types.h @@ -371,12 +371,10 @@ typedef int re_sock_t; if (likely((safe))) { \ size_t sz = va_arg((ap), size_t); \ if (unlikely(!sz)) { \ - re_assert(0 && "RE_VA_ARG: no more arguments"); \ - err = EOVERFLOW; \ + err = ENODATA; \ goto out; \ } \ if (unlikely(sz != sizeof(type))) { \ - re_assert(0 && "RE_VA_ARG: arg is not compatible"); \ err = EOVERFLOW; \ goto out; \ } \ diff --git a/src/fmt/print.c b/src/fmt/print.c index 7098ad34f..f8088108a 100644 --- a/src/fmt/print.c +++ b/src/fmt/print.c @@ -4,11 +4,11 @@ * Copyright (C) 2010 Creytiv.com */ #include +#include #include #include #include #include -#include #ifdef _MSC_VER #include #ifndef isinf @@ -26,6 +26,9 @@ #define isnan(a) isnand((a)) #endif +#define DEBUG_MODULE "print" +#define DEBUG_LEVEL 5 +#include enum length_modifier { LENMOD_NONE = 0, @@ -489,6 +492,17 @@ static int vhprintf(const char *fmt, va_list ap, re_vprintf_h *vph, void *arg, err |= vph(p0, p - p0, arg); out: +#ifndef RELEASE + if (err == ENODATA) { + DEBUG_WARNING("Format: \"%b<-- NO ARG\n", fmt, p - fmt + 1); + re_assert(0 && "RE_VA_ARG: no more arguments"); + } + if (err == EOVERFLOW) { + DEBUG_WARNING("Format: \"%b<-- SIZE ERROR\n", fmt, + p - fmt + 1); + re_assert(0 && "RE_VA_ARG: arg is not compatible"); + } +#endif return err; } From b5ca0e28aa1a30404f74a2125a9054904ed56d19 Mon Sep 17 00:00:00 2001 From: Sebastian Reimers Date: Wed, 30 Aug 2023 19:41:42 +0200 Subject: [PATCH 2/2] sip/request: fix check return code (found by coverity) (#926) --- src/sip/request.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/sip/request.c b/src/sip/request.c index 4c3748d8d..cb60a8801 100644 --- a/src/sip/request.c +++ b/src/sip/request.c @@ -228,6 +228,8 @@ static int request(struct sip_request *req, enum sip_transp tp, if (req->srcport) { struct sip_conncfg cfg = {.srcport = req->srcport}; err = sip_conncfg_set(req->sip, dst, &cfg); + if (err) + goto out; } if (!req->stateful) {