[libvirt] [PATCH] return a sensible error on bogus paths
Daniel P. Berrange
berrange at redhat.com
Tue May 5 09:38:12 UTC 2009
On Mon, May 04, 2009 at 09:40:33PM +0200, Guido G?nther wrote:
> Hi,
> attached patch makes it easier to detect bogus paths when
> creating/removing pidfiles. O.k. to apply?
ACK
> >From f79fcd99b28e36cbb80bd91ac52109148eafa814 Mon Sep 17 00:00:00 2001
> From: =?utf-8?q?Guido=20G=C3=BCnther?= <agx at sigxcpu.org>
> Date: Mon, 4 May 2009 21:31:57 +0200
> Subject: [PATCH] return EINVAL on dir == NULL || name == NULL
>
> ---
> src/util.c | 15 +++++++++++++++
> 1 files changed, 15 insertions(+), 0 deletions(-)
>
> diff --git a/src/util.c b/src/util.c
> index 47a1cd3..c5edc9d 100644
> --- a/src/util.c
> +++ b/src/util.c
> @@ -1165,6 +1165,11 @@ int virFileWritePid(const char *dir,
> FILE *file = NULL;
> char *pidfile = NULL;
>
> + if (name == NULL || dir == NULL) {
> + rc = EINVAL;
> + goto cleanup;
> + }
> +
> if ((rc = virFileMakePath(dir)))
> goto cleanup;
>
> @@ -1212,6 +1217,11 @@ int virFileReadPid(const char *dir,
> char *pidfile = NULL;
> *pid = 0;
>
> + if (name == NULL || dir == NULL) {
> + rc = EINVAL;
> + goto cleanup;
> + }
> +
> if (!(pidfile = virFilePid(dir, name))) {
> rc = ENOMEM;
> goto cleanup;
> @@ -1246,6 +1256,11 @@ int virFileDeletePid(const char *dir,
> int rc = 0;
> char *pidfile = NULL;
>
> + if (name == NULL || dir == NULL) {
> + rc = EINVAL;
> + goto cleanup;
> + }
> +
> if (!(pidfile = virFilePid(dir, name))) {
> rc = ENOMEM;
> goto cleanup;
> --
> 1.6.2.4
>
> --
> Libvir-list mailing list
> Libvir-list at redhat.com
> https://www.redhat.com/mailman/listinfo/libvir-list
--
|: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :|
|: http://libvirt.org -o- http://virt-manager.org -o- http://ovirt.org :|
|: http://autobuild.org -o- http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|
More information about the libvir-list
mailing list