Unverified Commit eec72fd9 authored by Sandro Jäckel's avatar Sandro Jäckel Committed by GitHub
Browse files

Merge pull request #325178 from alois31/hplip

parents 711e627c 57428640
Loading
Loading
Loading
Loading
+9 −10
Original line number Diff line number Diff line
{ lib, stdenv, fetchurl, substituteAll
, pkg-config, autoreconfHook
, pkg-config, autoreconfHook, gobject-introspection, wrapGAppsHook3
, cups, zlib, libjpeg, libusb1, python311Packages, sane-backends
, dbus, file, ghostscript, usbutils
, net-snmp, openssl, perl, nettools, avahi
@@ -14,16 +14,16 @@
let

  pname = "hplip";
  version = "3.23.8";
  version = "3.24.4";

  src = fetchurl {
    url = "mirror://sourceforge/hplip/${pname}-${version}.tar.gz";
    hash = "sha256-98wF9ijAz9dQ5UrkFDHB390p6XaC8YtcW6XLLFtLG0Y=";
    hash = "sha256-XXZDgxiTpeKt351C1YGl2/5arwI2Johrh2LFZF2g8fs=";
  };

  plugin = fetchurl {
    url = "https://developers.hp.com/sites/default/files/${pname}-${version}-plugin.run";
    hash = "sha256-frsgye3f0M3HE2trKRlfFvMnDEwe+z74IumCdVPrcSY=";
    hash = "sha256-Hzxr3SVmGoouGBU2VdbwbwKMHZwwjWnI7P13Z6LQxao=";
  };

  hplipState = substituteAll {
@@ -74,6 +74,8 @@ python311Packages.buildPythonApplication {
    pkg-config
    removeReferencesTo
    autoreconfHook
    gobject-introspection
    wrapGAppsHook3
  ] ++ lib.optional withQt5 qt5.wrapQtAppsHook;

  pythonPath = with python311Packages; [
@@ -82,7 +84,6 @@ python311Packages.buildPythonApplication {
    pygobject3
    reportlab
    usbutils
    sip4
    dbus-python
    distro
  ] ++ lib.optionals withQt5 [
@@ -105,9 +106,6 @@ python311Packages.buildPythonApplication {
      url = "https://web.archive.org/web/20230226174550/https://sources.debian.org/data/main/h/hplip/3.22.10+dfsg0-1/debian/patches/0028-Remove-ImageProcessor-binary-installs.patch";
      sha256 = "sha256:18njrq5wrf3fi4lnpd1jqmaqr7ph5d7jxm7f15b1wwrbxir1rmml";
    })

    # Revert changes that break compilation under -Werror=format-security
    ./revert-snprintf-change.patch
  ];

  postPatch = ''
@@ -239,7 +237,8 @@ python311Packages.buildPythonApplication {
  # 1. Calling patchPythonProgram on the original script in $out/share/hplip
  # 2. Making our own wrapper pointing directly to the original script.
  dontWrapPythonPrograms = true;
  # We also avoid double wrapping in case we add qt5 support
  # We also avoid double (or triple in case qt5 support is added) wrapping
  dontWrapGApps = true;
  dontWrapQtApps = true;
  preFixup = ''
    buildPythonPath "$out $pythonPath"
@@ -253,7 +252,7 @@ python311Packages.buildPythonApplication {
      ${if withQt5 then "makeQtWrapper" else "makeWrapper"} "$py" "$bin" \
          --prefix PATH ':' "$program_PATH" \
          --set PYTHONNOUSERSITE "true" \
          $makeWrapperArgs
          $makeWrapperArgs "''${gappsWrapperArgs[@]}"
    done
  '';

+0 −61
Original line number Diff line number Diff line
commit f103a260215016fc035bc1399c8accabf83b0264
Author: Claudio Bley <claudio.bley@gmail.com>
Date:   Fri Jul 1 22:29:05 2022 +0200

    Revert change to hp_ipp.c from 3.22.{4 -> 6}
    
    This fails compilation:
    ```
    protocol/hp_ipp.c: In function ‘addCupsPrinter’:
    protocol/hp_ipp.c:113:9: error: format not a string literal and no format arguments [-Werror=format-security]
      113 |         snprintf( info,sizeof(info), name );
          |         ^~~~~~~~
    ```

diff --git a/protocol/hp_ipp.c b/protocol/hp_ipp.c
index 97d827d..af7013b 100644
--- a/protocol/hp_ipp.c
+++ b/protocol/hp_ipp.c
@@ -110,7 +110,7 @@ int addCupsPrinter(char *name, char *device_uri, char *location, char *ppd_file,
      }
 
      if ( info == NULL )
-        snprintf( info,sizeof(info), name );
+        strcpy( info, name );
 
      sprintf( printer_uri, "ipp://localhost/printers/%s", name );
 
@@ -511,27 +511,27 @@ int __parsePrinterAttributes(ipp_t *response, printer_t **printer_list)
 
              if ( strcmp(attr_name, "printer-name") == 0 &&
                                         val_tag == IPP_TAG_NAME ) {
-                  snprintf(t_printer->name, sizeof(t_printer->name),ippGetString(attr, 0, NULL) );
+                  strcpy(t_printer->name, ippGetString(attr, 0, NULL) );
              }
              else if ( strcmp(attr_name, "device-uri") == 0 &&
                                          val_tag == IPP_TAG_URI ) {
-                  snprintf(t_printer->device_uri,sizeof(t_printer->device_uri), ippGetString(attr, 0, NULL) );
+                  strcpy(t_printer->device_uri, ippGetString(attr, 0, NULL) );
              }
              else if ( strcmp(attr_name, "printer-uri-supported") == 0 &&
                                                  val_tag == IPP_TAG_URI ) {
-                  snprintf(t_printer->printer_uri,sizeof(t_printer->printer_uri), ippGetString(attr, 0, NULL) );
+                  strcpy(t_printer->printer_uri, ippGetString(attr, 0, NULL) );
              }
              else if ( strcmp(attr_name, "printer-info") == 0 &&
                                         val_tag == IPP_TAG_TEXT ) {
-                  snprintf(t_printer->info,sizeof(t_printer->info), ippGetString(attr, 0, NULL) );
+                  strcpy(t_printer->info, ippGetString(attr, 0, NULL) );
              }
              else if ( strcmp(attr_name, "printer-location") == 0 &&
                                            val_tag == IPP_TAG_TEXT ) {
-                  snprintf(t_printer->location,sizeof(t_printer->location),ippGetString(attr, 0, NULL) );
+                  strcpy(t_printer->location, ippGetString(attr, 0, NULL) );
              }
              else if ( strcmp(attr_name, "printer-make-and-model") == 0 &&
                                                   val_tag == IPP_TAG_TEXT ) {
-                  snprintf(t_printer->make_model,sizeof(t_printer->make_model),ippGetString(attr, 0, NULL) );
+                  strcpy(t_printer->make_model, ippGetString(attr, 0, NULL) );
              } 
              else if ( strcmp(attr_name, "printer-state") == 0 &&
                                              val_tag == IPP_TAG_ENUM ) {