summaryrefslogtreecommitdiffstats
path: root/source/ap/hplip/hplip-covscan.patch
blob: 6c885816593263e9de1f35a68c966aa331c59124 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
diff -up hplip-3.23.3/common/utils.c.covscan hplip-3.23.3/common/utils.c
--- hplip-3.23.3/common/utils.c.covscan	2023-03-28 09:26:11.000000000 +0200
+++ hplip-3.23.3/common/utils.c	2023-05-29 13:58:10.969395214 +0200
@@ -1,5 +1,9 @@
+#ifndef _GNU_SOURCE
+#define _GNU_SOURCE
+#endif
+
 #include "utils.h"
-#include "string.h"
+#include <string.h>
 #include <dlfcn.h>
 #include <sys/stat.h>
 #include <errno.h>
diff -up hplip-3.23.3/io/hpmud/hpmud.c.covscan hplip-3.23.3/io/hpmud/hpmud.c
--- hplip-3.23.3/io/hpmud/hpmud.c.covscan	2023-03-28 09:26:11.000000000 +0200
+++ hplip-3.23.3/io/hpmud/hpmud.c	2023-05-29 13:58:10.970395208 +0200
@@ -759,6 +759,7 @@ enum HPMUD_RESULT hpmud_get_dstat(HPMUD_
    }
 
    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;
diff -up hplip-3.23.3/io/hpmud/jd.c.covscan hplip-3.23.3/io/hpmud/jd.c
--- hplip-3.23.3/io/hpmud/jd.c.covscan	2023-03-28 09:26:11.000000000 +0200
+++ hplip-3.23.3/io/hpmud/jd.c	2023-05-29 13:58:10.970395208 +0200
@@ -31,6 +31,7 @@
 #endif
 
 #include <signal.h>
+#include <stdlib.h>
 #include "hpmud.h"
 #include "hpmudi.h"
 
diff -up hplip-3.23.3/io/hpmud/model.c.covscan hplip-3.23.3/io/hpmud/model.c
--- hplip-3.23.3/io/hpmud/model.c.covscan	2023-05-29 13:58:10.958395279 +0200
+++ hplip-3.23.3/io/hpmud/model.c	2023-05-29 13:58:10.970395208 +0200
@@ -117,6 +117,7 @@ static int ReadConfig()
       if (rcbuf[0] == '[')
       {
          strncpy(section, rcbuf, sizeof(section)); /* found new section */
+         section[sizeof(section)-1] = '\0';
          continue;
       }
 
@@ -125,6 +126,7 @@ static int ReadConfig()
       if ((strncasecmp(section, "[dirs]", 6) == 0) && (strcasecmp(key, "home") == 0))
       {
          strncpy(homedir, value, sizeof(homedir));
+         homedir[sizeof(homedir)-1] = '\0';
          break;  /* done */
       }
    }
diff -up hplip-3.23.3/io/hpmud/musb.c.covscan hplip-3.23.3/io/hpmud/musb.c
--- hplip-3.23.3/io/hpmud/musb.c.covscan	2023-03-28 09:26:11.000000000 +0200
+++ hplip-3.23.3/io/hpmud/musb.c	2023-05-29 13:58:10.970395208 +0200
@@ -776,7 +776,7 @@ static int device_id(int fd, unsigned ch
         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);
 
diff -up hplip-3.23.3/io/hpmud/pp.c.covscan hplip-3.23.3/io/hpmud/pp.c
--- hplip-3.23.3/io/hpmud/pp.c.covscan	2023-03-28 09:26:11.000000000 +0200
+++ hplip-3.23.3/io/hpmud/pp.c	2023-05-29 13:58:10.970395208 +0200
@@ -632,7 +632,7 @@ static int device_id(int fd, char *buffe
       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);
