don't emulate snprintf

This commit is contained in:
Guido Günther 2009-01-11 11:21:29 +00:00
parent 4275be68fb
commit 8af87ea251
2 changed files with 8 additions and 12 deletions

View File

@ -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> Sun Jan 11 12:16:44 CET 2009 Guido Günther <agx@sigxcpu.org>
split out opening of the qemu logfile split out opening of the qemu logfile

View File

@ -149,24 +149,16 @@ qemudLogFD(virConnectPtr conn, const char* logDir, const char* name)
char logfile[PATH_MAX]; char logfile[PATH_MAX];
mode_t logmode; mode_t logmode;
uid_t uid = geteuid(); uid_t uid = geteuid();
int fd = -1; int ret, fd = -1;
if ((strlen(logDir) + /* path */ if ((ret = snprintf(logfile, sizeof(logfile), "%s/%s.log", logDir, name))
1 + /* Separator */ < 0 || ret >= sizeof(logfile)) {
strlen(name) + /* basename */
4 + /* suffix .log */
1 /* NULL */) > PATH_MAX) {
qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, 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); logDir, name);
return -1; return -1;
} }
strcpy(logfile, logDir);
strcat(logfile, "/");
strcat(logfile, name);
strcat(logfile, ".log");
logmode = O_CREAT | O_WRONLY; logmode = O_CREAT | O_WRONLY;
if (uid != 0) if (uid != 0)
logmode |= O_TRUNC; logmode |= O_TRUNC;