diff options
author | Stephen Gallagher <sgallagh@redhat.com> | 2009-12-08 10:58:01 -0500 |
---|---|---|
committer | Stephen Gallagher <sgallagh@redhat.com> | 2009-12-08 12:30:02 -0500 |
commit | 99d9df65b65928f754f75013cf9f2f06bdbf3104 (patch) | |
tree | 2acce993c05fc120a4e79c1587ab863fefb52909 /server/util | |
parent | 0f29c921fe2138eadac33803115ad71a3e8715db (diff) | |
download | sssd-99d9df65b65928f754f75013cf9f2f06bdbf3104.tar.gz sssd-99d9df65b65928f754f75013cf9f2f06bdbf3104.tar.bz2 sssd-99d9df65b65928f754f75013cf9f2f06bdbf3104.zip |
Add allocation error check
Diffstat (limited to 'server/util')
-rw-r--r-- | server/util/server.c | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/server/util/server.c b/server/util/server.c index 3a84c70d..977deaeb 100644 --- a/server/util/server.c +++ b/server/util/server.c @@ -111,7 +111,10 @@ int pidfile(const char *path, const char *name) int fd; int ret, err; - asprintf(&file, "%s/%s.pid", path, name); + file = talloc_asprintf(NULL, "%s/%s.pid", path, name); + if (!file) { + return ENOMEM; + } fd = open(file, O_RDONLY, 0644); err = errno; @@ -129,25 +132,25 @@ int pidfile(const char *path, const char *name) /* succeeded in signaling the process -> another sssd process */ if (ret == 0) { close(fd); - free(file); + talloc_free(file); return EEXIST; } if (ret != 0 && errno != ESRCH) { err = errno; close(fd); - free(file); + talloc_free(file); return err; } } } - /* notihng in the file or no process */ + /* nothing in the file or no process */ close(fd); unlink(file); } else { if (err != ENOENT) { - free(file); + talloc_free(file); return err; } } @@ -155,10 +158,10 @@ int pidfile(const char *path, const char *name) fd = open(file, O_CREAT | O_WRONLY | O_EXCL, 0644); err = errno; if (fd == -1) { - free(file); + talloc_free(file); return err; } - free(file); + talloc_free(file); memset(pid_str, 0, sizeof(pid_str)); snprintf(pid_str, sizeof(pid_str) -1, "%u\n", (unsigned int) getpid()); |