From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.1 required=5.0 tests=DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,HTML_MESSAGE,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL autolearn=ham autolearn_force=no version=3.4.4 Received: from second.openwall.net (second.openwall.net [193.110.157.125]) by inbox.vuxu.org (Postfix) with SMTP id 764BC220FE for ; Wed, 17 Jul 2024 19:41:44 +0200 (CEST) Received: (qmail 3504 invoked by uid 550); 17 Jul 2024 17:41:38 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Reply-To: musl@lists.openwall.com Received: (qmail 3105 invoked from network); 17 Jul 2024 16:55:21 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1721235312; x=1721840112; darn=lists.openwall.com; h=to:subject:message-id:date:from:mime-version:from:to:cc:subject :date:message-id:reply-to; bh=VxngV1OyviDXzKFNygc/H2yUKVcYLTwI902DGwNwB60=; b=N1BiGIaQ9Eadshr1sgh4VtKSV3uOfb76Vp+ToAqGu44yfkojDVbI0OBB8i/wMjWUQP xIRxE1N4cxIQ99bLXvIf5d0/k22hDDgzhDLFECDO1bzp1+jw6PIdafIuVBE+Q8lCtuvP vF5PZCB0+ADwQ5peZLpkqvY3LImij+SI0Reqg0ke00kd1HVAnmV29fj6u/LspgeoBxxX Qf3tw5g0bXKrtnyOSjbeKCyUubJId3Odz1qx6NlI6J31ijgq+Mjm/5t3UQaX0StGt8fR icu5o1oubpwZSVyc6K8mLu02SgNbUoX48tqewm2Q/r1TeYsq2pXwwCo5w+mOd2NzzjZr 2KCQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721235312; x=1721840112; h=to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=VxngV1OyviDXzKFNygc/H2yUKVcYLTwI902DGwNwB60=; b=EQ7Q3MYRO9Mo/jOZVZohyfwkZY8DgNFWrhP7FCB0QHN8noMg9M8Hb/d4hfp/+5l9IE 4OAPlDKCHSZW2jyt8lVGpGIahMKhPxjzi9k3f6+L7gmEQwnni9Mm5UqD85IHsMi1dzRc lv5jSUaZfMqfwZ/mPd8jR4LPtGEllff0wKOY7W+3wsG3+pRGaq/KLQAav4luU5T+Wd7z mFQQY65RN/4IcEk03oeBY97U6E6k0QJoCueoIO/TB4d5OyDi0YRL1RDm/B0nTDfwMRDI G/lXAzfrhIUtvyra/C2VhA+lA1zEaNB/Ad8q24hOqd0J9aP5L8rg/XrH6hN90OdhnKO+ 1nzA== X-Gm-Message-State: AOJu0YxVnU9+Rf+YHJN6mY35fH73kJEHZB8nPF4W1t4Q12EeM8kwomLR V68PjIHzqiul/Mci1v7MShSnGDGQy0XdxQ60oU6PXps5/6MOLf+i3+kWbumo3Tr31qAQV3J/Q3A oiscNlR+lKOKEw8a+vRGvpEQDbgKw5gKGFZw= X-Google-Smtp-Source: AGHT+IHOU4iZuX5UZelAbr7ucQ1w1RPvENEYavLasbHIk0iaG/saWDaZG6d6Nh592XlEUHyHhFy/mwHVIT/EtaScUys= X-Received: by 2002:a05:6a21:6d86:b0:1c3:b1b6:5066 with SMTP id adf61e73a8af0-1c3fdc6f5f3mr2934038637.13.1721235311912; Wed, 17 Jul 2024 09:55:11 -0700 (PDT) MIME-Version: 1.0 From: Luca Date: Wed, 17 Jul 2024 18:54:59 +0200 Message-ID: To: musl@lists.openwall.com Content-Type: multipart/alternative; boundary="000000000000577095061d74534a" Subject: [musl] Memory Leak --000000000000577095061d74534a Content-Type: text/plain; charset="UTF-8" Hi, I believe I found a memory leak in your code. In the file: /src/env/putenv.c In the function: int __putenv(char *s, size_t l, char *r); The variable `static char **oldenv` is passed to a free in line 29: `free(oldenv);`. The variable is a 2d pointer and therefore all contents within it should be freed. By freeing only oldenv all the lines of `__environ` are lost. Possible hotfix: ``` for (int j = 0; oldenv[j]; ++j) free(oldenv[j]); free(oldenv); ``` Thank you for your support and dedication, Luca --000000000000577095061d74534a Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi,

I believe I found a memory= leak in your code.

In the file: /src/env/putenv.c
<= br>
In the function: int __putenv(char *s, size_t l, char *r);
The variable `static char **oldenv` is passed to a free in = line 29: `free(oldenv);`.
The variable is a 2d pointer and th= erefore all contents within it should be freed.
By freeing only o= ldenv all the lines of `__environ` are lost.

Possi= ble hotfix:
```
for (int j =3D 0; oldenv[j]; ++j) free(oldenv[j]);<= /div>
free(oldenv);
```

Thank you for your = support and dedication,
Luca
--000000000000577095061d74534a--