tpl = (strncmp(type, "fsck.", 5) ? "%s/fsck.%s" : "%s/%s");
for(s = strtok(p, ":"); s; s = strtok(NULL, ":")) {
- sprintf(prog, tpl, s, type);
+ if (snprintf(prog, sizeof(prog), tpl, s, type) >= sizeof(prog))
+ continue;
if (stat(prog, &st) == 0) break;
}
free(p);
static int execute(const char *type, const char *device, const char *mntpt,
int interactive)
{
- char *s, *argv[80], prog[80];
+ char *s, *argv[80], prog[256];
int argc, i;
struct fsck_instance *inst, *p;
pid_t pid;
return ENOMEM;
memset(inst, 0, sizeof(struct fsck_instance));
- sprintf(prog, "fsck.%s", type);
+ if (snprintf(prog, sizeof(prog), "fsck.%s", type) >= sizeof(prog))
+ return EINVAL;
argv[0] = string_copy(prog);
argc = 1;