port/snprintf(): fix overflow and do padding

Bruce Momjian <bruce@momjian.us>

Commit: 29725b3db67ad3f09da1a7fb6690737d2f8d6c0a
Author: Bruce Momjian <bruce@momjian.us>
Date: 2015-02-02T15:00:45Z
Releases: 9.5.0
port/snprintf():  fix overflow and do padding

Prevent port/snprintf() from overflowing its local fixed-size
buffer and pad to the desired number of digits with zeros, even
if the precision is beyond the ability of the native sprintf().
port/snprintf() is only used on systems that lack a native
snprintf().

Reported by Bruce Momjian. Patch by Tom Lane.	Backpatch to all
supported versions.

Security: CVE-2015-0242

Files

PathChange+/−
src/port/snprintf.c modified +62 −7