replace sprintf call with snprintf for open image command

This commit is contained in:
antma 2014-01-10 16:15:59 +04:00
parent 35f981d519
commit 20d8954732

View File

@ -1764,12 +1764,15 @@ void end_load (struct download *D) {
if (D->next == 1) { if (D->next == 1) {
logprintf ("Done: %s\n", D->name); logprintf ("Done: %s\n", D->name);
} else if (D->next == 2) { } else if (D->next == 2) {
static char buf[1000]; static char buf[PATH_MAX];
sprintf (buf, OPEN_BIN, D->name); if (snprintf (buf, sizeof (buf), OPEN_BIN, D->name) >= (int) sizeof (buf)) {
int x = system (buf); logprintf ("Open image command buffer overflow\n");
if (x < 0) { } else {
logprintf ("Can not open image viewer: %m\n"); int x = system (buf);
logprintf ("Image is at %s\n", D->name); if (x < 0) {
logprintf ("Can not open image viewer: %m\n");
logprintf ("Image is at %s\n", D->name);
}
} }
} }
if (D->iv) { if (D->iv) {