segfault-avahi-fix-kodakio.patch 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. From 37523b867d411c2f82d08128246be7e38bc9812c Mon Sep 17 00:00:00 2001
  2. From: Paul Newall <quandry@ntlworld.com>
  3. Date: Mon, 14 Oct 2013 22:22:53 +0100
  4. Subject: [PATCH] Bugfix in kodakaio.c to fix segfault when non kodak scanners
  5. return unexpected data via avahi auto discovery
  6. ---
  7. backend/kodakaio.c | 43 ++++++++++++++++++++++++++++++----------
  8. doc/descriptions/kodakaio.desc | 2 +-
  9. 3 files changed, 37 insertions(+), 12 deletions(-)
  10. diff --git a/backend/kodakaio.c b/backend/kodakaio.c
  11. index 8c4583a..b442e50 100644
  12. --- a/backend/kodakaio.c
  13. +++ b/backend/kodakaio.c
  14. @@ -127,7 +127,7 @@ for ubuntu 12.10
  15. #define KODAKAIO_VERSION 02
  16. #define KODAKAIO_REVISION 4
  17. -#define KODAKAIO_BUILD 6
  18. +#define KODAKAIO_BUILD 7
  19. /* for usb (but also used for net though it's not required). */
  20. #define MAX_BLOCK_SIZE 32768
  21. @@ -2184,6 +2184,7 @@ static void resolve_callback(
  22. AvahiLookupResultFlags flags,
  23. AVAHI_GCC_UNUSED void* userdata) {
  24. + AvahiStringList *vid_pair_list = NULL, *pid_pair_list = NULL;
  25. char *pidkey, *pidvalue;
  26. char *vidkey, *vidvalue;
  27. size_t valuesize;
  28. @@ -2204,20 +2205,40 @@ static void resolve_callback(
  29. avahi_address_snprint(a, sizeof(a), address);
  30. /* Output short for Kodak ESP */
  31. - DBG(min(10,DBG_AUTO), "%s:%u %s ", a,port,host_name);
  32. - avahi_string_list_get_pair(avahi_string_list_find(txt, "vid"),
  33. - &vidkey, &vidvalue, &valuesize);
  34. - DBG(min(10,DBG_AUTO), "%s=%s ", vidkey, vidvalue);
  35. - avahi_string_list_get_pair(avahi_string_list_find(txt, "pid"),
  36. - &pidkey, &pidvalue, &valuesize);
  37. - DBG(min(10,DBG_AUTO), "%s=%s\n", pidkey, pidvalue);
  38. + DBG(min(10,DBG_AUTO), "%s:%u %s\n", a,port,host_name);
  39. + vid_pair_list = avahi_string_list_find(txt, "vid");
  40. + if(vid_pair_list != NULL) {
  41. + avahi_string_list_get_pair(vid_pair_list, &vidkey, &vidvalue, &valuesize);
  42. + DBG(min(10,DBG_AUTO), "%s=%s ", vidkey, vidvalue);
  43. + }
  44. + else DBG(min(10,DBG_AUTO), "failed to find key vid\n");
  45. +
  46. + pid_pair_list = avahi_string_list_find(txt, "pid");
  47. + if(pid_pair_list != NULL) {
  48. + avahi_string_list_get_pair(pid_pair_list, &pidkey, &pidvalue, &valuesize);
  49. + DBG(min(10,DBG_AUTO), "%s=%s\n", pidkey, pidvalue);
  50. + }
  51. + else DBG(min(10,DBG_AUTO), "failed to find key pid\n");
  52. +
  53. + if(pid_pair_list != NULL && vid_pair_list != NULL) {
  54. ProcessAvahiDevice(name, vidvalue, pidvalue, a);
  55. - avahi_free(vidkey); avahi_free(vidvalue);
  56. - avahi_free(pidkey); avahi_free(pidvalue);
  57. + }
  58. + else DBG(min(10,DBG_AUTO), "didn't call ProcessAvahiDevice\n");
  59. +
  60. + if(vid_pair_list != NULL) {
  61. + avahi_free(vidkey);
  62. + avahi_free(vidvalue);
  63. + DBG(min(15,DBG_AUTO), "vidkey and vidvalue freed\n");
  64. + }
  65. + if(pid_pair_list != NULL) {
  66. + avahi_free(pidkey);
  67. + avahi_free(pidvalue);
  68. + DBG(min(15,DBG_AUTO), "pidkey and pidvalue freed\n");
  69. + }
  70. }
  71. }
  72. -
  73. + DBG(min(10,DBG_AUTO), "ending resolve_callback\n");
  74. avahi_service_resolver_free(r);
  75. }
  76. diff --git a/doc/descriptions/kodakaio.desc b/doc/descriptions/kodakaio.desc
  77. index 7882513..5fb18ed 100644
  78. --- a/doc/descriptions/kodakaio.desc
  79. +++ b/doc/descriptions/kodakaio.desc
  80. @@ -1,6 +1,6 @@
  81. :backend "kodakaio"
  82. :url "http://sourceforge.net/projects/cupsdriverkodak/"
  83. -:version "2.4.6"
  84. +:version "2.4.7"
  85. :manpage "sane-kodakaio"
  86. :comment "Backend for Kodak AiO ESP and Hero printers. Also possibly Advent AWL10"
  87. :devicetype :scanner
  88. --
  89. 1.7.10.4