diff -up hplip-3.23.3/Makefile.am.covscan hplip-3.23.3/Makefile.am
--- hplip-3.23.3/Makefile.am.covscan	2023-05-29 13:58:10.944395361 +0200
+++ hplip-3.23.3/Makefile.am	2023-05-29 13:58:10.969395214 +0200
@@ -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)\"
 
@@ -310,7 +310,7 @@ dist_pcard_DATA = pcard/__init__.py pcar
 pcardextdir = $(pyexecdir)
 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
@@ -322,7 +322,7 @@ lib_LTLIBRARIES += libhpipp.la
 #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
 
diff -up hplip-3.23.3/pcard/fat.c.covscan hplip-3.23.3/pcard/fat.c
--- hplip-3.23.3/pcard/fat.c.covscan	2023-03-28 09:26:11.000000000 +0200
+++ hplip-3.23.3/pcard/fat.c	2023-05-29 13:58:10.971395203 +0200
@@ -519,14 +519,17 @@ int FatFreeSpace(void)
 
 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 @@ int FatSetCWD(char *dir)
       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;
diff -up hplip-3.23.3/prnt/hpijs/context2.cpp.covscan hplip-3.23.3/prnt/hpijs/context2.cpp
--- hplip-3.23.3/prnt/hpijs/context2.cpp.covscan	2023-03-28 09:26:11.000000000 +0200
+++ hplip-3.23.3/prnt/hpijs/context2.cpp	2023-05-29 13:58:10.971395203 +0200
@@ -1302,6 +1302,7 @@ DRIVER_ERROR PrintContext::SelectDevice
 	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)
diff -up hplip-3.23.3/prnt/hpijs/systemservices.cpp.covscan hplip-3.23.3/prnt/hpijs/systemservices.cpp
--- hplip-3.23.3/prnt/hpijs/systemservices.cpp.covscan	2023-03-28 09:26:27.000000000 +0200
+++ hplip-3.23.3/prnt/hpijs/systemservices.cpp	2023-05-29 13:58:10.971395203 +0200
@@ -396,7 +396,10 @@ void SystemServices::AdjustIO(IO_MODE IM
     IOMode.bDevID =IM.bDevID  && IOMode.bDevID;
 
     if (model)
+    {
         strncpy(strModel,model, sizeof(strModel));
+        strModel[sizeof(strModel)-1] = '\0';
+    }
 }
 
 APDK_END_NAMESPACE
diff -up hplip-3.23.3/prnt/hpps/hppsfilter.c.covscan hplip-3.23.3/prnt/hpps/hppsfilter.c
--- hplip-3.23.3/prnt/hpps/hppsfilter.c.covscan	2023-03-28 09:26:11.000000000 +0200
+++ hplip-3.23.3/prnt/hpps/hppsfilter.c	2023-05-29 13:58:10.972395197 +0200
@@ -274,13 +274,13 @@ static void WriteHeader(char **argument)
     /*		Writing Header Information
     argument[1] = JOB ID , argument[2]= USERNAME,  argument[3] = TITLE		*/
     hpwrite("\x1b%-12345X@PJL JOBNAME=", strlen("\x1b%-12345X@PJL JOBNAME="));
-    sprintf(buffer, "hplip_%s_%s\x0a", argument[2], argument[1]);
+    snprintf(buffer, MAX_BUFFER-1, "hplip_%s_%s\x0a", argument[2], argument[1]);
     hpwrite(buffer, strlen(buffer));
     memset(buffer, 0, sizeof(buffer));
-    sprintf(buffer, "@PJL SET USERNAME=\"%s\"\x0a", argument[2]);
+    snprintf(buffer, MAX_BUFFER-1, "@PJL SET USERNAME=\"%s\"\x0a", argument[2]);
     hpwrite(buffer, strlen(buffer));
     memset(buffer, 0, sizeof(buffer));
-    sprintf(buffer, "@PJL SET JOBNAME=\"%s\"\x0a", argument[3]);
+    snprintf(buffer, MAX_BUFFER-1, "@PJL SET JOBNAME=\"%s\"\x0a", argument[3]);
     hpwrite(buffer, strlen(buffer));
     fprintf(stderr, "HP PS filter func = WriteHeader           : WRITING PJL HEADER INFO\n");
     return;
diff -up hplip-3.23.3/protocol/hp_ipp.h.covscan hplip-3.23.3/protocol/hp_ipp.h
--- hplip-3.23.3/protocol/hp_ipp.h.covscan	2023-05-29 13:58:10.972395197 +0200
+++ hplip-3.23.3/protocol/hp_ipp.h	2023-05-29 13:59:03.645085468 +0200
@@ -168,6 +168,11 @@ HPIPP_RESULT parseResponseHeader(char* h
 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);
diff -up hplip-3.23.3/scan/sane/bb_ledm.c.covscan hplip-3.23.3/scan/sane/bb_ledm.c
--- hplip-3.23.3/scan/sane/bb_ledm.c.covscan	2023-03-28 09:26:11.000000000 +0200
+++ hplip-3.23.3/scan/sane/bb_ledm.c	2023-05-29 13:58:10.972395197 +0200
@@ -26,6 +26,7 @@
 # include "http.h"
 # include "xml.h"
 # include <stdlib.h>
+# include <unistd.h>
 
 # include <stdint.h>
 
diff -up hplip-3.23.3/scan/sane/common.h.covscan hplip-3.23.3/scan/sane/common.h
--- hplip-3.23.3/scan/sane/common.h.covscan	2023-05-29 13:58:10.727396637 +0200
+++ hplip-3.23.3/scan/sane/common.h	2023-05-29 13:58:10.972395197 +0200
@@ -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);}
 
diff -up hplip-3.23.3/scan/sane/escl.c.covscan hplip-3.23.3/scan/sane/escl.c
--- hplip-3.23.3/scan/sane/escl.c.covscan	2023-03-28 09:26:11.000000000 +0200
+++ hplip-3.23.3/scan/sane/escl.c	2023-05-29 13:58:10.972395197 +0200
@@ -849,7 +849,7 @@ SANE_Status escl_control_option(SANE_Han
   //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 @@ void escl_close(SANE_Handle handle)
 
   if (ps == NULL || ps != session)
   {
-    BUG("invalid sane_close\n");
+    BUG_SCAN("invalid sane_close\n");
     return;
   }
 
diff -up hplip-3.23.3/scan/sane/http.c.covscan hplip-3.23.3/scan/sane/http.c
--- hplip-3.23.3/scan/sane/http.c.covscan	2023-03-28 09:26:11.000000000 +0200
+++ hplip-3.23.3/scan/sane/http.c	2023-05-29 13:58:10.973395191 +0200
@@ -36,6 +36,7 @@
 #include <string.h>
 #include <syslog.h>
 #include <ctype.h>
+#include <unistd.h>
 #include "hpmud.h"
 #include "http.h"
 
diff -up hplip-3.23.3/scan/sane/io.c.covscan hplip-3.23.3/scan/sane/io.c
--- hplip-3.23.3/scan/sane/io.c.covscan	2023-03-28 09:26:11.000000000 +0200
+++ hplip-3.23.3/scan/sane/io.c	2023-05-29 13:58:10.973395191 +0200
@@ -50,7 +50,7 @@ int __attribute__ ((visibility ("hidden"
     
    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 @@ int __attribute__ ((visibility ("hidden"
 
     if (NULL == msg)
     {
-        BUG("dbus message is NULL!\n");
+        BUG_SCAN("dbus message is NULL!\n");
         return 0;
     }
 
@@ -94,7 +94,7 @@ int __attribute__ ((visibility ("hidden"
 
     if (!dbus_connection_send(dbus_conn, msg, NULL))
     {
-        BUG("dbus message send failed!\n");
+        BUG_SCAN("dbus message send failed!\n");
         return 0;
     }
 
diff -up hplip-3.23.3/scan/sane/ledm.c.covscan hplip-3.23.3/scan/sane/ledm.c
--- hplip-3.23.3/scan/sane/ledm.c.covscan	2023-03-28 09:26:11.000000000 +0200
+++ hplip-3.23.3/scan/sane/ledm.c	2023-05-29 13:58:10.973395191 +0200
@@ -813,7 +813,7 @@ SANE_Status ledm_control_option(SANE_Han
 
   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;
@@ -1078,7 +1078,7 @@ void ledm_close(SANE_Handle handle)
 
   if (ps == NULL || ps != session)
   {
-    BUG("invalid sane_close\n");
+    BUG_SCAN("invalid sane_close\n");
     return;
   }
 
diff -up hplip-3.23.3/scan/sane/marvell.c.covscan hplip-3.23.3/scan/sane/marvell.c
--- hplip-3.23.3/scan/sane/marvell.c.covscan	2023-03-28 09:26:11.000000000 +0200
+++ hplip-3.23.3/scan/sane/marvell.c	2023-05-29 13:58:10.976395173 +0200
@@ -134,7 +134,7 @@ static int get_ip_data(struct marvell_se
 
    if (!ps->ip_handle)
    {
-      BUG("invalid ipconvert state\n");
+      BUG_SCAN("invalid ipconvert state\n");
       goto bugout;
    }
    
@@ -335,7 +335,7 @@ static struct marvell_session *create_se
 
    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 @@ SANE_Status marvell_open(SANE_String_Con
 
    if (session)
    {
-      BUG("session in use\n");
+      BUG_SCAN("session in use\n");
       return SANE_STATUS_DEVICE_BUSY;
    }
       
@@ -431,7 +431,7 @@ SANE_Status marvell_open(SANE_String_Con
 
    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 @@ SANE_Status marvell_open(SANE_String_Con
 
    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 @@ void marvell_close(SANE_Handle handle)
 
    if (ps == NULL || ps != session)
    {
-      BUG("invalid sane_close\n");
+      BUG_SCAN("invalid sane_close\n");
       return;
    }
 
@@ -849,7 +849,7 @@ SANE_Status marvell_control_option(SANE_
                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. */
@@ -866,7 +866,7 @@ SANE_Status marvell_control_option(SANE_
 
    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");
    }
 
@@ -905,7 +905,7 @@ SANE_Status marvell_start(SANE_Handle ha
    
    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;
@@ -963,7 +963,7 @@ SANE_Status marvell_start(SANE_Handle ha
    /* 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;
    }
@@ -1023,7 +1023,7 @@ SANE_Status marvell_read(SANE_Handle han
 
    if(ret & (IP_INPUT_ERROR | IP_FATAL_ERROR))
    {
-      BUG("ipConvert error=%x\n", ret);
+      BUG_SCAN("ipConvert error=%x\n", ret);
       goto bugout;
    }
 
diff -up hplip-3.23.3/scan/sane/sclpml.c.covscan hplip-3.23.3/scan/sane/sclpml.c
--- hplip-3.23.3/scan/sane/sclpml.c.covscan	2023-03-28 09:26:11.000000000 +0200
+++ hplip-3.23.3/scan/sane/sclpml.c	2023-05-29 13:58:10.976395173 +0200
@@ -30,6 +30,7 @@
 #include <unistd.h>
 #include <fcntl.h>
 #include <string.h>
+#include <sys/time.h>
 #include "sane.h"
 #include "saneopts.h"
 #include "common.h"
@@ -2090,7 +2091,7 @@ void sclpml_close(SANE_Handle handle)
     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;
      }
 
diff -up hplip-3.23.3/scan/sane/soap.c.covscan hplip-3.23.3/scan/sane/soap.c
--- hplip-3.23.3/scan/sane/soap.c.covscan	2023-03-28 09:26:11.000000000 +0200
+++ hplip-3.23.3/scan/sane/soap.c	2023-05-29 13:58:10.977395167 +0200
@@ -142,7 +142,7 @@ static int get_ip_data(struct soap_sessi
 
    if (!ps->ip_handle)
    {
-      BUG("invalid ipconvert state\n");
+      BUG_SCAN("invalid ipconvert state\n");
       goto bugout;
    }      
 
@@ -219,7 +219,7 @@ static struct soap_session *create_sessi
 
    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 @@ SANE_Status soap_open(SANE_String_Const
 
    if (session)
    {
-      BUG("session in use\n");
+      BUG_SCAN("session in use\n");
       return SANE_STATUS_DEVICE_BUSY;
    }
 
@@ -434,7 +434,7 @@ SANE_Status soap_open(SANE_String_Const
 
    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 @@ void soap_close(SANE_Handle handle)
 
    if (ps == NULL || ps != session)
    {
-      BUG("invalid sane_close\n");
+      BUG_SCAN("invalid sane_close\n");
       return;
    }
 
@@ -824,7 +824,7 @@ SANE_Status soap_control_option(SANE_Han
 
    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");
    }
 
@@ -862,7 +862,7 @@ SANE_Status soap_start(SANE_Handle handl
    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;
@@ -913,7 +913,7 @@ SANE_Status soap_start(SANE_Handle handl
    /* 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;
    }
@@ -955,7 +955,7 @@ SANE_Status soap_start(SANE_Handle handl
 
          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;
          }
@@ -1007,7 +1007,7 @@ SANE_Status soap_read(SANE_Handle handle
 
    if(ret & (IP_INPUT_ERROR | IP_FATAL_ERROR))
    {
-      BUG("ipConvert error=%x\n", ret);
+      BUG_SCAN("ipConvert error=%x\n", ret);
       goto bugout;
    }
 
diff -up hplip-3.23.3/scan/sane/soapht.c.covscan hplip-3.23.3/scan/sane/soapht.c
--- hplip-3.23.3/scan/sane/soapht.c.covscan	2023-03-28 09:26:11.000000000 +0200
+++ hplip-3.23.3/scan/sane/soapht.c	2023-05-29 13:58:10.977395167 +0200
@@ -136,7 +136,7 @@ static int get_ip_data(struct soap_sessi
 
    if (!ps->ip_handle)
    {
-      BUG("invalid ipconvert state\n");
+      BUG_SCAN("invalid ipconvert state\n");
       goto bugout;
    }      
 
@@ -435,7 +435,7 @@ static struct soap_session *create_sessi
 
    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 @@ SANE_Status soapht_open(SANE_String_Cons
 
    if (session)
    {
-      BUG("session in use\n");
+      BUG_SCAN("session in use\n");
       return SANE_STATUS_DEVICE_BUSY;
    }
 
@@ -475,7 +475,7 @@ SANE_Status soapht_open(SANE_String_Cons
 
    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 @@ void soapht_close(SANE_Handle handle)
 
    if (ps == NULL || ps != session)
    {
-      BUG("invalid sane_close\n");
+      BUG_SCAN("invalid sane_close\n");
       return;
    }
 
@@ -904,7 +904,7 @@ SANE_Status soapht_control_option(SANE_H
 
    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");
    }
 
@@ -946,7 +946,7 @@ SANE_Status soapht_start(SANE_Handle han
   
    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;
@@ -1032,7 +1032,7 @@ SANE_Status soapht_start(SANE_Handle han
    /* 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;
    }
@@ -1075,7 +1075,7 @@ SANE_Status soapht_start(SANE_Handle han
 
          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;
          }
@@ -1124,7 +1124,7 @@ SANE_Status soapht_read(SANE_Handle hand
 
    if(ret & (IP_INPUT_ERROR | IP_FATAL_ERROR))
    {
-      BUG("ipConvert error=%x\n", ret);
+      BUG_SCAN("ipConvert error=%x\n", ret);
       goto bugout;
    }