--- ./protocol/hp_ipp.h.orig 2026-09-11 06:22:00.000000000 -0500 +++ ./protocol/hp_ipp.h 2026-09-17 18:29:40.218011531 -0500 @@ -168,6 +168,11 @@ HPIPP_RESULT prepend_http_header(raw_ipp *raw_request,const char *resource); enum HPMUD_RESULT sendUSBRequest(char *buf, int size, raw_ipp *responseptr, char * device_uri); enum HPMUD_RESULT sendUSBFileRequest(char *buf, int size, int fileHandle,raw_ipp *responseptr, char *device_uri); +void _releaseCupsInstance(); +int addCupsPrinter(char *name, char *device_uri, char *location, char *ppd_file, char *model, char *info); +int delCupsPrinter(char *pr_name); +int setDefaultCupsPrinter(char *pr_name); +int controlCupsPrinter(char *pr_name, int op); ipp_t * createFaxDetailRequest(const char *printer_name); ipp_t * getDeviceFaxModemAttributes(char* device_uri,char* printer_name, int *count); --- ./scan/sane/bb_ledm.c.orig 2026-09-11 06:22:00.000000000 -0500 +++ ./scan/sane/bb_ledm.c 2026-09-17 18:29:40.218095280 -0500 @@ -26,6 +26,7 @@ # include "http.h" # include "xml.h" # include +# include # include --- ./scan/sane/sclpml.c.orig 2026-09-11 06:22:00.000000000 -0500 +++ ./scan/sane/sclpml.c 2026-09-17 18:29:40.219479718 -0500 @@ -2117,7 +2117,7 @@ DBG(8, "sane_hpaio_close(): %s %d\n", __FILE__, __LINE__); if (hpaio == NULL || hpaio != session) { - BUG("invalid sane_close\n"); + BUG_SCAN("invalid sane_close\n"); return; } --- ./scan/sane/ledm.c.orig 2026-09-11 06:22:00.000000000 -0500 +++ ./scan/sane/ledm.c 2026-09-17 18:29:40.218617171 -0500 @@ -819,7 +819,7 @@ if (stat != SANE_STATUS_GOOD) { - BUG("control_option failed: option=%s action=%s\n", ps->option[option].name, action==SANE_ACTION_GET_VALUE ? "get" : action==SANE_ACTION_SET_VALUE ? "set" : "auto"); + BUG_SCAN("control_option failed: option=%s action=%s\n", ps->option[option].name, action==SANE_ACTION_GET_VALUE ? "get" : action==SANE_ACTION_SET_VALUE ? "set" : "auto"); } return stat; @@ -1084,7 +1084,7 @@ if (ps == NULL || ps != session) { - BUG("invalid sane_close\n"); + BUG_SCAN("invalid sane_close\n"); return; } --- ./scan/sane/common.h.orig 2026-09-11 06:22:00.000000000 -0500 +++ ./scan/sane/common.h 2026-09-17 18:29:40.218188030 -0500 @@ -36,7 +36,7 @@ #define _STRINGIZE(x) #x #define STRINGIZE(x) _STRINGIZE(x) -#define BUG(args...) {syslog(LOG_ERR, __FILE__ " " STRINGIZE(__LINE__) ": " args); DBG(2, __FILE__ " " STRINGIZE(__LINE__) ": " args);} +#define BUG_SCAN(args...) {syslog(LOG_ERR, __FILE__ " " STRINGIZE(__LINE__) ": " args); DBG(2, __FILE__ " " STRINGIZE(__LINE__) ": " args);} #define BUG_DUMP(data, size) bugdump((data), (size)) #define BUG_SZ(args...) {syslog(LOG_ERR, args); DBG(2, args);} --- ./scan/sane/soap.c.orig 2026-09-11 06:22:00.000000000 -0500 +++ ./scan/sane/soap.c 2026-09-17 18:29:40.219786990 -0500 @@ -142,7 +142,7 @@ if (!ps->ip_handle) { - BUG("invalid ipconvert state\n"); + BUG_SCAN("invalid ipconvert state\n"); goto bugout; } @@ -219,7 +219,7 @@ if ((ps = malloc(sizeof(struct soap_session))) == NULL) { - BUG("malloc failed: %m\n"); + BUG_SCAN("malloc failed: %m\n"); return NULL; } memset(ps, 0, sizeof(struct soap_session)); @@ -418,7 +418,7 @@ if (session) { - BUG("session in use\n"); + BUG_SCAN("session in use\n"); return SANE_STATUS_DEVICE_BUSY; } @@ -434,7 +434,7 @@ if (hpmud_open_device(session->uri, ma.mfp_mode, &session->dd) != HPMUD_R_OK) { - BUG("unable to open device %s\n", session->uri); + BUG_SCAN("unable to open device %s\n", session->uri); goto bugout; free(session); @@ -519,7 +519,7 @@ if (ps == NULL || ps != session) { - BUG("invalid sane_close\n"); + BUG_SCAN("invalid sane_close\n"); return; } @@ -828,7 +828,7 @@ if (stat != SANE_STATUS_GOOD) { - BUG("control_option failed: option=%s action=%s\n", ps->option[option].name, + BUG_SCAN("control_option failed: option=%s action=%s\n", ps->option[option].name, action==SANE_ACTION_GET_VALUE ? "get" : action==SANE_ACTION_SET_VALUE ? "set" : "auto"); } @@ -866,7 +866,7 @@ ps->user_cancel = 0; if (set_extents(ps)) { - BUG("invalid extents: tlx=%d brx=%d tly=%d bry=%d minwidth=%d minheight%d maxwidth=%d maxheight=%d\n", + BUG_SCAN("invalid extents: tlx=%d brx=%d tly=%d bry=%d minwidth=%d minheight%d maxwidth=%d maxheight=%d\n", ps->currentTlx, ps->currentTly, ps->currentBrx, ps->currentBry, ps->min_width, ps->min_height, ps->tlxRange.max, ps->tlyRange.max); stat = SANE_STATUS_INVAL; goto bugout; @@ -917,7 +917,7 @@ /* Open image processor. */ if ((ret = ipOpen(pXform-xforms, xforms, 0, &ps->ip_handle)) != IP_DONE) { - BUG("unable open image processor: err=%d\n", ret); + BUG_SCAN("unable open image processor: err=%d\n", ret); stat = SANE_STATUS_INVAL; goto bugout; } @@ -959,7 +959,7 @@ if (ret & (IP_INPUT_ERROR | IP_FATAL_ERROR | IP_DONE)) { - BUG("ipConvert error=%x\n", ret); + BUG_SCAN("ipConvert error=%x\n", ret); stat = SANE_STATUS_IO_ERROR; goto bugout; } @@ -1011,7 +1011,7 @@ if(ret & (IP_INPUT_ERROR | IP_FATAL_ERROR)) { - BUG("ipConvert error=%x\n", ret); + BUG_SCAN("ipConvert error=%x\n", ret); goto bugout; } --- ./scan/sane/soapht.c.orig 2026-09-11 06:22:00.000000000 -0500 +++ ./scan/sane/soapht.c 2026-09-17 18:29:40.220092876 -0500 @@ -136,7 +136,7 @@ if (!ps->ip_handle) { - BUG("invalid ipconvert state\n"); + BUG_SCAN("invalid ipconvert state\n"); goto bugout; } @@ -435,7 +435,7 @@ if ((ps = malloc(sizeof(struct soap_session))) == NULL) { - BUG("malloc failed: %m\n"); + BUG_SCAN("malloc failed: %m\n"); return NULL; } memset(ps, 0, sizeof(struct soap_session)); @@ -459,7 +459,7 @@ if (session) { - BUG("session in use\n"); + BUG_SCAN("session in use\n"); return SANE_STATUS_DEVICE_BUSY; } @@ -475,7 +475,7 @@ if (hpmud_open_device(session->uri, ma.mfp_mode, &session->dd) != HPMUD_R_OK) { - BUG("unable to open device %s\n", session->uri); + BUG_SCAN("unable to open device %s\n", session->uri); goto bugout; free(session); @@ -554,7 +554,7 @@ if (ps == NULL || ps != session) { - BUG("invalid sane_close\n"); + BUG_SCAN("invalid sane_close\n"); return; } @@ -910,7 +910,7 @@ if (stat != SANE_STATUS_GOOD) { - BUG("control_option failed: option=%s action=%s\n", ps->option[option].name, + BUG_SCAN("control_option failed: option=%s action=%s\n", ps->option[option].name, action==SANE_ACTION_GET_VALUE ? "get" : action==SANE_ACTION_SET_VALUE ? "set" : "auto"); } @@ -952,7 +952,7 @@ if (set_extents(ps)) { - BUG("invalid extents: tlx=%d brx=%d tly=%d bry=%d minwidth=%d minheight%d maxwidth=%d maxheight=%d\n", + BUG_SCAN("invalid extents: tlx=%d brx=%d tly=%d bry=%d minwidth=%d minheight%d maxwidth=%d maxheight=%d\n", ps->currentTlx, ps->currentTly, ps->currentBrx, ps->currentBry, ps->min_width, ps->min_height, ps->tlxRange.max, ps->tlyRange.max); stat = SANE_STATUS_INVAL; goto bugout; @@ -1038,7 +1038,7 @@ /* Open image processor. */ if ((ret = ipOpen(pXform-xforms, xforms, 0, &ps->ip_handle)) != IP_DONE) { - BUG("unable open image processor: err=%d\n", ret); + BUG_SCAN("unable open image processor: err=%d\n", ret); stat = SANE_STATUS_INVAL; goto bugout; } @@ -1081,7 +1081,7 @@ if (ret & (IP_INPUT_ERROR | IP_FATAL_ERROR | IP_DONE)) { - BUG("ipConvert error=%x\n", ret); + BUG_SCAN("ipConvert error=%x\n", ret); stat = SANE_STATUS_IO_ERROR; goto bugout; } @@ -1130,7 +1130,7 @@ if(ret & (IP_INPUT_ERROR | IP_FATAL_ERROR)) { - BUG("ipConvert error=%x\n", ret); + BUG_SCAN("ipConvert error=%x\n", ret); goto bugout; } --- ./scan/sane/http.c.orig 2026-09-11 06:22:00.000000000 -0500 +++ ./scan/sane/http.c 2026-09-17 18:29:40.218465223 -0500 @@ -36,6 +36,7 @@ #include #include #include +#include #include "hpmud.h" #include "http.h" --- ./scan/sane/io.c.orig 2026-09-11 06:22:00.000000000 -0500 +++ ./scan/sane/io.c 2026-09-17 18:29:40.218538766 -0500 @@ -50,7 +50,7 @@ if (dbus_error_is_set(&dbus_err)) { - BUG("dBus Connection Error (%s)!\n", dbus_err.message); + BUG_SCAN("dBus Connection Error (%s)!\n", dbus_err.message); dbus_error_free(&dbus_err); } @@ -79,7 +79,7 @@ if (NULL == msg) { - BUG("dbus message is NULL!\n"); + BUG_SCAN("dbus message is NULL!\n"); return 0; } @@ -94,7 +94,7 @@ if (!dbus_connection_send(dbus_conn, msg, NULL)) { - BUG("dbus message send failed!\n"); + BUG_SCAN("dbus message send failed!\n"); return 0; } --- ./scan/sane/escl.c.orig 2026-09-11 06:22:00.000000000 -0500 +++ ./scan/sane/escl.c 2026-09-17 18:29:40.218277958 -0500 @@ -849,7 +849,7 @@ //DBG8("escl_control_option (option=%s) action=%d\n", ps->option[option].name, action); if (stat != SANE_STATUS_GOOD) { - BUG("control_option failed: option=%s action=%s\n", ps->option[option].name, action==SANE_ACTION_GET_VALUE ? "get" : action==SANE_ACTION_SET_VALUE ? "set" : "auto"); + BUG_SCAN("control_option failed: option=%s action=%s\n", ps->option[option].name, action==SANE_ACTION_GET_VALUE ? "get" : action==SANE_ACTION_SET_VALUE ? "set" : "auto"); } return stat; @@ -1159,7 +1159,7 @@ if (ps == NULL || ps != session) { - BUG("invalid sane_close\n"); + BUG_SCAN("invalid sane_close\n"); return; } --- ./scan/sane/marvell.c.orig 2026-09-11 06:22:00.000000000 -0500 +++ ./scan/sane/marvell.c 2026-09-17 18:29:40.218860240 -0500 @@ -134,7 +134,7 @@ if (!ps->ip_handle) { - BUG("invalid ipconvert state\n"); + BUG_SCAN("invalid ipconvert state\n"); goto bugout; } @@ -335,7 +335,7 @@ if ((ps = malloc(sizeof(struct marvell_session))) == NULL) { - BUG("malloc failed: %m\n"); + BUG_SCAN("malloc failed: %m\n"); return NULL; } memset(ps, 0, sizeof(struct marvell_session)); @@ -402,7 +402,7 @@ if (session) { - BUG("session in use\n"); + BUG_SCAN("session in use\n"); return SANE_STATUS_DEVICE_BUSY; } @@ -431,7 +431,7 @@ if (hpmud_open_device(session->uri, ma.mfp_mode, &session->dd) != HPMUD_R_OK) { - BUG("unable to open device %s\n", session->uri); + BUG_SCAN("unable to open device %s\n", session->uri); goto bugout; free(session); @@ -441,7 +441,7 @@ if (hpmud_open_channel(session->dd, HPMUD_S_MARVELL_SCAN_CHANNEL, &session->cd) != HPMUD_R_OK) { - BUG("unable to open %s channel %s\n", HPMUD_S_MARVELL_SCAN_CHANNEL, session->uri); + BUG_SCAN("unable to open %s channel %s\n", HPMUD_S_MARVELL_SCAN_CHANNEL, session->uri); stat = SANE_STATUS_DEVICE_BUSY; goto bugout; } @@ -554,7 +554,7 @@ if (ps == NULL || ps != session) { - BUG("invalid sane_close\n"); + BUG_SCAN("invalid sane_close\n"); return; } @@ -853,7 +853,7 @@ stat = SANE_STATUS_GOOD; break; } - BUG("value=%d brymin=%d brymax=%d\n", *int_value, ps->bryRange.min, ps->bryRange.max); + BUG_SCAN("value=%d brymin=%d brymax=%d\n", *int_value, ps->bryRange.min, ps->bryRange.max); } else { /* Set default. */ @@ -870,7 +870,7 @@ if (stat != SANE_STATUS_GOOD) { - BUG("control_option failed: option=%s action=%s\n", ps->option[option].name, + BUG_SCAN("control_option failed: option=%s action=%s\n", ps->option[option].name, action==SANE_ACTION_GET_VALUE ? "get" : action==SANE_ACTION_SET_VALUE ? "set" : "auto"); } @@ -909,7 +909,7 @@ if (set_extents(ps)) { - BUG("invalid extents: tlx=%d brx=%d tly=%d bry=%d minwidth=%d minheight%d maxwidth=%d maxheight=%d\n", + BUG_SCAN("invalid extents: tlx=%d brx=%d tly=%d bry=%d minwidth=%d minheight%d maxwidth=%d maxheight=%d\n", ps->currentTlx, ps->currentTly, ps->currentBrx, ps->currentBry, ps->min_width, ps->min_height, ps->tlxRange.max, ps->tlyRange.max); stat = SANE_STATUS_INVAL; goto bugout; @@ -967,7 +967,7 @@ /* Open image processor. */ if ((ret = ipOpen(pXform-xforms, xforms, 0, &ps->ip_handle)) != IP_DONE) { - BUG("unable open image processor: err=%d\n", ret); + BUG_SCAN("unable open image processor: err=%d\n", ret); stat = SANE_STATUS_INVAL; goto bugout; } @@ -1027,7 +1027,7 @@ if(ret & (IP_INPUT_ERROR | IP_FATAL_ERROR)) { - BUG("ipConvert error=%x\n", ret); + BUG_SCAN("ipConvert error=%x\n", ret); goto bugout; } --- ./pcard/fat.c.orig 2026-09-11 06:22:00.000000000 -0500 +++ ./pcard/fat.c 2026-09-17 18:29:40.217124543 -0500 @@ -519,14 +519,17 @@ int FatDiskAttributes( PHOTO_CARD_ATTRIBUTES * pa ) { - strncpy( pa->OEMID, bpb.OEMID, 8 ); + strncpy(pa->OEMID, bpb.OEMID, sizeof(pa->OEMID)); + pa->OEMID[sizeof(pa->OEMID)-1] = '\0'; pa->BytesPerSector = bpb.BytesPerSector; pa->SectorsPerCluster = bpb.SectorsPerCluster; pa->ReservedSectors = bpb.ReservedSectors; pa->SectorsPerFat = bpb.SectorsPerFat; pa->RootEntries = bpb.RootEntries; - strncpy( pa->SystemID, (char *)bpb.SystemID, 8 ); - strncpy( pa->VolumeLabel, (char *)bpb.VolumeLabel, 11 ); + strncpy(pa->SystemID, (char *)bpb.SystemID, sizeof(pa->SystemID)); + pa->SystemID[sizeof(pa->SystemID)-1] = '\0'; + strncpy(pa->VolumeLabel, (char *)bpb.VolumeLabel, sizeof(pa->VolumeLabel)); + pa->VolumeLabel[sizeof(pa->VolumeLabel)-1] = '\0'; pa->WriteProtect = da.WriteProtect; return 0; @@ -741,6 +744,7 @@ return 1; strncpy(cwd.Name, fa.Name, sizeof(cwd.Name)); + cwd.Name[sizeof(cwd.Name)-1] = '\0'; cwd.StartSector = ConvertClusterToSector(fa.StartCluster); cwd.CurrSector = cwd.StartSector; cwd.StartCluster = fa.StartCluster; --- ./Makefile.am.orig 2026-09-11 06:22:00.000000000 -0500 +++ ./Makefile.am 2026-09-17 18:29:40.216917061 -0500 @@ -3,7 +3,7 @@ # # (c) 2004-2015 Copyright HP Development Company, LP # Author: David Suffield, Naga Samrat Chowdary Narla, Sarbeswar Meher -INCLUDES = -Iip -Iio/hpmud -Iscan/sane -Iprnt/hpijs -Icommon/ +INCLUDES = -Iip -Iio/hpmud -Iscan/sane -Iprnt/hpijs -Icommon/ -Iprotocol CFLAGS+= -DCONFDIR=\"$(hplip_confdir)\" CXXFLAGS+= -DCONFDIR=\"$(hplip_confdir)\" @@ -323,7 +323,7 @@ pcardextdir = $(PYTHONEXECDIR) pcardext_LTLIBRARIES = pcardext.la pcardext_la_LDFLAGS = -module -avoid-version -pcardext_la_SOURCES = pcard/pcardext/pcardext.c pcard/fat.c +pcardext_la_SOURCES = pcard/pcardext/pcardext.c pcard/fat.c pcard/pcardext/pcardext.h pcardext_la_CFLAGS = -I$(PYTHONINCLUDEDIR) # prnt @@ -335,7 +335,7 @@ #hpipp_LTLIBRARIES = hpipp.la #hpipp_la_LDFLAGS = -module -avoid-version libhpipp_la_SOURCES = protocol/hp_ipp.c protocol/hp_ipp.h protocol/hp_ipp_i.h -libhpipp_la_CFLAGS = -DCONFDIR=\"$(hplip_confdir)\" +libhpipp_la_CFLAGS = -DCONFDIR=\"$(hplip_confdir)\" -D_GNU_SOURCE libhpipp_la_LDFLAGS = -version-info 0:1:0 libhpipp_la_LIBADD = libhpmud.la --- ./io/hpmud/musb.c.orig 2026-09-11 06:22:00.000000000 -0500 +++ ./io/hpmud/musb.c 2026-09-17 18:29:40.216500754 -0500 @@ -776,7 +776,7 @@ len = size-1; /* leave byte for zero termination */ if (len > 2) len -= 2; - memcpy(buffer, buffer+2, len); /* remove length */ + memmove(buffer, buffer+2, len); /* remove length */ buffer[len]=0; DBG("read actual device_id successfully fd=%d len=%d\n", fd, len); --- ./io/hpmud/jd.c.orig 2026-09-11 06:22:00.000000000 -0500 +++ ./io/hpmud/jd.c 2026-09-17 18:29:40.216105000 -0500 @@ -31,6 +31,7 @@ #endif #include +#include #include "hpmud.h" #include "hpmudi.h" --- ./io/hpmud/model.c.orig 2026-09-11 06:22:00.000000000 -0500 +++ ./io/hpmud/model.c 2026-09-17 18:29:40.216324397 -0500 @@ -117,6 +117,7 @@ if (rcbuf[0] == '[') { strncpy(section, rcbuf, sizeof(section)); /* found new section */ + section[sizeof(section)-1] = '\0'; continue; } @@ -125,6 +126,7 @@ if ((strncasecmp(section, "[dirs]", 6) == 0) && (strcasecmp(key, "home") == 0)) { strncpy(homedir, value, sizeof(homedir)); + homedir[sizeof(homedir)-1] = '\0'; break; /* done */ } } --- ./io/hpmud/hpmud.c.orig 2026-09-11 06:22:00.000000000 -0500 +++ ./io/hpmud/hpmud.c 2026-09-17 18:29:40.215932185 -0500 @@ -770,6 +770,7 @@ } strncpy(ds->uri, msp->device[dd].uri, sizeof(ds->uri)); + ds->uri[sizeof(ds->uri)-1] = '\0'; ds->io_mode = msp->device[dd].io_mode; ds->channel_cnt = msp->device[dd].channel_cnt; ds->mlc_up = msp->device[dd].mlc_up; --- ./io/hpmud/pp.c.orig 2026-09-11 06:22:00.000000000 -0500 +++ ./io/hpmud/pp.c 2026-09-17 18:29:40.216711557 -0500 @@ -632,7 +632,7 @@ len = size-1; /* leave byte for zero termination */ if (len > 2) len -= 2; - memcpy(buffer, buffer+2, len); /* remove length */ + memmove(buffer, buffer+2, len); /* remove length */ buffer[len]=0; DBG("read actual device_id successfully fd=%d len=%d\n", fd, len); --- ./prnt/hpijs/systemservices.cpp.orig 2026-09-11 06:22:15.000000000 -0500 +++ ./prnt/hpijs/systemservices.cpp 2026-09-17 18:29:40.217560613 -0500 @@ -396,7 +396,10 @@ IOMode.bDevID =IM.bDevID && IOMode.bDevID; if (model) + { strncpy(strModel,model, sizeof(strModel)); + strModel[sizeof(strModel)-1] = '\0'; + } } APDK_END_NAMESPACE --- ./prnt/hpijs/context2.cpp.orig 2026-09-11 06:22:00.000000000 -0500 +++ ./prnt/hpijs/context2.cpp 2026-09-17 18:29:40.217362795 -0500 @@ -1302,6 +1302,7 @@ if(0 == strnlen((const char *)pSS->strDevID, DevIDBuffSize)) { strncpy((char *)pSS->strDevID,szDeviceId,DevIDBuffSize); + pSS->strDevID[sizeof(pSS->strDevID)-1] = '\0'; } thePrinter = pPFI->CreatePrinter (pSS, familyHandle); if (thePrinter->constructor_error != NO_ERROR) --- ./common/utils.c.orig 2026-09-11 06:22:00.000000000 -0500 +++ ./common/utils.c 2026-09-17 18:29:40.215778341 -0500 @@ -1,5 +1,9 @@ +#ifndef _GNU_SOURCE +#define _GNU_SOURCE +#endif + #include "utils.h" -#include "string.h" +#include #include #include #include