diff --git a/ppd/imagetops-pstops.c b/ppd/imagetops-pstops.c index bf12609a..4b79830b 100644 --- a/ppd/imagetops-pstops.c +++ b/ppd/imagetops-pstops.c @@ -3622,11 +3622,11 @@ doc_printf(pstops_doc_t *doc, // I - Document information bytes = vsnprintf(buffer, sizeof(buffer), format, ap); va_end(ap); - if ((size_t)bytes > sizeof(buffer)) + if ((size_t)bytes >= sizeof(buffer)) { if (log) log(ld, CF_LOGLEVEL_ERROR, "ppdFilterPSToPS: Buffer overflow detected, truncating."); - bytes = sizeof(buffer); + bytes = sizeof(buffer) - 1; } doc_write(doc, buffer, (size_t)bytes);