Try to be a bit more strict about integer types, use off_t or int64_t for file size and file offsets. Replace safe_ato*() by safe_atoi32() and safe_atoi64(), fix integer types at call sites to match.