{
char *s;
const char *tpl;
- static char prog[256];
+ static char *prog = NULL;
char *p = xstrdup(fsck_path);
/* Are we looking for a program or just a type? */
tpl = (strncmp(type, "fsck.", 5) ? "%s/fsck.%s" : "%s/%s");
for(s = strtok(p, ":"); s; s = strtok(NULL, ":")) {
- sprintf(prog, tpl, s, type);
+ xasprintf(&prog, tpl, s, type);
if (access(prog, X_OK) == 0)
break;
+ free(prog); prog = NULL;
}
free(p);
-
- return(s ? prog : NULL);
+ return(prog);
}
static int progress_active(void)
*/
static int fsck_device(struct libmnt_fs *fs, int interactive)
{
- char progname[80], *progpath;
+ char *progname, *progpath;
const char *type;
int retval;
else
type = DEFAULT_FSTYPE;
- sprintf(progname, "fsck.%s", type);
+ xasprintf(&progname, "fsck.%s", type);
progpath = find_fsck(progname);
if (progpath == NULL) {
+ free(progname);
if (fs_check_required(type)) {
retval = ENOENT;
goto err;
num_running++;
retval = execute(progname, progpath, type, fs, interactive);
+ free(progname);
+ free(progpath);
if (retval) {
num_running--;
goto err;