-
- for (i = 0; i <= afhi->chunks_total; i++)
- write_u32(buf + 4 * i, afhi->chunk_table[i]);
+ uint32_t max = 0, old = 0;
+
+ for (i = 0; i <= afhi->chunks_total; i++) {
+ uint32_t val = afhi->chunk_table[i];
+ write_u32(buf + 4 * i, val);
+ /*
+ * If the first chunk is the header, do not consider it for the
+ * calculation of the largest chunk size.
+ */
+ if (i == 0 || (i == 1 && afhi->header_len > 0)) {
+ old = val;
+ continue;
+ }
+ max = PARA_MAX(max, val - old);
+ old = val;
+ }
+ return max;