]> git.proxmox.com Git - mirror_lxc.git/commit
confile: improve strprint()
authorChristian Brauner <christian.brauner@ubuntu.com>
Wed, 30 May 2018 13:34:03 +0000 (15:34 +0200)
committerChristian Brauner <christian.brauner@ubuntu.com>
Wed, 30 May 2018 13:46:06 +0000 (15:46 +0200)
commit9496659c6b167951d0e1ae4109a9d08da0d1b31a
treeb381b6e7c2fd33a6602a88e2de59b7647ab09533
parent9715e65c41dce245022c3dde8595659f928fe47f
confile: improve strprint()

POSIX specifies [1]:
"If the value of n is zero on a call to snprintf(), nothing shall be written,
the number of bytes that would have been written had n been sufficiently large
excluding the terminating null shall be returned, and s may be a null pointer."

But in case there are any non-sane libcs out there that do actually dereference
the buffer when when 0 is passed as length to snprintf() let's give them a
dummy buffer.

[1]: The Open Group Base Specifications Issue 7, 2018 edition
     IEEE Std 1003.1-2017 (Revision of IEEE Std 1003.1-2008)
     Copyright © 2001-2018 IEEE and The Open Group

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
Reported-by: Donghwa Jeong <dh48.jeong@samsung.com>
src/lxc/confile_utils.h