Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

The clearest way into the Universe is through a forest wilderness. -- John Muir


devel / comp.os.msdos.djgpp / libc: new warnings with gcc 12

SubjectAuthor
o libc: new warnings with gcc 12J.W. Jagersma (jwjagersma@gmail.com) [via djgpp@delorie.com]

1
libc: new warnings with gcc 12

<b7fda707-09d2-dce9-ec04-cd3cb591ba9e@gmail.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=358&group=comp.os.msdos.djgpp#358

  copy link   Newsgroups: comp.os.msdos.djgpp
Path: i2pn2.org!i2pn.org!news.neodome.net!feeder1.feed.usenet.farm!feed.usenet.farm!peer01.ams4!peer.am4.highwinds-media.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.com!feeder.usenetexpress.com!tr3.iad1.usenetexpress.com!69.80.99.26.MISMATCH!XbbXl.tags.giganews.com!local-2.nntp.ord.giganews.com!news.giganews.com.POSTED!not-for-mail
NNTP-Posting-Date: Wed, 28 Jun 2023 17:07:51 +0000
X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f
X-Recipient: djgpp@delorie.com
X-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1687971875; x=1690563875; h=subject:from:to:content-language:user-agent:mime-version:date :message-id:from:to:cc:subject:date:message-id:reply-to; bh=SB9e5L5HY5QLUU9BGwusDKugDctgxd8kCt3r9mUNTvI=; b=rZYrEsVeTFoyr18t6NBMTRmbW9axM2mCqtSm06bA9G3EkChTaWPZHi7qJaJX3IEtGk Gp6nbM5n449fze8WWhbiGIAXKSuiMb8Rb/Nouw64vbTlqv+yL3FmljHv4MWl4vjzJJ0W rPojN3moCGwqzfmpOSxA/NNUlVW7BKkRmI4ZVIttyjONVRXS3gQNaBQIFaLZ3pHPfTAr ObBaFPhiUKlMRn7TwKkF6oAZwtdnPyA0Lw9wMih02q2k0RFBlE5p0t3d7RPXjKL6OvIJ K0nfwGwxqFVUhWUYoPt75mscQyJYzcvd6U5gMa/Po5FFINbmrdYRVKDbto1igB7i/dbL TuNg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687971875; x=1690563875; h=subject:from:to:content-language:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=SB9e5L5HY5QLUU9BGwusDKugDctgxd8kCt3r9mUNTvI=; b=Hiu1Bi8f5zqen0KFJIXDQKGTFXiCF8BEpYFvlj++glqB6QFrmkHmPv/mOVO2vjXhoq MXlaVTZmDINBbXhwUlFD/ny40vokhDH7k71XIQxzKQkDwyyM6VfgDM4RP8posTtCS5zQ 7jOjG1Xe7hiwV3vd9RAIkmcZUkRqsXeiixqe9gxowIaoES5frXmk0bfkKuwB2qj5ulJY XQTpWX89DMwUHi+9o3RkRz2lbvwfjwTk4Zq2T4gs7UtzaHayGw4bH6zafrWVlg9+/JlK oOkUkGnRUUiczrFClRR5IhsnyCh3O45bzeeoo8b6gJfmMMKlD6HwEvuAcCT5EXdh/Jag MYzQ==
X-Gm-Message-State: AC+VfDz8zfCWHrdN4EhUHvM1i3grFYq4uzhWRfDYlh/C+KlUu3jPH3hL yvpk+OeVmpfbo+9ztSWEzm2QGSlpmt8=
X-Google-Smtp-Source: ACHHUZ7+3jA2qSVNoNFKaRPtVjZN9hSgslwWPbEfYOkeZT/oSzbvRxwu5t7/nD6HxIeiLSFwulcmKg==
X-Received: by 2002:a17:907:3e0a:b0:8b1:7de3:cfaa with SMTP id hp10-20020a1709073e0a00b008b17de3cfaamr34222263ejc.3.1687971874373; Wed, 28 Jun 2023 10:04:34 -0700 (PDT)
Content-Type: multipart/mixed; boundary="------------dYgo2b4H43kc8Bd22nMMXG9L"
Message-ID: <b7fda707-09d2-dce9-ec04-cd3cb591ba9e@gmail.com>
Date: Wed, 28 Jun 2023 19:04:33 +0200
MIME-Version: 1.0
User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.12.0
Content-Language: en-US
To: djgpp@delorie.com
From: djgpp@delorie.com (J.W. Jagersma (jwjagersma@gmail.com) [via djgpp@delorie.com])
Subject: libc: new warnings with gcc 12
Reply-To: djgpp@delorie.com
Errors-To: nobody@delorie.com
X-Mailing-List: djgpp@delorie.com
X-Unsubscribes-To: listserv@delorie.com
Precedence: bulk
Newsgroups: comp.os.msdos.djgpp
Organization: None provided
DJ-Gateway: from mailing list djgpp@delorie.com
Lines: 181
X-Usenet-Provider: http://www.giganews.com
X-Trace: sv3-YgjUz2fL+fmnShQmnnhFyl4LR+5ckTgzChDjVLaTpo1/xAkhqmZhOXpEJe4HOAf4aDqJLo0usQ8TvHw!9MCqA7IxrIVji9ISgiBJl1G8b9oNOvWk+jhF0RDCEQEsICMmvy6oMLDgtL5ycYZv9TvhM5eMwzsg
X-Complaints-To: abuse@giganews.com
X-DMCA-Notifications: http://www.giganews.com/info/dmca.html
X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers
X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly
X-Postfilter: 1.3.40
X-Received-Bytes: 14174
 by: J.W. Jagersma (jwjag - Wed, 28 Jun 2023 17:04 UTC
Attachments: "0001-fix-use-after-free-warnings-on-gcc-12.patch" (text/plain), 0002-fix-bogus-free-nonheap-object-warning-in-gcc-12.patch (text/plain), "0003-silence-array-bounds-warning-in-gcc-12.patch" (text/plain)

Noticed the following new warnings (errors) while compiling libc with gcc 12:

rename.c: In function 'push_dir':
rename.c:138:24: error: pointer may be used after 'realloc' [-Werror=use-after-free]
138 | pool_end += temp - dirnames_pool;
| ~~~~~^~~~~~~~~~~~~~~
rename.c:132:22: note: call to 'realloc' here
132 | temp = (char *)realloc(dirnames_pool, pool_size);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
rename.c:156:25: error: pointer may be used after 'realloc' [-Werror=use-after-free]
156 | stack_top += temp - dirstack;
| ^
rename.c:149:29: note: call to 'realloc' here
149 | temp = (Stacked_Dir *)realloc(dirstack,
| ^~~~~~~~~~~~~~~~~
150 | stack_size * sizeof(Stacked_Dir));
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

In function '_instr',
inlined from '_innum' at doscan.c:285:13,
inlined from '_doscan_low' at doscan.c:225:11:
doscan.c:542:9: error: pointer 'orig_ptr_517' may be used after 'realloc' [-Werror=use-after-free]
542 | free(orig_ptr);
| ^~~~~~~~~~~~~~
doscan.c:538:27: note: call to 'realloc' here
538 | *(char **)arg_ptr = realloc(orig_ptr, string_length);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

In file included from nmalign.c:13:
nmalign.c: In function 'memalign':
nmalcdef.h:41:23: error: 'free' called on pointer '<unknown>' with nonzero offset 16 [-Werror=free-nonheap-object]
41 | # define nfree free
nmalign.c:144:13: note: in expansion of macro 'nfree'
144 | nfree(PTR(__nmalloc_split(&m, alignment - misalign)));
| ^~~~~
nmalign.c:144:23: note: returned from '__nmalloc_split'
144 | nfree(PTR(__nmalloc_split(&m, alignment - misalign)));
nmalcdef.h:190:36: note: in definition of macro 'PTR'
190 | #define PTR(m) (void*)((byte*)(m) + DATAOFFSET)
| ^
nmalcdef.h:42:23: error: 'realloc' called on pointer 'm' with nonzero offset 16 [-Werror=free-nonheap-object]
42 | # define nrealloc realloc
nmalign.c:145:20: note: in expansion of macro 'nrealloc'
145 | return nrealloc(PTR(m), size);
| ^~~~~~~~
nmalign.c:113:14: note: declared here
113 | memblockp m = NULL;
| ^

mcount.c: In function 'mcount':
mcount.c:80:8: error: array subscript -1 is outside array bounds of 'int[1]' [-Werror=array-bounds]
80 | to = *((&_to)-1) - 12;
| ^~~~~~~~~~~
mcount.c:56:17: note: at offset -4 into object '_to' of size 4
56 | void mcount(int _to)
| ~~~~^~~
mcount.c:81:7: error: array subscript -2 is outside array bounds of 'int[1]' [-Werror=array-bounds]
81 | ebp = *((&_to)-2); /* glean the caller's return address from the stack */
| ~~~~^~~~~~~~~~~~~
mcount.c:56:17: note: at offset -8 into object '_to' of size 4
56 | void mcount(int _to)
| ~~~~^~~

The attached patches will resolve them.

Also, I think there's a possible memory leak in doscan.c: If
'allocate_char_buffer' is set, but 'ptr' isn't, the allocation will be leaked.
Maybe that can never happen, but the logic is a bit hard to follow.

Attachments: "0001-fix-use-after-free-warnings-on-gcc-12.patch" (text/plain), 0002-fix-bogus-free-nonheap-object-warning-in-gcc-12.patch (text/plain), "0003-silence-array-bounds-warning-in-gcc-12.patch" (text/plain)
1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor