diff --git a/plug-ins/common/file-psp.c b/plug-ins/common/file-psp.c index ef39d5b847..04897d5b53 100644 --- a/plug-ins/common/file-psp.c +++ b/plug-ins/common/file-psp.c @@ -1197,6 +1197,10 @@ read_channel_data (FILE *f, } else fread (buf, runcount, 1, f); + + /* prevent buffer overflow for bogus data */ + runcount = MIN (runcount, endq - q); + if (bytespp == 1) { memmove (q, buf, runcount);