qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] bug writing pidfile under unix (and fix)


From: Anthony Liguori
Subject: Re: [Qemu-devel] bug writing pidfile under unix (and fix)
Date: Tue, 11 Nov 2008 15:05:00 -0600
User-agent: Thunderbird 2.0.0.17 (X11/20080925)

Jim Bailey wrote:
Hello,

In qemu_create_pidfile (osdep.c:229) the current pid and a newline is
written to the pidfile. However, the pidfile isn't truncated, so if it
is longer than the length of the pid and the newline character you get
trailing junk that can really mess up scripts.

I noticed this when going from a 5 digit pid to a 3 digit pid, so it
can happen in regular operation, especially if the OS randomizes pids.

Truncating the file fixes the bug.

Needs a Signed-off-by.

Regards,

Anthony Liguori

dgym


*** osdep.c.orig        Fri Nov  7 16:56:12 2008
--- osdep.c     Fri Nov  7 16:58:49 2008
***************
*** 236,241 ****
--- 236,243 ----
      len = snprintf(buffer, sizeof(buffer), "%ld\n", (long)getpid());
      if (write(fd, buffer, len) != len)
          return -1;
+ + ftruncate(fd, len);
  #else
      HANDLE file;
      DWORD flags;







reply via email to

[Prev in Thread] Current Thread [Next in Thread]