Commit 43e16133 authored by Jonathan Watt's avatar Jonathan Watt
Browse files

Bug 1754308 p1 - Stop sending nsIPrintSettings.toFileName to content processes. r=bobowen

This avoids exposing the path to potentially compromised content processes.

The roundtripping of the toFileName value from RemotePrintJobParent's
mPrintSettings to the content process and then back to
RemotePrintJobParent::InitializePrintDevice was silly anyway.

Differential Revision: https://phabricator.services.mozilla.com/D146867
parent 62e4d2a9
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -20,7 +20,7 @@ both:

parent:
  // Initialize the real print device with the given information.
  async InitializePrint(nsString aDocumentTitle, nsString aPrintToFile,
  async InitializePrint(nsString aDocumentTitle,
                        int32_t aStartPage, int32_t aEndPage);

  // Translate the page recording writen into |fd| and play back the events to
+1 −3
Original line number Diff line number Diff line
@@ -20,13 +20,11 @@ NS_IMPL_ISUPPORTS(RemotePrintJobChild, nsIWebProgressListener)
RemotePrintJobChild::RemotePrintJobChild() = default;

nsresult RemotePrintJobChild::InitializePrint(const nsString& aDocumentTitle,
                                              const nsString& aPrintToFile,
                                              const int32_t& aStartPage,
                                              const int32_t& aEndPage) {
  // Print initialization can sometimes display a dialog in the parent, so we
  // need to spin a nested event loop until initialization completes.
  Unused << SendInitializePrint(aDocumentTitle, aPrintToFile, aStartPage,
                                aEndPage);
  Unused << SendInitializePrint(aDocumentTitle, aStartPage, aEndPage);
  mozilla::SpinEventLoopUntil("RemotePrintJobChild::InitializePrint"_ns,
                              [&]() { return mPrintInitialized; });

+0 −1
Original line number Diff line number Diff line
@@ -29,7 +29,6 @@ class RemotePrintJobChild final : public PRemotePrintJobChild,
  void ActorDestroy(ActorDestroyReason aWhy) final;

  nsresult InitializePrint(const nsString& aDocumentTitle,
                           const nsString& aPrintToFile,
                           const int32_t& aStartPage, const int32_t& aEndPage);

  mozilla::ipc::IPCResult RecvPrintInitializationResult(
+10 −8
Original line number Diff line number Diff line
@@ -31,10 +31,9 @@ RemotePrintJobParent::RemotePrintJobParent(nsIPrintSettings* aPrintSettings)
}

mozilla::ipc::IPCResult RemotePrintJobParent::RecvInitializePrint(
    const nsString& aDocumentTitle, const nsString& aPrintToFile,
    const int32_t& aStartPage, const int32_t& aEndPage) {
  nsresult rv =
      InitializePrintDevice(aDocumentTitle, aPrintToFile, aStartPage, aEndPage);
    const nsString& aDocumentTitle, const int32_t& aStartPage,
    const int32_t& aEndPage) {
  nsresult rv = InitializePrintDevice(aDocumentTitle, aStartPage, aEndPage);
  if (NS_FAILED(rv)) {
    Unused << SendPrintInitializationResult(rv, FileDescriptor());
    // Let any listeners know about the failure before we delete.
@@ -59,8 +58,8 @@ mozilla::ipc::IPCResult RemotePrintJobParent::RecvInitializePrint(
}

nsresult RemotePrintJobParent::InitializePrintDevice(
    const nsString& aDocumentTitle, const nsString& aPrintToFile,
    const int32_t& aStartPage, const int32_t& aEndPage) {
    const nsString& aDocumentTitle, const int32_t& aStartPage,
    const int32_t& aEndPage) {
  nsresult rv;
  nsCOMPtr<nsIDeviceContextSpec> deviceContextSpec =
      do_CreateInstance("@mozilla.org/gfx/devicecontextspec;1", &rv);
@@ -79,8 +78,11 @@ nsresult RemotePrintJobParent::InitializePrintDevice(
    return rv;
  }

  rv = mPrintDeviceContext->BeginDocument(aDocumentTitle, aPrintToFile,
                                          aStartPage, aEndPage);
  nsAutoString fileName;
  mPrintSettings->GetToFileName(fileName);

  rv = mPrintDeviceContext->BeginDocument(aDocumentTitle, fileName, aStartPage,
                                          aEndPage);
  if (NS_FAILED(rv)) {
    NS_WARNING_ASSERTION(rv == NS_ERROR_ABORT,
                         "Failed to initialize print device");
+0 −2
Original line number Diff line number Diff line
@@ -35,7 +35,6 @@ class RemotePrintJobParent final : public PRemotePrintJobParent {
  void ActorDestroy(ActorDestroyReason aWhy) final;

  mozilla::ipc::IPCResult RecvInitializePrint(const nsString& aDocumentTitle,
                                              const nsString& aPrintToFile,
                                              const int32_t& aStartPage,
                                              const int32_t& aEndPage) final;

@@ -70,7 +69,6 @@ class RemotePrintJobParent final : public PRemotePrintJobParent {
  ~RemotePrintJobParent() final;

  nsresult InitializePrintDevice(const nsString& aDocumentTitle,
                                 const nsString& aPrintToFile,
                                 const int32_t& aStartPage,
                                 const int32_t& aEndPage);

Loading