bosserver: use normal asprintf idiom

We generally tend to explicitly NULL out the buffer argument if
asprintf() returns failure, since it is not guaranteed to have done
so itself.  It is even less clear whether setting the buffer argument
to NULL ourselves before calling asprintf() will be untouched in all
possible failures, so re-zero it after failed calls just to be sure
we don't try to free garbage later.

Change-Id: Ie8995472aeadb8043f5e43f4e6d197a7be1363e0
Reviewed-on: https://gerrit.openafs.org/15832
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
This commit is contained in:
Benjamin Kaduk 2024-08-11 15:57:05 -07:00 committed by Michael Meffie
parent 5a20d9e219
commit 3bf2a27566

View File

@ -713,14 +713,18 @@ make_pid_filename(char *ainst, char *aname)
if (aname && *aname) {
r = asprintf(&buffer, "%s/%s.%s.pid", DoPidFiles, ainst, aname);
if (r < 0 || buffer == NULL)
if (r < 0 || buffer == NULL) {
ViceLog(0, ("Failed to alloc pid filename buffer for %s.%s.\n",
ainst, aname));
buffer = NULL;
}
} else {
r = asprintf(&buffer, "%s/%s.pid", DoPidFiles, ainst);
if (r < 0 || buffer == NULL)
if (r < 0 || buffer == NULL) {
ViceLog(0, ("Failed to alloc pid filename buffer for %s.\n",
ainst));
buffer = NULL;
}
}
return buffer;