Closed Bug 1656733 Opened 4 years ago Closed 4 years ago

The Windows code for enumerating printers is not fit for purpose

Categories

(Core :: Printing: Setup, enhancement, P2)

enhancement

Tracking

()

RESOLVED FIXED
81 Branch
Tracking Status
firefox81 --- fixed

People

(Reporter: jwatt, Assigned: jfkthame)

References

(Blocks 1 open bug)

Details

(Whiteboard: [print2020_v81])

Attachments

(1 file)

I don't currently have a working Windows machine, but I can tell just by looking at the Windows code for enumerating the available printers that it is not fit for purpose. It is using GetProfileStringW which is for reading data out of Win.ini, and it limits the total length of the names of all printers contatenated together to 1024 bytes.

We need to change this code to use EnumPrinters(PRINTER_ENUM_LOCAL | PRINTER_ENUM_CONNECTIONS, nullptr, ...)

Assignee: nobody → jfkthame
Status: NEW → ASSIGNED

Looking at nsDeviceContextSpecWin.cpp, I'd be tempted to do some pretty radical rewriting, as the whole thing looks like an exercise in overengineering; but in the interests of limiting the scope here, I decided to just hack up a patch to just fix EnumerateNativePrinters.

In the process, I noticed that the logging in GetDefaultPrinterName is also broken (it passes a 16-bit string to a %s format specifier), and the implementation here can also use a proper Win32 API rather than reading a registry string, so I fixed that at the same time.

Attachment #9168175 - Attachment description: Bug 1656733 - Reimplement EnumerateNativePrinters (and GetDefaultPrinterName) in widget/windows code to use proper Win32 APIs. r=jwatt → Bug 1656733 - Reimplement EnumerateNativePrinters (and GetDefaultPrinterName) in widget/windows code to use proper Win32 APIs. r=bobowen
Pushed by jkew@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/3190fa9aa904 Reimplement EnumerateNativePrinters (and GetDefaultPrinterName) in widget/windows code to use proper Win32 APIs. r=bobowen
Status: ASSIGNED → RESOLVED
Closed: 4 years ago
Resolution: --- → FIXED
Target Milestone: --- → 81 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: