I had incorrectly assumed that only the last dataBlock has any padding, but that’s not true based on the way exiftool is reading the data.
Through my testing, exiftool is finding non-terminal dataBlocks that it determines need padding.
Since we want to copy each dataBlock as it exists in the original file including any in-line garbage data that is considered padding, we should copy each dataBlock for $size + $pad.
Also, exiftool is writing ‘\0’ for the padding to its output file when, imho, it shouldn’t modify the raw image data. This would immediately modify the raw image data on the first write for affected raw files. I’ll ask the maintainer about this.