mirror of
https://github.com/libvirt/libvirt.git
synced 2026-09-03 20:53:04 -05:00
maint: avoid remaining sprintf uses
* cfg.mk (sc_prohibit_sprintf): New rule. (sc_prohibit_asprintf): Avoid false positives. * docs/hacking.html.in (Printf-style functions): Document the policy. * HACKING: Regenerate. * .x-sc_prohibit_sprintf: New exemptions. * Makefile.am (syntax_check_exceptions): Ship new file. * src/vbox/vbox_tmpl.c (vboxStartMachine, vboxAttachUSB): Use virAsprintf instead. * src/uml/uml_driver.c (umlOpenMonitor): Use snprintf instead. * tools/virsh.c (cmdDetachInterface): Likewise. * src/security/security_selinux.c (SELinuxGenSecurityLabel): Likewise. * src/openvz/openvz_driver.c (openvzDomainDefineCmd): Likewise, and ensure large enough buffer.
This commit is contained in:
@@ -538,6 +538,12 @@ virAsprintf, in util.h:
|
||||
This makes it so gcc's -Wformat and -Wformat-security options can do their
|
||||
jobs and cross-check format strings with the number and types of arguments.
|
||||
|
||||
When printing to a string, consider using virBuffer for incremental
|
||||
allocations, virAsprintf for a one-shot allocation, and snprintf for
|
||||
fixed-width buffers. Do not use sprintf, even if you can prove the buffer
|
||||
won't overflow, since gnulib does not provide the same portability guarantees
|
||||
for sprintf as it does for snprintf.
|
||||
|
||||
|
||||
Use of goto
|
||||
===========
|
||||
|
||||
Reference in New Issue
Block a user