Skip to content

Commit bed9c82

Browse files
committed
Fix potential crash in cups-driverd due to duplicate PPDs (Issue #1355)
1 parent ddb9959 commit bed9c82

2 files changed

Lines changed: 13 additions & 27 deletions

File tree

CHANGES.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ CHANGES - OpenPrinting CUPS
55
Changes in CUPS v2.4.15 (YYYY-MM-DD)
66
------------------------------------
77

8+
- Fixed potential crash in `cups-driverd` when there are duplicate PPDs
9+
(Issue #1355)
810
- Fixed error recovery when scanning for PPDs in `cups-driverd` (Issue #1416)
911

1012

scheduler/cups-driverd.cxx

Lines changed: 11 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1106,26 +1106,6 @@ list_ppds(int request_id, /* I - Request ID */
11061106
load_ppds("/opt/share/ppd", "lsb/opt", 1);
11071107
#endif /* __APPLE__ */
11081108

1109-
/*
1110-
* Cull PPD files that are no longer present...
1111-
*/
1112-
1113-
for (ppd = (ppd_info_t *)cupsArrayFirst(PPDsByName);
1114-
ppd;
1115-
ppd = (ppd_info_t *)cupsArrayNext(PPDsByName))
1116-
if (!ppd->found)
1117-
{
1118-
/*
1119-
* Remove this PPD file from the list...
1120-
*/
1121-
1122-
cupsArrayRemove(PPDsByName, ppd);
1123-
cupsArrayRemove(PPDsByMakeModel, ppd);
1124-
free(ppd);
1125-
1126-
ChangedPPD = 1;
1127-
}
1128-
11291109
/*
11301110
* Write the new ppds.dat file...
11311111
*/
@@ -1144,10 +1124,11 @@ list_ppds(int request_id, /* I - Request ID */
11441124

11451125
cupsFileWrite(fp, (char *)&ppdsync, sizeof(ppdsync));
11461126

1147-
for (ppd = (ppd_info_t *)cupsArrayFirst(PPDsByName);
1148-
ppd;
1149-
ppd = (ppd_info_t *)cupsArrayNext(PPDsByName))
1150-
cupsFileWrite(fp, (char *)&(ppd->record), sizeof(ppd_rec_t));
1127+
for (ppd = (ppd_info_t *)cupsArrayFirst(PPDsByName); ppd; ppd = (ppd_info_t *)cupsArrayNext(PPDsByName))
1128+
{
1129+
if (ppd->found)
1130+
cupsFileWrite(fp, (char *)&(ppd->record), sizeof(ppd_rec_t));
1131+
}
11511132

11521133
cupsFileClose(fp);
11531134

@@ -1316,7 +1297,8 @@ list_ppds(int request_id, /* I - Request ID */
13161297
*/
13171298

13181299
if (ppd->record.type < PPD_TYPE_POSTSCRIPT ||
1319-
ppd->record.type >= PPD_TYPE_DRV)
1300+
ppd->record.type >= PPD_TYPE_DRV ||
1301+
!ppd->found)
13201302
continue;
13211303

13221304
if (cupsArrayFind(exclude, ppd->record.scheme) ||
@@ -1429,7 +1411,8 @@ list_ppds(int request_id, /* I - Request ID */
14291411
*/
14301412

14311413
if (ppd->record.type < PPD_TYPE_POSTSCRIPT ||
1432-
ppd->record.type >= PPD_TYPE_DRV)
1414+
ppd->record.type >= PPD_TYPE_DRV ||
1415+
!ppd->found)
14331416
continue;
14341417

14351418
if (cupsArrayFind(exclude, ppd->record.scheme) ||
@@ -1451,7 +1434,8 @@ list_ppds(int request_id, /* I - Request ID */
14511434
*/
14521435

14531436
if (ppd->record.type < PPD_TYPE_POSTSCRIPT ||
1454-
ppd->record.type >= PPD_TYPE_DRV)
1437+
ppd->record.type >= PPD_TYPE_DRV ||
1438+
!ppd->found)
14551439
continue;
14561440

14571441
/*

0 commit comments

Comments
 (0)