]> xenbits.xensource.com Git - libvirt.git/commitdiff
don't emulate snprintf
authorGuido Günther <agx@sigxcpu.org>
Sun, 11 Jan 2009 11:21:29 +0000 (11:21 +0000)
committerGuido Günther <agx@sigxcpu.org>
Sun, 11 Jan 2009 11:21:29 +0000 (11:21 +0000)
ChangeLog
src/qemu_driver.c

index a71c9c5cec4bff22afd0aed54897d7cdd9838685..853b46d52e04ee515a2d2d567acee59a84049404 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+Sun Jan 11 12:18:38 CET 2009 Guido Günther<agx@sigxcpu.org>
+
+       * src/qemu_driver.c (qemudLogFD): use snprintf instead of emulating it
+
 Sun Jan 11 12:16:44 CET 2009 Guido Günther <agx@sigxcpu.org>
 
        split out opening of the qemu logfile
index d4c56d6780b1082a70203388b36613dc7e6e98af..f5168e1eaab15e5e76b4aab1bc65435a0cbfd456 100644 (file)
@@ -149,24 +149,16 @@ qemudLogFD(virConnectPtr conn, const char* logDir, const char* name)
     char logfile[PATH_MAX];
     mode_t logmode;
     uid_t uid = geteuid();
-    int fd = -1;
+    int ret, fd = -1;
 
-    if ((strlen(logDir) + /* path */
-         1 + /* Separator */
-         strlen(name) + /* basename */
-         4 + /* suffix .log */
-         1 /* NULL */) > PATH_MAX) {
+    if ((ret = snprintf(logfile, sizeof(logfile), "%s/%s.log", logDir, name))
+        < 0 || ret >= sizeof(logfile)) {
         qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
-                         _("config file path too long: %s/%s.log"),
+                         _("failed to build logfile name %s/%s.log"),
                          logDir, name);
         return -1;
     }
 
-    strcpy(logfile, logDir);
-    strcat(logfile, "/");
-    strcat(logfile, name);
-    strcat(logfile, ".log");
-
     logmode = O_CREAT | O_WRONLY;
     if (uid != 0)
         logmode |= O_TRUNC;