Content-Type: multipart/alternative; boundary="Apple-Mail=_93FC5A63-73E6-42C8-ABA9-DE1C9057403E" Mime-Version: 1.0 (Mac OS X Mail 9.3 \(3124\)) From: Jens Neuhalfen In-Reply-To: Date: Sun, 18 Sep 2016 18:34:32 +0200 Message-Id: <8D624060-471D-42CA-BC8F-9EBA929A6B75@...2127...> References: <1474208364-11251-1-git-send-email-chipitsine@...277...> <2ea62e71-fe65-714b-2a2e-27bfa8f480eb@...2080...> Subject: Re: [Openvpn-devel] [PATCH] cppcheck finding: add "ASSERT( maxoutput > 0 || separator != NULL )" to prevent possible null pointer derefence List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: =?utf-8?B?0JjQu9GM0Y8g0KjQuNC/0LjRhtC40L0=?= Cc: "openvpn-devel@lists.sourceforge.net" --Apple-Mail=_93FC5A63-73E6-42C8-ABA9-DE1C9057403E Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable >=20 > Hello, >=20 > this defect was found by cppcheck, however cppcheck still complains. > so, we did not make it happy yet. >=20 > I think, the best would be split this function into 2 separate functions > (with either null argument) or leave it like that. Unrelated to an actual fix, IMHO we should at least break up out =3D alloc_buf_gc (maxoutput ? maxoutput : ((size * 2) + (size / (space_break_flags & FHE_SPACE_BREAK_MASK)) *= (int) strlen (separator) + 2), gc); and create a variable with a semantic variable for the result of "((size = * 2) + (size / (space_break_flags & FHE_SPACE_BREAK_MASK)) * (int) strlen (= separator) + 2)=E2=80=9D Honestly the calculation looks very arcane and I would better understand it= , if i knew what it means :-) Jens= --Apple-Mail=_93FC5A63-73E6-42C8-ABA9-DE1C9057403E Content-Type: text/html; charset="utf-8" Content-Transfer-Encoding: quoted-printable

Hello,

this defect was found by cppcheck, however cppch= eck still complains.
so, we did not make it happy yet.

I think, the best would be split this function into 2 sep= arate functions
(with either null argument) or leave it like that= .

Unrelated to an actual fix, IMHO we should at least break up
out =3D alloc_buf_gc (maxoutput ? maxoutput :
=     = ((size * 2) + (size / (space_break_flags & FHE_SPACE_BREAK_MASK)) * (in= t) strlen (separator) + 2),
= and create a variable with a semantic variable for the result of   "((= size * 2) + (size / (space_break_flags & FHE_SPACE_BREAK_MASK)) * (int)= strlen (separator) + 2)=E2=80=9D

Hones= tly the calculation looks very arcane and I would better understand it, if = i knew what it means :-)

Jens
= --Apple-Mail=_93FC5A63-73E6-42C8-ABA9-DE1C9057403E--