OSDN Git Service

qemu-ga: ga_open_pidfile(): add new line to pidfile
authorLuiz Capitulino <lcapitulino@redhat.com>
Wed, 3 Oct 2012 21:40:01 +0000 (18:40 -0300)
committerMichael Roth <mdroth@linux.vnet.ibm.com>
Tue, 9 Oct 2012 08:42:42 +0000 (03:42 -0500)
FHS requires that pid files should end with a new line. Also change to
snprintf() while there.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Reviewed-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
qemu-ga.c

index daeaea5..9b59a52 100644 (file)
--- a/qemu-ga.c
+++ b/qemu-ga.c
@@ -255,7 +255,7 @@ static bool ga_open_pidfile(const char *pidfile)
         g_critical("Failed to truncate pid file");
         goto fail;
     }
-    sprintf(pidstr, "%d", getpid());
+    snprintf(pidstr, sizeof(pidstr), "%d\n", getpid());
     if (write(pidfd, pidstr, strlen(pidstr)) != strlen(pidstr)) {
         g_critical("Failed to write pid file");
         goto fail;