coverity: #1427668

parent e14d8270
...@@ -76,23 +76,25 @@ static void usage(void) { ...@@ -76,23 +76,25 @@ static void usage(void) {
static void remove_self(void) static void remove_self(void)
{ {
char path[PATH_MAX]; int ret;
ssize_t n; ssize_t n;
char path[MAXPATHLEN] = {0};
n = readlink("/proc/self/exe", path, sizeof(path)); n = readlink("/proc/self/exe", path, sizeof(path));
if (n < 0) { if (n < 0 || n >= MAXPATHLEN) {
SYSERROR("Failed to readlink \"/proc/self/exe\""); SYSERROR("Failed to readlink \"/proc/self/exe\"");
return; return;
} }
path[n] = '\0';
path[n] = 0; ret = umount2(path, MNT_DETACH);
if (ret < 0) {
if (umount2(path, MNT_DETACH) < 0) {
SYSERROR("Failed to unmount \"%s\"", path); SYSERROR("Failed to unmount \"%s\"", path);
return; return;
} }
if (unlink(path) < 0) { ret = unlink(path);
if (ret < 0) {
SYSERROR("Failed to unlink \"%s\"", path); SYSERROR("Failed to unlink \"%s\"", path);
return; return;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment