pixma: Use snprint instead of sprintf to avoid buffer overflow.

merge-requests/871/head
Ralph Little 2025-04-25 09:53:08 -07:00
rodzic a9ad50fe56
commit 01a041c02c
2 zmienionych plików z 3 dodań i 3 usunięć

Wyświetl plik

@ -70,7 +70,7 @@
#define PIXMA_STATUS_FAILED 0x1515
#define PIXMA_STATUS_BUSY 0x1414
#define PIXMA_MAX_ID_LEN 30
#define PIXMA_MAX_ID_LEN 40
/* These may have been defined elsewhere */
#ifndef MIN

Wyświetl plik

@ -132,7 +132,7 @@ attach_bjnp (SANE_String_Const devname,
return SANE_STATUS_NO_MEM;
si->cfg = cfg;
sprintf(si->serial, "%s_%s", cfg->model, serial);
snprintf(si->serial, sizeof(si->serial), "%s_%s", cfg->model, serial);
si -> interface = INT_BJNP;
si->next = first_scanner;
first_scanner = si;
@ -188,7 +188,7 @@ u16tohex (uint16_t x, char *str)
static void
read_serial_number (scanner_info_t * si)
{
uint8_t unicode[2 * (PIXMA_MAX_ID_LEN - 9) + 2];
uint8_t unicode[2 * (PIXMA_MAX_ID_LEN - 9) + 2]; // 9 = size of VID + PID + "_"
uint8_t ddesc[18];
int iSerialNumber;
SANE_Int usb;