~ubuntu-branches/debian/experimental/hplip/experimental

« back to all changes in this revision

Viewing changes to scan/sane/soap.c

Tags: 3.13.3-1
* New Upstream Release 
  - Fixes CVE-2013-0200 (Closes: #701185)
  - Fixes "hp-check does not find installed Xsane" (Closes: #690362)
* Ack NMU - Thanks Sebastian Ramacher

Show diffs side-by-side

added added

removed removed

Lines of Context:
56
56
#include "soap.h"
57
57
#include "soapi.h"
58
58
#include "io.h"
 
59
#include "utils.h"
59
60
 
60
61
#define DEBUG_DECLARE_ONLY
61
62
#include "sanei_debug.h"
64
65
 
65
66
static int bb_load(struct soap_session *ps, const char *so)
66
67
{
67
 
   char home[128];
68
 
   char sz[255]; 
69
68
   int stat=1;
70
69
 
71
70
   /* Load hpmud manually with symbols exported. Otherwise the plugin will not find it. */ 
72
71
   if ((ps->hpmud_handle = dlopen("libhpmud.so", RTLD_LAZY|RTLD_GLOBAL)) == NULL)
73
72
   {
74
 
      if ((ps->hpmud_handle = dlopen("libhpmud.so.0", RTLD_LAZY|RTLD_GLOBAL)) == NULL)
75
 
      {
76
 
         BUG("unable to load restricted library: %s\n", dlerror());
77
 
         goto bugout;
78
 
      }
 
73
     if ((ps->hpmud_handle = dlopen("libhpmud.so.0", RTLD_LAZY|RTLD_GLOBAL)) == NULL)
 
74
     {
 
75
       BUG("unable to load restricted library: %s\n", dlerror());
 
76
       goto bugout;
 
77
     }
79
78
   } 
80
79
 
81
80
   /* Load math library manually with symbols exported (Ubuntu 8.04). Otherwise the plugin will not find it. */ 
82
 
   if ((ps->math_handle = dlopen("libm.so", RTLD_LAZY|RTLD_GLOBAL)) == NULL)
 
81
   if ((ps->math_handle = load_library("libm.so")) == NULL)
83
82
   {
84
 
      if ((ps->math_handle = dlopen("libm.so.6", RTLD_LAZY|RTLD_GLOBAL)) == NULL)
85
 
      {
86
 
         BUG("unable to load restricted library: %s\n", dlerror());
 
83
      if ((ps->math_handle = load_library("libm.so.6")) == NULL)
87
84
         goto bugout;
88
 
      }
89
85
   } 
90
86
 
91
 
   if (hpmud_get_conf("[dirs]", "home", home, sizeof(home)) != HPMUD_R_OK)
92
 
      goto bugout;
93
 
   snprintf(sz, sizeof(sz), "%s/scan/plugins/%s", home, so);
94
 
   if ((ps->bb_handle = dlopen(sz, RTLD_NOW|RTLD_GLOBAL)) == NULL)
 
87
   if ((ps->bb_handle = load_plugin_library(UTILS_SCAN_PLUGIN_LIBRARY, so)) == NULL)
95
88
   {
96
 
      BUG("unable to load restricted library %s: %s\n", sz, dlerror());
97
89
      SendScanEvent(ps->uri, EVENT_PLUGIN_FAIL);
98
90
      goto bugout;
99
91
   } 
100
92
   
101
 
   if ((ps->bb_open = dlsym(ps->bb_handle, "bb_open")) == NULL)
102
 
   {
103
 
      BUG("unable to load restricted library %s: %s\n", sz, dlerror());
104
 
      goto bugout;
105
 
   } 
106
 
   if ((ps->bb_close = dlsym(ps->bb_handle, "bb_close")) == NULL)
107
 
   {
108
 
      BUG("unable to load restricted library %s: %s\n", sz, dlerror());
109
 
      goto bugout;
110
 
   } 
111
 
   if ((ps->bb_get_parameters = dlsym(ps->bb_handle, "bb_get_parameters")) == NULL)
112
 
   {
113
 
      BUG("unable to load restricted library %s: %s\n", sz, dlerror());
114
 
      goto bugout;
115
 
   } 
116
 
   if ((ps->bb_is_paper_in_adf = dlsym(ps->bb_handle, "bb_is_paper_in_adf")) == NULL)
117
 
   {
118
 
      BUG("unable to load restricted library %s: %s\n", sz, dlerror());
119
 
      goto bugout;
120
 
   } 
121
 
   if ((ps->bb_start_scan = dlsym(ps->bb_handle, "bb_start_scan")) == NULL)
122
 
   {
123
 
      BUG("unable to load restricted library %s: %s\n", sz, dlerror());
124
 
      goto bugout;
125
 
   } 
126
 
   if ((ps->bb_end_scan = dlsym(ps->bb_handle, "bb_end_scan")) == NULL)
127
 
   {
128
 
      BUG("unable to load restricted library %s: %s\n", sz, dlerror());
129
 
      goto bugout;
130
 
   } 
131
 
   if ((ps->bb_get_image_data = dlsym(ps->bb_handle, "bb_get_image_data")) == NULL)
132
 
   {
133
 
      BUG("unable to load restricted library %s: %s\n", sz, dlerror());
134
 
      goto bugout;
135
 
   } 
136
 
   if ((ps->bb_end_page = dlsym(ps->bb_handle, "bb_end_page")) == NULL)
137
 
   {
138
 
      BUG("unable to load restricted library %s: %s\n", sz, dlerror());
139
 
      goto bugout;
140
 
   } 
 
93
   if ((ps->bb_open = get_library_symbol(ps->bb_handle, "bb_open")) == NULL)
 
94
      goto bugout;
 
95
 
 
96
   if ((ps->bb_close = get_library_symbol(ps->bb_handle, "bb_close")) == NULL)
 
97
      goto bugout;
 
98
 
 
99
   if ((ps->bb_get_parameters = get_library_symbol(ps->bb_handle, "bb_get_parameters")) == NULL)
 
100
      goto bugout;
 
101
 
 
102
   if ((ps->bb_is_paper_in_adf = get_library_symbol(ps->bb_handle, "bb_is_paper_in_adf")) == NULL)
 
103
      goto bugout;
 
104
 
 
105
   if ((ps->bb_start_scan = get_library_symbol(ps->bb_handle, "bb_start_scan")) == NULL)
 
106
      goto bugout;
 
107
 
 
108
    if ((ps->bb_end_scan = get_library_symbol(ps->bb_handle, "bb_end_scan")) == NULL)
 
109
      goto bugout;
 
110
 
 
111
   if ((ps->bb_get_image_data = get_library_symbol(ps->bb_handle, "bb_get_image_data")) == NULL)
 
112
      goto bugout;
 
113
 
 
114
   if ((ps->bb_end_page = get_library_symbol(ps->bb_handle, "bb_end_page")) == NULL)
 
115
      goto bugout;
 
116
 
141
117
 
142
118
   stat=0;
143
119
 
147
123
 
148
124
static int bb_unload(struct soap_session *ps)
149
125
{
150
 
   if (ps->bb_handle)
151
 
   {   
152
 
      dlclose(ps->bb_handle);
153
 
      ps->bb_handle = NULL;
154
 
   }  
155
 
   if (ps->hpmud_handle)
156
 
   {   
157
 
      dlclose(ps->hpmud_handle);
158
 
      ps->hpmud_handle = NULL;
159
 
   }  
160
 
   if (ps->math_handle)
161
 
   {   
162
 
      dlclose(ps->math_handle);
163
 
      ps->math_handle = NULL;
164
 
   }  
 
126
    unload_library(ps->bb_handle);
 
127
    ps->bb_handle = NULL;
 
128
 
 
129
    unload_library(ps->hpmud_handle);
 
130
    ps->hpmud_handle = NULL;
 
131
 
 
132
    unload_library(ps->math_handle);
 
133
    ps->math_handle = NULL;
 
134
 
165
135
   return 0;
166
136
} /* bb_unload */
167
137
 
462
432
      return SANE_STATUS_IO_ERROR;
463
433
   }
464
434
 
465
 
   if (bb_load(session, "bb_soap.so"))
 
435
   if (bb_load(session, SCAN_PLUGIN_SOAP))
466
436
   {
467
437
      stat = SANE_STATUS_IO_ERROR;
468
438
      goto bugout;
607
577
         }
608
578
         else
609
579
         {  /* Set default. */
610
 
            ps->currentScanMode = CE_RGB24;
 
580
            ps->currentScanMode = ps->scanModeMap[0];
611
581
            set_scan_mode_side_effects(ps, ps->currentScanMode);
612
582
            stat = SANE_STATUS_GOOD;
613
583
         }