Skip to content

Commit cb16d07

Browse files
bazel-iobenjaminp
andauthored
[7.0.0] ijar: Widen some size types. (bazelbuild#19995)
This is a follow up to bazelbuild@ac10bac. Closes bazelbuild#19722. Commit bazelbuild@a69fdb8 PiperOrigin-RevId: 577864132 Change-Id: I4b7165b6abfd55f545811bd16c8e5cf02ae183ae Co-authored-by: Benjamin Peterson <[email protected]>
1 parent 69feddb commit cb16d07

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

third_party/ijar/zip_main.cc

+6-2
Original file line numberDiff line numberDiff line change
@@ -254,10 +254,14 @@ char **read_filelist(char *filename) {
254254
}
255255

256256
int nb_entries = 1;
257-
for (int i = 0; i < file_stat.total_size; i++) {
257+
for (u8 i = 0; i < file_stat.total_size; i++) {
258258
if (data[i] == '\n') {
259259
nb_entries++;
260260
}
261+
if (nb_entries == INT_MAX) {
262+
fprintf(stderr, "too many input files");
263+
return NULL;
264+
}
261265
}
262266

263267
size_t sizeof_array = sizeof(char *) * (nb_entries + 1);
@@ -271,7 +275,7 @@ char **read_filelist(char *filename) {
271275
// Create the corresponding array
272276
int j = 1;
273277
filelist[0] = content;
274-
for (int i = 0; i < file_stat.total_size; i++) {
278+
for (u8 i = 0; i < file_stat.total_size; i++) {
275279
if (content[i] == '\n') {
276280
content[i] = 0;
277281
if (i + 1 < file_stat.total_size) {

0 commit comments

Comments
 (0)