hplip-strncpy.patch 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. diff -up hplip-3.14.10/prnt/hpcups/HPCupsFilter.cpp.strncpy hplip-3.14.10/prnt/hpcups/HPCupsFilter.cpp
  2. --- hplip-3.14.10/prnt/hpcups/HPCupsFilter.cpp.strncpy 2015-01-21 16:52:44.066497631 +0000
  3. +++ hplip-3.14.10/prnt/hpcups/HPCupsFilter.cpp 2015-01-21 16:59:46.216434376 +0000
  4. @@ -203,6 +203,7 @@ HPCupsFilter::HPCupsFilter() : m_pPrinte
  5. adj_k_width = 0;
  6. black_raster = NULL;
  7. color_raster = NULL;
  8. + memset (&m_JA, 0, sizeof (m_JA));
  9. }
  10. HPCupsFilter::~HPCupsFilter()
  11. @@ -384,9 +385,9 @@ DRIVER_ERROR HPCupsFilter::startPage (cu
  12. m_JA.media_attributes.physical_height = cups_header->PageSize[1];
  13. m_JA.media_attributes.printable_width = ((cups_header->ImagingBoundingBox[2]-cups_header->ImagingBoundingBox[0]) * horz_res) / 72;
  14. m_JA.media_attributes.printable_height = ((cups_header->ImagingBoundingBox[3]-cups_header->ImagingBoundingBox[1]) * vert_res) / 72;
  15. - strncpy(m_JA.media_attributes.PageSizeName, &cups_header->cupsString[0][0], sizeof(m_JA.media_attributes.PageSizeName));
  16. - strncpy(m_JA.media_attributes.MediaTypeName, cups_header->MediaType, sizeof(m_JA.media_attributes.MediaTypeName));
  17. - strncpy(m_JA.quality_attributes.hbpl1_print_quality, cups_header->OutputType, sizeof(m_JA.quality_attributes.hbpl1_print_quality));
  18. + strncpy(m_JA.media_attributes.PageSizeName, &cups_header->cupsString[0][0], sizeof(m_JA.media_attributes.PageSizeName)-1);
  19. + strncpy(m_JA.media_attributes.MediaTypeName, cups_header->MediaType, sizeof(m_JA.media_attributes.MediaTypeName)-1);
  20. + strncpy(m_JA.quality_attributes.hbpl1_print_quality, cups_header->OutputType, sizeof(m_JA.quality_attributes.hbpl1_print_quality)-1);
  21. m_JA.color_mode = cups_header->cupsRowStep;
  22. }
  23. else {
  24. diff -up hplip-3.14.10/prnt/hpijs/hpijs.cpp.strncpy hplip-3.14.10/prnt/hpijs/hpijs.cpp
  25. --- hplip-3.14.10/prnt/hpijs/hpijs.cpp.strncpy 2015-01-21 17:00:03.225512410 +0000
  26. +++ hplip-3.14.10/prnt/hpijs/hpijs.cpp 2015-01-21 17:04:59.308870785 +0000
  27. @@ -605,7 +605,7 @@ int main (int argc, char *argv[], char *
  28. }
  29. if (argc > 2)
  30. - strncpy(user_name, argv[2], sizeof(user_name));
  31. + strncpy(user_name, argv[2], sizeof(user_name) - 1);
  32. #ifdef HAVE_LIBHPIP
  33. char *pDev;
  34. diff -up hplip-3.14.10/prnt/hpijs/hpijsfax.cpp.strncpy hplip-3.14.10/prnt/hpijs/hpijsfax.cpp
  35. --- hplip-3.14.10/prnt/hpijs/hpijsfax.cpp.strncpy 2015-01-21 17:05:06.585904171 +0000
  36. +++ hplip-3.14.10/prnt/hpijs/hpijsfax.cpp 2015-01-21 17:05:15.787946389 +0000
  37. @@ -282,7 +282,7 @@ int hpijsFaxServer (int argc, char **arg
  38. char user_name[32]={0,};
  39. if (argc > 2)
  40. - strncpy(user_name, argv[2], sizeof(user_name));
  41. + strncpy(user_name, argv[2], sizeof(user_name) - 1);
  42. snprintf(hpFileName,sizeof(hpFileName),"%s/hp_%s_ijsfax_Log_XXXXXX",CUPS_TMP_DIR, user_name);