[Rpm-maint] [rpm-software-management/rpm] Fix signed vs unsigned comparisons (PR #3515)

Panu Matilainen notifications at github.com
Fri Jan 10 13:09:37 UTC 2025


@pmatilai commented on this pull request.



> @@ -976,12 +976,12 @@ static int isHardLink(FileListRec flp, FileListRec tlp)
  */
 static int checkHardLinks(FileRecords & files)
 {
-    for (int i = 0;  i < files.size(); i++) {
+    for (rpm_count_t i = 0;  i < files.size(); i++) {

I don't think rpm_count_t is right here: rpm_count_t reflects the limit inside headers, but here the data is in a vector that can hold much more, so given enough files in a buildroot, rpm_count_t could roll over and behave in various interesting ways.

I almost wrote it should use the same type as files.size() returns, but what this *really* should do is use iterators to avoid the issue entirely.

-- 
Reply to this email directly or view it on GitHub:
https://github.com/rpm-software-management/rpm/pull/3515#pullrequestreview-2542404387
You are receiving this because you are subscribed to this thread.

Message ID: <rpm-software-management/rpm/pull/3515/review/2542404387 at github.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rpm.org/pipermail/rpm-maint/attachments/20250110/33a0d170/attachment.htm>


More information about the Rpm-maint mailing list