[FFmpeg-devel] [PATCH 5/9] nistspheredec: prevent overflow during block alignment calculation
Andreas Cadhalpun
andreas.cadhalpun at googlemail.com
Sat Jan 28 02:26:40 EET 2017
On 27.01.2017 02:56, Marton Balint wrote:
> I see 3 problems (wm4 explicitly named them, but I also had them in mind)
> - Little benefit, yet
> - Makes the code less clean, more cluttered
> - Increases binary size
>
> The ideas I proposed (use macros, use common / factorized checks for common
> validatons and errors) might be a good compromise IMHO. Fuzzing thereforce
> can be done with "debug" builds.
>
> Anyway, I am not blocking the patch, just expressing what I would prefer in
> the long run.
How about the following macro?
#define FF_RETURN_ERROR(condition, error, log_ctx, ...) { \
if (condition) { \
if (!CONFIG_SMALL && log_ctx) \
av_log(log_ctx, AV_LOG_ERROR, __VA_ARGS__); \
return error; \
} \
}
That could be used with error message:
FF_RETURN_ERROR(st->codecpar->channels > FF_SANE_NB_CHANNELS, AVERROR(ENOSYS),
s, "Too many channels %d > %d\n", st->codecpar->channels, FF_SANE_NB_CHANNELS)
Or without:
FF_RETURN_ERROR(st->codecpar->channels > FF_SANE_NB_CHANNELS, AVERROR(ENOSYS), NULL)
Best regards,
Andreas
More information about the ffmpeg-devel
mailing list