check for NULL pointers in pidfile functions

This commit is contained in:
Guido Günther 2009-05-07 07:29:51 +00:00
parent 7ee54d8356
commit 1dfc35677e
2 changed files with 22 additions and 0 deletions

View File

@ -1,3 +1,10 @@
Thu May 7 09:26:50 CEST 2009 Guido Günther <agx@sigxcpu.org>
* src/util.c (virFileWritePid): check for NULL pointers
to avoid bogus pid files
(virFileReadPid): likewise
(virFileDeletePid): likewise
Thu May 7 09:24:47 CEST 2009 Daniel Veillard <veillard@redhat.com> Thu May 7 09:24:47 CEST 2009 Daniel Veillard <veillard@redhat.com>
* src/domain_conf.c src/domain_conf.h: parse and save multiple * src/domain_conf.c src/domain_conf.h: parse and save multiple

View File

@ -1165,6 +1165,11 @@ int virFileWritePid(const char *dir,
FILE *file = NULL; FILE *file = NULL;
char *pidfile = NULL; char *pidfile = NULL;
if (name == NULL || dir == NULL) {
rc = EINVAL;
goto cleanup;
}
if ((rc = virFileMakePath(dir))) if ((rc = virFileMakePath(dir)))
goto cleanup; goto cleanup;
@ -1212,6 +1217,11 @@ int virFileReadPid(const char *dir,
char *pidfile = NULL; char *pidfile = NULL;
*pid = 0; *pid = 0;
if (name == NULL || dir == NULL) {
rc = EINVAL;
goto cleanup;
}
if (!(pidfile = virFilePid(dir, name))) { if (!(pidfile = virFilePid(dir, name))) {
rc = ENOMEM; rc = ENOMEM;
goto cleanup; goto cleanup;
@ -1246,6 +1256,11 @@ int virFileDeletePid(const char *dir,
int rc = 0; int rc = 0;
char *pidfile = NULL; char *pidfile = NULL;
if (name == NULL || dir == NULL) {
rc = EINVAL;
goto cleanup;
}
if (!(pidfile = virFilePid(dir, name))) { if (!(pidfile = virFilePid(dir, name))) {
rc = ENOMEM; rc = ENOMEM;
goto cleanup; goto cleanup;