40
static struct line_buffer input = LINE_BUFFER_INIT;
41
42
static struct {
43
- uint32_t action, propLength, textLength, srcRev, type;
43
+ uint32_t action, propLength, srcRev, type;
44
+ off_t text_length;
45
struct strbuf src, dst;
46
uint32_t text_delta, prop_delta;
47
} node_ctx;
62
node_ctx.type = 0;
63
node_ctx.action = NODEACT_UNKNOWN;
64
node_ctx.propLength = LENGTH_UNKNOWN;
64
- node_ctx.textLength = LENGTH_UNKNOWN;
65
+ node_ctx.text_length = -1;
66
strbuf_reset(&node_ctx.src);
67
node_ctx.srcRev = 0;
68
strbuf_reset(&node_ctx.dst);
210
{
211
const uint32_t type = node_ctx.type;
212
const int have_props = node_ctx.propLength != LENGTH_UNKNOWN;
212
- const int have_text = node_ctx.textLength != LENGTH_UNKNOWN;
213
+ const int have_text = node_ctx.text_length != -1;
214
/*
215
* Old text for this node:
216
* NULL - directory or bug
292
}
293
if (!node_ctx.text_delta) {
294
fast_export_modify(node_ctx.dst.buf, node_ctx.type, "inline");
294
- fast_export_data(node_ctx.type, node_ctx.textLength, &input);
295
+ fast_export_data(node_ctx.type, node_ctx.text_length, &input);
296
return;
297
}
298
fast_export_modify(node_ctx.dst.buf, node_ctx.type, "inline");
299
fast_export_blob_delta(node_ctx.type, old_mode, old_data,
299
- node_ctx.textLength, &input);
300
+ node_ctx.text_length, &input);
301
}
302
303
static void begin_revision(void)
410
break;
411
case sizeof("Text-content-length"):
412
if (!constcmp(t, "Text-content-length")) {
412
- node_ctx.textLength = atoi(val);
413
+ char *end;
414
+ uintmax_t textlen;
415
+
416
+ textlen = strtoumax(val, &end, 10);
417
+ if (!isdigit(*val) || *end)
418
+ die("invalid dump: non-numeric length %s", val);
419
+ if (textlen > maximum_signed_value_of_type(off_t))
420
+ die("unrepresentable length in dump: %s", val);
421
+ node_ctx.text_length = (off_t) textlen;
422
break;
423
}
424
if (constcmp(t, "Prop-content-length"))