By going through the frames of the video I can see the timestamps and when the video reaches the last frame I can compute the total number of frames and total time that are actually in the video. So in theory this should be enough to fix this kind of files automatically. I'm not sure what's the best way to go about it though.
It could initially leave things as they are and after the first loop, when it realizes the last frame doesn't match the duration, try to fix it.
There could be a explicit "Fix duration" button in the Video > Configure timing dialog, that would perform the test and save the actual duration somewhere. This could then become an option in the main preferences to "always try to fix duration", but would be off by default because it will slow down opening the files in the normal case.
Other ideas are welcomed.