X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f X-Recipient: djgpp AT delorie DOT 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: 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 AT delorie DOT com From: "J.W. Jagersma (jwjagersma AT gmail DOT com) [via djgpp AT delorie DOT com]" Subject: libc: new warnings with gcc 12 Reply-To: djgpp AT delorie DOT com This is a multi-part message in MIME format. --------------dYgo2b4H43kc8Bd22nMMXG9L Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit 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 '' 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. --------------dYgo2b4H43kc8Bd22nMMXG9L Content-Type: text/plain; charset=UTF-8; name="0001-fix-use-after-free-warnings-on-gcc-12.patch" Content-Disposition: attachment; filename="0001-fix-use-after-free-warnings-on-gcc-12.patch" Content-Transfer-Encoding: base64 RnJvbSAyMjU1YWU5NGVhMzZkNzg1NWQ3MDVkOWQ2NDk0ZTZlNzBmOTM1YTA0IE1vbiBTZXAg MTcgMDA6MDA6MDAgMjAwMQpGcm9tOiAiSi5XLiBKYWdlcnNtYSIgPGp3amFnZXJzbWFAZ21h aWwuY29tPgpEYXRlOiBXZWQsIDI4IEp1biAyMDIzIDE4OjI3OjI1ICswMjAwClN1YmplY3Q6 IFtQQVRDSCAxLzNdIGZpeCB1c2UtYWZ0ZXItZnJlZSB3YXJuaW5ncyBvbiBnY2MgMTIKCi0t LQogc3JjL2xpYmMvYW5zaS9zdGRpby9kb3NjYW4uYyB8IDkgKysrKystLS0tCiBzcmMvbGli Yy9hbnNpL3N0ZGlvL3JlbmFtZS5jIHwgNiArKysrLS0KIDIgZmlsZXMgY2hhbmdlZCwgOSBp bnNlcnRpb25zKCspLCA2IGRlbGV0aW9ucygtKQoKZGlmZiAtLWdpdCBhL3NyYy9saWJjL2Fu c2kvc3RkaW8vZG9zY2FuLmMgYi9zcmMvbGliYy9hbnNpL3N0ZGlvL2Rvc2Nhbi5jCmluZGV4 IGIwZDg1ZWY3Li5iOGEwZDgxYiAxMDA2NDQKLS0tIGEvc3JjL2xpYmMvYW5zaS9zdGRpby9k b3NjYW4uYworKysgYi9zcmMvbGliYy9hbnNpL3N0ZGlvL2Rvc2Nhbi5jCkBAIC01MzMsMTYg KzUzMywxNyBAQCBfaW5zdHIoY2hhciAqcHRyLCBpbnQgdHlwZSwgaW50IGxlbiwgRklMRSAq aW9wLAogICAgICAgKnB0cisrID0gJ1wwJzsKICAgICAgIHN0cmluZ19sZW5ndGgrKzsKICAg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AKICAgICAgIC8qIE1ha2UgaXRzIHNpemUgZG91YmxlZCwgcGx1cyBhIHNw YWNlIGZvciB0aGlzIGRpcmVjdG9yeS4gICovCkBAIC0xMzUsNyArMTM2LDcgQEAgcHVzaF9k aXIoY29uc3QgY2hhciAqZGlyKQogICAgICAgICAgIGVycm5vID0gRU5PTUVNOwogICAgICAg ICAgIHJldHVybiAwOwogICAgICAgICB9Ci0gICAgICBwb29sX2VuZCArPSB0ZW1wIC0gZGly bmFtZXNfcG9vbDsKKyAgICAgIHBvb2xfZW5kICs9IChpbnQpIHRlbXAgLSBvbGRfcHRyOwog ICAgICAgZGlybmFtZXNfcG9vbCA9IHRlbXA7CiAgICAgfQogCkBAIC0xNDMsNiArMTQ0LDcg QEAgcHVzaF9kaXIoY29uc3QgY2hhciAqZGlyKQogICBpZiAoKytzdGFja190b3AgLSBkaXJz dGFjayA+PSBzdGFja19zaXplKQogICAgIHsKICAgICAgIC8qIE5vdCBlbm91Z2ggc3RvcmFn ZS0tcmVhbGxvY2F0ZS4gICovCisgICAgICBjb25zdCBpbnQgb2xkX3B0ciA9IChpbnQpIGRp cnN0YWNrOwogICAgICAgU3RhY2tlZF9EaXIgKiB0ZW1wOwogCiAgICAgICBzdGFja19zaXpl ICo9IDI7CkBAIC0xNTMsNyArMTU1LDcgQEAgcHVzaF9kaXIoY29uc3QgY2hhciAqZGlyKQog ICAgICAgICAgIGVycm5vID0gRU5PTUVNOwogICAgICAgICAgIHJldHVybiAwOwogICAgICAg ICB9Ci0gICAgICBzdGFja190b3AgKz0gdGVtcCAtIGRpcnN0YWNrOworICAgICAgc3RhY2tf dG9wICs9IChpbnQpIHRlbXAgLSBvbGRfcHRyOwogICAgICAgZGlyc3RhY2sgPSB0ZW1wOwog ICAgIH0KIAotLSAKMi40MC4xCgo= --------------dYgo2b4H43kc8Bd22nMMXG9L Content-Type: text/plain; charset=UTF-8; name="0002-fix-bogus-free-nonheap-object-warning-in-gcc-12.patch" Content-Disposition: attachment; filename*0="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qIGFsaWdubWVudCBNVVNUIGJlIGEgcG93ZXIgb2YgdHdvLCBtYXggNjU1MzYuICAgICAg ICAqLwotLSAKMi40MC4xCgo= --------------dYgo2b4H43kc8Bd22nMMXG9L Content-Type: text/plain; charset=UTF-8; name="0003-silence-array-bounds-warning-in-gcc-12.patch" Content-Disposition: attachment; filename="0003-silence-array-bounds-warning-in-gcc-12.patch" Content-Transfer-Encoding: base64 RnJvbSAxNDM4ZTliNDk5MzUzYjlkNzI0MTNlYWZmZWVmZDE4ODQ2MjBjMDczIE1vbiBTZXAg MTcgMDA6MDA6MDAgMjAwMQpGcm9tOiAiSi5XLiBKYWdlcnNtYSIgPGp3amFnZXJzbWFAZ21h aWwuY29tPgpEYXRlOiBXZWQsIDI4IEp1biAyMDIzIDE4OjMwOjI5ICswMjAwClN1YmplY3Q6 IFtQQVRDSCAzLzNdIHNpbGVuY2UgYXJyYXktYm91bmRzIHdhcm5pbmcgaW4gZ2NjIDEyCgot LS0KIHNyYy9saWJjL2NydDAvbWNvdW50LmMgfCAxNCArKysrKysrKystLS0tLQogMSBmaWxl IGNoYW5nZWQsIDkgaW5zZXJ0aW9ucygrKSwgNSBkZWxldGlvbnMoLSkKCmRpZmYgLS1naXQg YS9zcmMvbGliYy9jcnQwL21jb3VudC5jIGIvc3JjL2xpYmMvY3J0MC9tY291bnQuYwppbmRl eCBhMDQ3OWIxYi4uYTg1OWM4OWMgMTAwNjQ0Ci0tLSBhL3NyYy9saWJjL2NydDAvbWNvdW50 LmMKKysrIGIvc3JjL2xpYmMvY3J0MC9tY291bnQuYwpAQCAtNTIsOSArNTIsMTAgQEAgc3Rh dGljIGludCBwcm9maWxpbmdfcDsKICoqIHRoZSBsYXN0IHVzZWQgTVRBQkUsIHNvIHRoYXQg cmVwZWF0ZWQgY2FsbHMgdG8vZnJvbSB0aGUgc2FtZQogKiogcGFpciB3b3JrcyBxdWlja2x5 IC0gbm8gbG9va3VwLgogKi8KLXZvaWQgbWNvdW50KGludCBfdG8pOwotdm9pZCBtY291bnQo aW50IF90bykKK3ZvaWQgbWNvdW50KGludCBhcmcpOwordm9pZCBtY291bnQoaW50IGFyZykK IHsKKyAgaW50ICphcmdfcHRyID0gJmFyZzsKICAgTVRBQiAqbTsKICAgaW50IGk7CiAgIHVu c2lnbmVkIGludCB0bzsKQEAgLTcxLDExICs3MiwxNCBAQCB2b2lkIG1jb3VudChpbnQgX3Rv KQogICBpZiAoIXByb2ZpbGluZ19wKQogICAgIHJldHVybjsKIAotICBpZiAoJl90byA8ICZl dGV4dCkKKyAgLyogTGF1bmRlciBhcmdfcHRyIHRvIHN1cHByZXNzIHdhcm5pbmdzLiAgKi8K KyAgX19hc21fXyAoIiIgOiAiK3JtIiAoYXJnX3B0cikpOworCisgIGlmIChhcmdfcHRyIDwg JmV0ZXh0KQogICAgICooaW50ICopKC0xKSA9IDA7IC8qIGZhdWx0ISAqLwogCi0gIHRvID0g KigoJl90byktMSkgLSAxMjsKLSAgZWJwID0gKigoJl90byktMik7IC8qIGdsZWFuIHRoZSBj YWxsZXIncyByZXR1cm4gYWRkcmVzcyBmcm9tIHRoZSBzdGFjayAqLworICB0byA9IGFyZ19w dHJbLTFdIC0gMTI7CisgIGVicCA9IGFyZ19wdHJbLTJdOyAvKiBnbGVhbiB0aGUgY2FsbGVy J3MgcmV0dXJuIGFkZHJlc3MgZnJvbSB0aGUgc3RhY2sgKi8KICAgZnJvbSA9ICgoaW50ICop ZWJwKVsxXTsKICAgLyogRG8gbm90aGluZyBpZiB0aGUgRlJPTSBhZGRyZXNzIGlzIG91dHNp ZGUgdGhlIHNhbXBsaW5nIHJhbmdlLiAgKi8KICAgaWYgKGZyb20gPCBoLmxvdyB8fCBmcm9t ID49IGguaGlnaCkKLS0gCjIuNDAuMQoK --------------dYgo2b4H43kc8Bd22nMMXG9L--