Skip to content

Commit

Permalink
Adjust loops to use size_t instead of int
Browse files Browse the repository at this point in the history
Gbp-Dch: ignore
  • Loading branch information
julian-klode committed Feb 9, 2021
1 parent 6284c82 commit ea11444
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions test/interactive-helper/createdeb-cve-2020-27350.cc
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ static void createtar(const int fd)
struct TarHeader t;
char buf[512];
} t;
for (int i = 0; i < sizeof(t.buf); i++)
for (size_t i = 0; i < sizeof(t.buf); i++)
t.buf[i] = '7';
memcpy(t.t.Name, "unterminatedName", 16);
memcpy(t.t.UserName, "userName", 8);
Expand All @@ -247,11 +247,11 @@ static void createtar(const int fd)
memset(t.t.Checksum, ' ', sizeof(t.t.Checksum));

unsigned long sum = 0;
for (int i = 0; i < sizeof(t.buf); i++)
for (size_t i = 0; i < sizeof(t.buf); i++)
sum += t.buf[i];

int written = sprintf(t.t.Checksum, "%lo", sum);
for (int i = written; i < sizeof(t.t.Checksum); i++)
for (size_t i = written; i < sizeof(t.t.Checksum); i++)
t.t.Checksum[i] = ' ';
write_chk(fd, t.buf, sizeof(t.buf));
}
Expand Down

0 comments on commit ea11444

Please sign in to comment.