Skip to content

Commit 7457bda

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

1 file changed

Lines changed: 11 additions & 27 deletions

File tree

scheduler/cups-driverd.cxx

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

1102-
/*
1103-
* Cull PPD files that are no longer present...
1104-
*/
1105-
1106-
for (ppd = (ppd_info_t *)cupsArrayFirst(PPDsByName);
1107-
ppd;
1108-
ppd = (ppd_info_t *)cupsArrayNext(PPDsByName))
1109-
if (!ppd->found)
1110-
{
1111-
/*
1112-
* Remove this PPD file from the list...
1113-
*/
1114-
1115-
cupsArrayRemove(PPDsByName, ppd);
1116-
cupsArrayRemove(PPDsByMakeModel, ppd);
1117-
free(ppd);
1118-
1119-
ChangedPPD = 1;
1120-
}
1121-
11221102
/*
11231103
* Write the new ppds.dat file...
11241104
*/
@@ -1137,10 +1117,11 @@ list_ppds(int request_id, // I - Request ID
11371117

11381118
cupsFileWrite(fp, (char *)&ppdsync, sizeof(ppdsync));
11391119

1140-
for (ppd = (ppd_info_t *)cupsArrayFirst(PPDsByName);
1141-
ppd;
1142-
ppd = (ppd_info_t *)cupsArrayNext(PPDsByName))
1143-
cupsFileWrite(fp, (char *)&(ppd->record), sizeof(ppd_rec_t));
1120+
for (ppd = (ppd_info_t *)cupsArrayFirst(PPDsByName); ppd; ppd = (ppd_info_t *)cupsArrayNext(PPDsByName))
1121+
{
1122+
if (ppd->found)
1123+
cupsFileWrite(fp, (char *)&(ppd->record), sizeof(ppd_rec_t));
1124+
}
11441125

11451126
cupsFileClose(fp);
11461127

@@ -1309,7 +1290,8 @@ list_ppds(int request_id, // I - Request ID
13091290
*/
13101291

13111292
if (ppd->record.type < PPD_TYPE_POSTSCRIPT ||
1312-
ppd->record.type >= PPD_TYPE_DRV)
1293+
ppd->record.type >= PPD_TYPE_DRV ||
1294+
!ppd->found)
13131295
continue;
13141296

13151297
if (cupsArrayFind(exclude, ppd->record.scheme) ||
@@ -1422,7 +1404,8 @@ list_ppds(int request_id, // I - Request ID
14221404
*/
14231405

14241406
if (ppd->record.type < PPD_TYPE_POSTSCRIPT ||
1425-
ppd->record.type >= PPD_TYPE_DRV)
1407+
ppd->record.type >= PPD_TYPE_DRV ||
1408+
!ppd->found)
14261409
continue;
14271410

14281411
if (cupsArrayFind(exclude, ppd->record.scheme) ||
@@ -1444,7 +1427,8 @@ list_ppds(int request_id, // I - Request ID
14441427
*/
14451428

14461429
if (ppd->record.type < PPD_TYPE_POSTSCRIPT ||
1447-
ppd->record.type >= PPD_TYPE_DRV)
1430+
ppd->record.type >= PPD_TYPE_DRV ||
1431+
!ppd->found)
14481432
continue;
14491433

14501434
/*

0 commit comments

Comments
 (0)