summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephen Gallagher <sgallagh@redhat.com>2009-12-08 10:58:01 -0500
committerStephen Gallagher <sgallagh@redhat.com>2009-12-08 12:30:02 -0500
commit99d9df65b65928f754f75013cf9f2f06bdbf3104 (patch)
tree2acce993c05fc120a4e79c1587ab863fefb52909
parent0f29c921fe2138eadac33803115ad71a3e8715db (diff)
downloadsssd-99d9df65b65928f754f75013cf9f2f06bdbf3104.tar.gz
sssd-99d9df65b65928f754f75013cf9f2f06bdbf3104.tar.xz
sssd-99d9df65b65928f754f75013cf9f2f06bdbf3104.zip
Add allocation error check
-rw-r--r--server/util/server.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/server/util/server.c b/server/util/server.c
index 3a84c70d7..977deaeb2 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());