From 46efe2f14d56c417b6253b96b00ad82af8d71ee2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=BD=D0=B0=D0=B1?= Date: Sat, 16 Dec 2023 01:55:50 +0100 Subject: [PATCH] sizeof('c')=4, not 1: fix overly-pessimistic IB_INSUFFICIENT_MEMORY return As found by DCS: [^._]sizeof[ (]'.{1,2}' filetype:c Ref: https://paste.sr.ht/~nabijaczleweli/6ee9ccf301a2651afb693bff46e3671d3f7cdd89 Ref: https://101010.pl/@nabijaczleweli/111587138076843793 --- libopensm/osm_helper.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libopensm/osm_helper.c b/libopensm/osm_helper.c index 6e9e98ed..c9218e48 100644 --- a/libopensm/osm_helper.c +++ b/libopensm/osm_helper.c @@ -584,7 +584,7 @@ static ib_api_status_t dbg_do_line(IN char **pp_local, IN uint32_t buf_size, sprintf(line, "%s%s", p_prefix_str, p_new_str); len = (uint32_t) strlen(line); *p_total_len += len; - if (*p_total_len + sizeof('\0') > buf_size) + if (*p_total_len + 1 /* NUL */ > buf_size) return IB_INSUFFICIENT_MEMORY; strcpy(*pp_local, line);