Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rucjD-006YgT-C2 for pgsql-hackers@arkaria.postgresql.org; Wed, 10 Apr 2024 18:31:23 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1rucjB-006YVd-LZ for pgsql-hackers@arkaria.postgresql.org; Wed, 10 Apr 2024 18:31:21 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rucjB-006YVV-9a for pgsql-hackers@lists.postgresql.org; Wed, 10 Apr 2024 18:31:21 +0000 Received: from mail-ej1-x629.google.com ([2a00:1450:4864:20::629]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1rucj4-000F4Q-Fx for pgsql-hackers@postgresql.org; Wed, 10 Apr 2024 18:31:20 +0000 Received: by mail-ej1-x629.google.com with SMTP id a640c23a62f3a-a47385a4379so24857766b.0 for ; Wed, 10 Apr 2024 11:31:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1712773873; x=1713378673; darn=postgresql.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=LKW2zXvIkNSWedCxauKte/dAsVd/qqbEFxWlDHRtGYk=; b=cuzvpxdWXVkwWlgGJslOFR35+Q4DaHAdJhzhKBrbfCsnwqbbrVl3zzaoi/x1ySkBgH GmlL3V1QCALhH7E7D2MCc3Mmo24rkrz2P+YX3X9YF3cxx/XVXFvqI/VVYTdi3xa/L4r9 0V7mpq3NtVHZoOjUdqC9Kh+Yqxel6mehqioxxtkOlYL49sZaqVl5J2zhq5PxfWb+0Py0 2EwyqEr03+DtnpwyzhSyg/oZnEWeBQKAZca7BfiI+bKqyIpJ64oAGETmsS10uk6kqcZM 7HHVvCRWcjrU8XB2tUf4le5iCQeHK66uxQauoyDsPG42jHQ+T4nm6hLigYW/zb2yr5nh WFbA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712773873; x=1713378673; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=LKW2zXvIkNSWedCxauKte/dAsVd/qqbEFxWlDHRtGYk=; b=gcEwJjth6urnnBVLodMUOr3oVDFYIEbwnT56K7v3fGhv2UtIsBw8+afsSdm+xuYud1 /+/vTATT495S0fpieLUaC2j1UYk+QD2NEtLXpdU75QjdA6B8GuHwfZN1spXD2ig/AEOt 9D9gQZHNEW8KZxJB7APmrfKlfqQjH+62xTNm/FOMMY1FHc3esdm/98LQ9sKw91vuwPWe sVxngTnXogXgwDruSOcQZbhjE0OInuScfYhqPvmeMb1eOqzplK5HJuPakzLj8o0b0RlY uy5HYRJjv90YqY9FQMuO/pGrI4GQ02pQyFoYq4D2WYMu9uvRysaM0C/SQs+6owjgEZHH vAVg== X-Gm-Message-State: AOJu0Yz6XAqxhUZ6rQUo4gjZCX1ZXmCH6+phSAARqc1rStxCgNRycJw5 1V9mZgxILMzqJ1EIMcubTlDwO1H/3a1n/oQpgY/3oGJXAZnZOJtljzN/Eh3WLhbapgR3Bsv8W2l 41roVznHnUL+yvqAl5M7BFigs3MORJu+0pRg= X-Google-Smtp-Source: AGHT+IG/WuXxX3rn/QLOHDcoVxlohQJOVCokOi3RCqyqOM6swvk9OXxJV9ib0EMJtyjW7umG71GDRXsq9Fn1x5hhit8= X-Received: by 2002:a17:906:78d:b0:a51:b74d:d0e1 with SMTP id l13-20020a170906078d00b00a51b74dd0e1mr331068ejc.28.1712773873045; Wed, 10 Apr 2024 11:31:13 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Ranier Vilela Date: Wed, 10 Apr 2024 15:31:02 -0300 Message-ID: Subject: Re: Fix resource leak (src/backend/libpq/be-secure-common.c) To: Daniel Gustafsson Cc: PostgreSQL Hackers Content-Type: multipart/mixed; boundary="00000000000048a8e10615c23e51" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --00000000000048a8e10615c23e51 Content-Type: multipart/alternative; boundary="00000000000048a8e00615c23e4f" --00000000000048a8e00615c23e4f Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Em ter., 2 de abr. de 2024 =C3=A0s 15:31, Daniel Gustafsson escreveu: > > On 2 Apr 2024, at 20:13, Ranier Vilela wrote: > > > Fix by freeing the pointer, like pclose_check (src/common/exec.c) > similar case. > > Off the cuff, seems reasonable when loglevel is LOG. > Per Coverity. Another case of resource leak, when loglevel is LOG. In the function shell_archive_file (src/backend/archive/shell_archive.c) The pointer *xlogarchcmd* is not freed. best regards, Ranier Vilela --00000000000048a8e00615c23e4f Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Em ter., 2 de abr. de 2024 =C3=A0s 15:31, Daniel Gustafsson <daniel@yesql.se> escreveu:
<= blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-l= eft:1px solid rgb(204,204,204);padding-left:1ex">> On 2 Apr 2024, at 20:= 13, Ranier Vilela <ranier.vf@gmail.com> wrote:

> Fix by freeing the pointer, like pclose_check (src/common/exec.c) simi= lar case.

Off the cuff, seems reasonable when loglevel is LOG.

Per Coverity.

Another case of resource leak, when loglevel is LOG.
In the function shell_archive_file (src/backend/archive/shell_ar= chive.c)
The pointer *xlogarchcmd*=C2=A0 is not freed.
<= div>
best regards,
Ranier Vilela
--00000000000048a8e00615c23e4f-- --00000000000048a8e10615c23e51 Content-Type: application/octet-stream; name="fix-resource-leak-shell_archive.patch" Content-Disposition: attachment; filename="fix-resource-leak-shell_archive.patch" Content-Transfer-Encoding: base64 Content-ID: X-Attachment-Id: f_luu5brc10 ZGlmZiAtLWdpdCBhL3NyYy9iYWNrZW5kL2FyY2hpdmUvc2hlbGxfYXJjaGl2ZS5jIGIvc3JjL2Jh Y2tlbmQvYXJjaGl2ZS9zaGVsbF9hcmNoaXZlLmMKaW5kZXggMDkyNTM0OGJmZS4uNTA2YzVhMzBh ZCAxMDA2NDQKLS0tIGEvc3JjL2JhY2tlbmQvYXJjaGl2ZS9zaGVsbF9hcmNoaXZlLmMKKysrIGIv c3JjL2JhY2tlbmQvYXJjaGl2ZS9zaGVsbF9hcmNoaXZlLmMKQEAgLTEyNSw5ICsxMjUsMTEgQEAg c2hlbGxfYXJjaGl2ZV9maWxlKEFyY2hpdmVNb2R1bGVTdGF0ZSAqc3RhdGUsIGNvbnN0IGNoYXIg KmZpbGUsCiAJCQkJCSBlcnJkZXRhaWwoIlRoZSBmYWlsZWQgYXJjaGl2ZSBjb21tYW5kIHdhczog JXMiLAogCQkJCQkJCSAgIHhsb2dhcmNoY21kKSkpOwogCQl9CisJCXBmcmVlKHhsb2dhcmNoY21k KTsKIAogCQlyZXR1cm4gZmFsc2U7CiAJfQorCXBmcmVlKHhsb2dhcmNoY21kKTsKIAogCWVsb2co REVCVUcxLCAiYXJjaGl2ZWQgd3JpdGUtYWhlYWQgbG9nIGZpbGUgXCIlc1wiIiwgZmlsZSk7CiAJ cmV0dXJuIHRydWU7 --00000000000048a8e10615c23e51--