summaryrefslogtreecommitdiffstats
path: root/server
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:31:46 -0500
commit4bef93eb16938efae6dd110790f5f57c76eb9117 (patch)
tree9cf472f8affd0453152693b70df8c9e7cf11d3f0 /server
parent202bd8e4d0a4b7e3d09f0eb5a6ac512ff83d9285 (diff)
downloadsssd-4bef93eb16938efae6dd110790f5f57c76eb9117.tar.gz
sssd-4bef93eb16938efae6dd110790f5f57c76eb9117.tar.xz
sssd-4bef93eb16938efae6dd110790f5f57c76eb9117.zip
Add allocation error check
Diffstat (limited to 'server')
-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());