N
Nick Maclaren
- Jan 1, 1970
- 0
This is getting ridiculously off-topic, and this will be my last
posting on this sub-thread.
|>
|> I know we can go on, but probably mean the same thing in the end,
|> but 'the program would not need inspecting (or changing)' sounds a
|> bit, eh, daring, if not wrong.
|> Take the example of a program that concatenates some wave files to
|> one larger one.
|> It will first read all headers, add the sizes, and then, if it finds the
|> output exceeds 4GB say: 'myprogram: output exceeds 4GB, aborting.'
|> So, the size check, and the reporting, would need to change, in any case.
That is not how to approach such a problem. Inter alia, it prevents
the program from concatenating files in a format with a 4 GB limit
and writing them to one with a larger limit. You should write it
like this:
Each header is read and decodes, and the length is put in an internal
format integer.
The concatenation code adds the lengths, checking that they don't
overflow, and giving a diagnostic if they do.
It then writes the result to the output, checking that the file will
fit, and diagnosing if it won't.
Regards,
Nick Maclaren.
posting on this sub-thread.
|>
|> I know we can go on, but probably mean the same thing in the end,
|> but 'the program would not need inspecting (or changing)' sounds a
|> bit, eh, daring, if not wrong.
|> Take the example of a program that concatenates some wave files to
|> one larger one.
|> It will first read all headers, add the sizes, and then, if it finds the
|> output exceeds 4GB say: 'myprogram: output exceeds 4GB, aborting.'
|> So, the size check, and the reporting, would need to change, in any case.
That is not how to approach such a problem. Inter alia, it prevents
the program from concatenating files in a format with a 4 GB limit
and writing them to one with a larger limit. You should write it
like this:
Each header is read and decodes, and the length is put in an internal
format integer.
The concatenation code adds the lengths, checking that they don't
overflow, and giving a diagnostic if they do.
It then writes the result to the output, checking that the file will
fit, and diagnosing if it won't.
Regards,
Nick Maclaren.