The the supplied argument is an empty string, eject triggers an out of
boundary access due to strlen() - 1 calculation.
Verify that the string is not empty before checking its last character.
Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
verbose(&ctl, _("using default device `%s'"), ctl.device);
} else {
char *p;
+ size_t len = strlen(ctl.device);
- if (ctl.device[strlen(ctl.device) - 1] == '/')
- ctl.device[strlen(ctl.device) - 1] = '\0';
+ if (len && ctl.device[len - 1] == '/')
+ ctl.device[len - 1] = '\0';
/* figure out full device or mount point name */
p = find_device(ctl.device);