69b289030bd82c6ab12bf1bde0669c5bb5c42187
[packages/openchange.git] / openchange-covscan.patch
1 diff -up openchange-openchange-2.3-VULCAN/libexchange2ical/exchange2ical_property.c.covscan openchange-openchange-2.3-VULCAN/libexchange2ical/exchange2ical_property.c
2 --- openchange-openchange-2.3-VULCAN/libexchange2ical/exchange2ical_property.c.covscan  2018-07-19 13:53:41.281450703 +0200
3 +++ openchange-openchange-2.3-VULCAN/libexchange2ical/exchange2ical_property.c  2018-07-19 13:53:41.285450703 +0200
4 @@ -53,6 +53,7 @@ static void openchange_all_string_sub(ch
5         }
6  }
7  
8 +#if 0
9  struct RRULE_byday {
10         uint16_t        DayOfWeek;
11         const char      *DayName;
12 @@ -68,6 +69,7 @@ static const struct RRULE_byday RRULE_by
13         { 0x0006,       "SA" },
14         { 0x0007,       NULL }
15  };
16 +#endif
17  
18  static const char *get_filename(const char *filename)
19  {
20 diff -up openchange-openchange-2.3-VULCAN/libexchange2ical/exchange2ical_utils.c.covscan openchange-openchange-2.3-VULCAN/libexchange2ical/exchange2ical_utils.c
21 --- openchange-openchange-2.3-VULCAN/libexchange2ical/exchange2ical_utils.c.covscan     2018-07-19 13:53:41.281450703 +0200
22 +++ openchange-openchange-2.3-VULCAN/libexchange2ical/exchange2ical_utils.c     2018-07-19 13:53:41.285450703 +0200
23 @@ -232,7 +232,7 @@ uint32_t get_exchange_rdfDays_from_ical(
24  
25  struct icaltimetype get_icaltimetype_from_tm(struct tm *tm)
26  {
27 -       struct icaltimetype tt;
28 +       struct icaltimetype tt = icaltime_null_time ();
29  
30         tt.year   = tm->tm_year+1900;
31         tt.month  = tm->tm_mon+1;
32 @@ -259,7 +259,7 @@ struct icaltimetype get_icaltimetype_fro
33  
34  struct icaltimetype get_icaldate_from_tm(struct tm *tm)
35  {
36 -       struct icaltimetype tt;
37 +       struct icaltimetype tt = icaltime_null_time ();
38  
39         tt.year   = tm->tm_year+1900;
40         tt.month  = tm->tm_mon+1;
41 @@ -267,6 +267,7 @@ struct icaltimetype get_icaldate_from_tm
42         tt.hour   = 0;
43         tt.minute = 0;
44         tt.second = 0;
45 +       tt.zone   = NULL;
46  
47         tt.is_date     = 1;
48         tt.is_daylight = 0;
49 @@ -292,7 +293,7 @@ struct tm *get_tm_from_FILETIME(const st
50  
51  struct icaltimetype get_icaltime_from_FILETIME(const struct FILETIME *ft)
52  {
53 -       struct icaltimetype     tt;
54 +       struct icaltimetype     tt = icaltime_null_time ();
55         NTTIME                  nttime;
56         struct timeval          temp_timeval;
57         struct tm               *tm;
58 @@ -317,7 +318,7 @@ struct icaltimetype get_icaltime_from_FI
59  
60  struct icaltimetype get_icaltime_from_FILETIME_UTC(const struct FILETIME *ft)
61  {
62 -       struct icaltimetype     tt;
63 +       struct icaltimetype     tt = icaltime_null_time ();
64         NTTIME                  nttime;
65         struct timeval          temp_timeval;
66         struct tm               *tm;
67 @@ -342,7 +343,7 @@ struct icaltimetype get_icaltime_from_FI
68  
69  struct icaltimetype get_icaldate_from_FILETIME(const struct FILETIME *ft)
70  {
71 -       struct icaltimetype     tt;
72 +       struct icaltimetype     tt = icaltime_null_time ();
73         NTTIME                  nttime;
74         struct timeval          temp_timeval;
75         struct tm               *tm;
76 @@ -373,7 +374,7 @@ struct icaltimetype get_icaldate_from_FI
77  
78  struct icaltimetype get_icaldate_from_GlobalObjectId(struct GlobalObjectId *GlobalObjectId)
79  {
80 -       struct icaltimetype     tt;
81 +       struct icaltimetype     tt = icaltime_null_time ();
82         tt.year   = GlobalObjectId->YH;
83         tt.year   = tt.year <<8;
84         tt.year   |= GlobalObjectId->YL;
85 @@ -513,7 +514,10 @@ uint32_t get_minutes_from_icaltimetype(i
86         time_t                  time;
87         NTTIME                  nttime;
88         struct timeval          t;
89 -       
90 +
91 +       if (icaltime_is_null_time(icaltime) || !icaltime_is_valid_time(icaltime))
92 +               return 0;
93 +
94         tm.tm_year      = icaltime.year - 1900;
95         tm.tm_mon       = icaltime.month - 1;
96         tm.tm_mday      = icaltime.day;
97 diff -up openchange-openchange-2.3-VULCAN/libexchange2ical/ical2exchange_property.c.covscan openchange-openchange-2.3-VULCAN/libexchange2ical/ical2exchange_property.c
98 --- openchange-openchange-2.3-VULCAN/libexchange2ical/ical2exchange_property.c.covscan  2015-05-16 17:22:04.000000000 +0200
99 +++ openchange-openchange-2.3-VULCAN/libexchange2ical/ical2exchange_property.c  2018-07-19 13:53:41.286450703 +0200
100 @@ -147,7 +147,6 @@ void ical2exchange_property_CATEGORIES(s
101         struct StringArray_r *sArray;
102         char **stringArray = NULL;
103         char string[256];
104 -       char *value;
105         char *tok;
106         icalproperty *categoriesProp;
107         uint32_t i = 0;
108 @@ -160,8 +159,10 @@ void ical2exchange_property_CATEGORIES(s
109         categoriesProp = icalcomponent_get_first_property(ical2exchange->categoriesEvent, ICAL_CATEGORIES_PROPERTY);
110         sArray->cValues = 0;
111         while(categoriesProp){
112 -       
113 -               value = strdup(icalproperty_get_categories(categoriesProp));
114 +               const char *categories = icalproperty_get_categories(categoriesProp);
115 +               char *value;
116 +
117 +               value = strdup(categories ? categories : "");
118                 tok = strtok(value, ",");
119                 while(tok){
120                         if(!stringArray){
121 @@ -185,6 +186,7 @@ void ical2exchange_property_CATEGORIES(s
122                 }
123                 categoriesProp = icalcomponent_get_next_property(ical2exchange->categoriesEvent, ICAL_CATEGORIES_PROPERTY);
124  
125 +               free(value);
126         }
127         sArray->lppszA= (const char **) stringArray;
128         
129 @@ -519,6 +521,7 @@ void ical2exchange_property_RRULE_EXDATE
130                 
131                 ritr = icalrecur_iterator_new(irt,dtstart);
132                 next=icalrecur_iterator_next(ritr);
133 +               last = icaltime_null_time();
134                 
135                 while (!icaltime_is_null_time(next)){
136                         last = next;
137 diff -up openchange-openchange-2.3-VULCAN/libmapi++/examples/foldertree.cpp.covscan openchange-openchange-2.3-VULCAN/libmapi++/examples/foldertree.cpp
138 --- openchange-openchange-2.3-VULCAN/libmapi++/examples/foldertree.cpp.covscan  2015-05-16 17:22:04.000000000 +0200
139 +++ openchange-openchange-2.3-VULCAN/libmapi++/examples/foldertree.cpp  2018-07-19 13:53:41.286450703 +0200
140 @@ -65,12 +65,12 @@ int main ()
141                 }
142  
143          }
144 -        catch (libmapipp::mapi_exception e) // Catch any MAPI exceptions
145 +        catch (libmapipp::mapi_exception &e) // Catch any MAPI exceptions
146          {
147                  std::cout << "MAPI Exception in main: " <<  e.what()
148                           << std::endl;
149          }
150 -        catch (std::runtime_error e) // Catch any other runtime exceptions
151 +        catch (std::runtime_error &e) // Catch any other runtime exceptions
152          {
153                  std::cout << "std::runtime_error exception in main: "
154                           << e.what() << std::endl;
155 diff -up openchange-openchange-2.3-VULCAN/libmapi++/examples/messages.cpp.covscan openchange-openchange-2.3-VULCAN/libmapi++/examples/messages.cpp
156 --- openchange-openchange-2.3-VULCAN/libmapi++/examples/messages.cpp.covscan    2015-05-16 17:22:04.000000000 +0200
157 +++ openchange-openchange-2.3-VULCAN/libmapi++/examples/messages.cpp    2018-07-19 13:53:41.286450703 +0200
158 @@ -61,12 +61,12 @@ int main ()
159                         }
160                 }
161          }
162 -        catch (libmapipp::mapi_exception e) // Catch any MAPI exceptions
163 +        catch (libmapipp::mapi_exception &e) // Catch any MAPI exceptions
164          {
165                  std::cout << "MAPI Exception in main: " <<  e.what()
166                           << std::endl;
167          }
168 -        catch (std::runtime_error e) // Catch any other runtime exceptions
169 +        catch (std::runtime_error &e) // Catch any other runtime exceptions
170          {
171                  std::cout << "std::runtime_error exception in main: "
172                           << e.what() << std::endl;
173 diff -up openchange-openchange-2.3-VULCAN/libmapi/FXICS.c.covscan openchange-openchange-2.3-VULCAN/libmapi/FXICS.c
174 --- openchange-openchange-2.3-VULCAN/libmapi/FXICS.c.covscan    2015-05-16 17:22:04.000000000 +0200
175 +++ openchange-openchange-2.3-VULCAN/libmapi/FXICS.c    2018-07-19 13:53:41.286450703 +0200
176 @@ -800,6 +800,7 @@ _PUBLIC_ enum MAPISTATUS FXGetBuffer(map
177         if ((retval = mapi_object_get_logon_id(obj_source_context, &logon_id)) != MAPI_E_SUCCESS)
178                 return retval;
179  
180 +       memset(&request, 0, sizeof(struct FastTransferSourceGetBuffer_req));
181         mem_ctx = talloc_named(session, 0, "FXGetBuffer");
182         size = 0;
183  
184 diff -up openchange-openchange-2.3-VULCAN/libmapi/idset.c.covscan openchange-openchange-2.3-VULCAN/libmapi/idset.c
185 --- openchange-openchange-2.3-VULCAN/libmapi/idset.c.covscan    2015-05-16 17:22:04.000000000 +0200
186 +++ openchange-openchange-2.3-VULCAN/libmapi/idset.c    2018-07-19 13:53:41.286450703 +0200
187 @@ -383,6 +383,7 @@ _PUBLIC_ struct idset *IDSET_parse(TALLO
188                         total_bytes += 16;
189                 }
190  
191 +               byte_count = 0;
192                 globset.length = buffer.length - 16;
193                 globset.data = (uint8_t *) buffer.data + 16;
194                 idset->ranges = GLOBSET_parse(idset, globset, &idset->range_count, &byte_count);
195 @@ -1182,7 +1183,8 @@ _PUBLIC_ void RAWIDSET_push_eid(struct r
196                 }
197                 else {
198                         glob_idset = RAWIDSET_make(rawidset->mem_ctx, true, rawidset->single);
199 -                       last_glob_idset->next = glob_idset;
200 +                       if (last_glob_idset)
201 +                               last_glob_idset->next = glob_idset;
202                 }
203                 glob_idset->repl.id = eid_id;
204         }
205 diff -up openchange-openchange-2.3-VULCAN/libmapi/IMAPIProp.c.covscan openchange-openchange-2.3-VULCAN/libmapi/IMAPIProp.c
206 --- openchange-openchange-2.3-VULCAN/libmapi/IMAPIProp.c.covscan        2015-05-16 17:22:04.000000000 +0200
207 +++ openchange-openchange-2.3-VULCAN/libmapi/IMAPIProp.c        2018-07-19 13:53:41.287450703 +0200
208 @@ -1122,6 +1122,7 @@ _PUBLIC_ enum MAPISTATUS QueryNamedPrope
209                 return retval;
210  
211         /* Initialization */
212 +       memset(&request, 0, sizeof(struct QueryNamedProperties_req));
213         mem_ctx = talloc_named(session, 0, "QueryNamesFromIDs");
214         size = 0;
215  
216 diff -up openchange-openchange-2.3-VULCAN/libmapi/IMAPISupport.c.covscan openchange-openchange-2.3-VULCAN/libmapi/IMAPISupport.c
217 --- openchange-openchange-2.3-VULCAN/libmapi/IMAPISupport.c.covscan     2015-05-16 17:22:04.000000000 +0200
218 +++ openchange-openchange-2.3-VULCAN/libmapi/IMAPISupport.c     2018-07-19 13:53:41.287450703 +0200
219 @@ -101,6 +101,7 @@ _PUBLIC_ enum MAPISTATUS Subscribe(mapi_
220         if ((retval = mapi_object_get_logon_id(obj, &logon_id)) != MAPI_E_SUCCESS)
221                 return retval;
222  
223 +       memset(&request, 0, sizeof(struct RegisterNotification_req));
224         mem_ctx = talloc_named(session, 0, "Subscribe");
225  
226         /* Fill the Subscribe operation */
227 diff -up openchange-openchange-2.3-VULCAN/libmapi/IMessage.c.covscan openchange-openchange-2.3-VULCAN/libmapi/IMessage.c
228 --- openchange-openchange-2.3-VULCAN/libmapi/IMessage.c.covscan 2015-05-16 17:22:04.000000000 +0200
229 +++ openchange-openchange-2.3-VULCAN/libmapi/IMessage.c 2018-07-19 13:53:41.287450703 +0200
230 @@ -499,6 +499,8 @@ _PUBLIC_ enum MAPISTATUS SetRecipientTyp
231         enum MAPISTATUS         retval;
232         struct SPropValue       lpProp;
233  
234 +       memset(&lpProp, 0, sizeof(struct SPropValue));
235 +
236         lpProp.ulPropTag = PR_RECIPIENT_TYPE;
237         lpProp.value.l = RecipClass;
238  
239 @@ -1648,6 +1650,7 @@ _PUBLIC_ enum MAPISTATUS OpenEmbeddedMes
240         if ((retval = mapi_object_get_logon_id(obj_attach, &logon_id)) != MAPI_E_SUCCESS)
241                 return retval;
242  
243 +       memset(&lpProp, 0, sizeof(struct SPropValue));
244         mem_ctx = talloc_named(session, 0, "OpenEmbeddedMessage");
245  
246         /* Fill the OpenEmbeddedMessage request */
247 diff -up openchange-openchange-2.3-VULCAN/libmapi/IStoreFolder.c.covscan openchange-openchange-2.3-VULCAN/libmapi/IStoreFolder.c
248 --- openchange-openchange-2.3-VULCAN/libmapi/IStoreFolder.c.covscan     2015-05-16 17:22:04.000000000 +0200
249 +++ openchange-openchange-2.3-VULCAN/libmapi/IStoreFolder.c     2018-07-19 13:53:41.287450703 +0200
250 @@ -93,6 +93,7 @@ _PUBLIC_ enum MAPISTATUS OpenMessage(map
251         if ((retval = mapi_object_get_logon_id(obj_store, &logon_id)) != MAPI_E_SUCCESS)
252                 return retval;
253  
254 +       memset(&lpProp, 0, sizeof(struct SPropValue));
255         mem_ctx = talloc_named(session, 0, "OpenMessage");
256  
257         /* Fill the OpenMessage operation */
258 @@ -232,6 +233,7 @@ _PUBLIC_ enum MAPISTATUS ReloadCachedInf
259         if ((retval = mapi_object_get_logon_id(obj_message, &logon_id)) != MAPI_E_SUCCESS)
260                 return retval;
261  
262 +       memset(&lpProp, 0, sizeof(struct SPropValue));
263         mem_ctx = talloc_named(session, 0, "ReloadCachedInformation");
264  
265         /* Fill the ReloadCachedInformation operation */
266 diff -up openchange-openchange-2.3-VULCAN/libmapi/IStream.c.covscan openchange-openchange-2.3-VULCAN/libmapi/IStream.c
267 --- openchange-openchange-2.3-VULCAN/libmapi/IStream.c.covscan  2015-05-16 17:22:04.000000000 +0200
268 +++ openchange-openchange-2.3-VULCAN/libmapi/IStream.c  2018-07-19 13:53:41.287450703 +0200
269 @@ -183,6 +183,7 @@ _PUBLIC_ enum MAPISTATUS ReadStream(mapi
270         if ((retval = mapi_object_get_logon_id(obj_stream, &logon_id)) != MAPI_E_SUCCESS)
271                 return retval;
272  
273 +       memset(&request, 0, sizeof(struct ReadStream_req));
274         mem_ctx = talloc_named(session, 0, "ReadStream");
275  
276         *ByteRead = 0;
277 diff -up openchange-openchange-2.3-VULCAN/libmapi++/src/folder.cpp.covscan openchange-openchange-2.3-VULCAN/libmapi++/src/folder.cpp
278 --- openchange-openchange-2.3-VULCAN/libmapi++/src/folder.cpp.covscan   2015-05-16 17:22:04.000000000 +0200
279 +++ openchange-openchange-2.3-VULCAN/libmapi++/src/folder.cpp   2018-07-19 13:53:41.287450703 +0200
280 @@ -57,7 +57,7 @@ folder::message_container_type folder::f
281                                 message_container.push_back(message_shared_ptr(new message(m_session,
282                                                                                            m_id,
283                                                                                            row_set.aRow[i].lpProps[1].value.d)));
284 -                       } catch(mapi_exception e) {
285 +                       } catch(mapi_exception &e) {
286                                 mapi_object_release(&contents_table);
287                                 throw;
288                         }
289 @@ -102,7 +102,7 @@ folder::hierarchy_container_type folder:
290                         try {
291                                 hierarchy_container.push_back(folder_shared_ptr(new folder(*this,
292                                                               row_set.aRow[i].lpProps[0].value.d)));
293 -                       } catch(mapi_exception e) {
294 +                       } catch(mapi_exception &e) {
295                                 mapi_object_release(&hierarchy_table);
296                                 throw;
297                         }
298 diff -up openchange-openchange-2.3-VULCAN/libmapi++/src/message.cpp.covscan openchange-openchange-2.3-VULCAN/libmapi++/src/message.cpp
299 --- openchange-openchange-2.3-VULCAN/libmapi++/src/message.cpp.covscan  2015-05-16 17:22:04.000000000 +0200
300 +++ openchange-openchange-2.3-VULCAN/libmapi++/src/message.cpp  2018-07-19 13:53:41.287450703 +0200
301 @@ -50,7 +50,7 @@ message::attachment_container_type messa
302                         try {
303                                 attachment_container.push_back(attachment_shared_ptr(new attachment(*this, row_set.aRow[i].lpProps[0].value.l)));
304                         }
305 -                       catch(mapi_exception e) {
306 +                       catch(mapi_exception &e) {
307                                 mapi_object_release(&attachment_table);
308                                 throw;
309                         }
310 diff -up openchange-openchange-2.3-VULCAN/libmapi++/src/session.cpp.covscan openchange-openchange-2.3-VULCAN/libmapi++/src/session.cpp
311 --- openchange-openchange-2.3-VULCAN/libmapi++/src/session.cpp.covscan  2015-05-16 17:22:04.000000000 +0200
312 +++ openchange-openchange-2.3-VULCAN/libmapi++/src/session.cpp  2018-07-19 13:53:41.287450703 +0200
313 @@ -61,7 +61,7 @@ void session::login(const std::string& p
314         if (m_profile_name == "") { // if profile is not set, try to get default profile
315                 try {
316                         m_profile_name = profile_database().get_default_profile_name();
317 -               } catch(mapi_exception e) {
318 +               } catch(mapi_exception &e) {
319                         uninitialize();
320                         throw;
321                 }
322 @@ -74,7 +74,7 @@ void session::login(const std::string& p
323  
324         try {
325                 m_message_store->open(m_session);
326 -       } catch (mapi_exception e) {
327 +       } catch (mapi_exception &e) {
328                 throw;
329         }
330  }
331 diff -up openchange-openchange-2.3-VULCAN/libmapi++/tests/attach_test.cpp.covscan openchange-openchange-2.3-VULCAN/libmapi++/tests/attach_test.cpp
332 --- openchange-openchange-2.3-VULCAN/libmapi++/tests/attach_test.cpp.covscan    2015-05-16 17:22:04.000000000 +0200
333 +++ openchange-openchange-2.3-VULCAN/libmapi++/tests/attach_test.cpp    2018-07-19 13:53:41.287450703 +0200
334 @@ -84,11 +84,11 @@ int main()
335  
336                 print_folder_tree(top_folder, mapi_session);
337         }
338 -       catch (mapi_exception e) // Catch any mapi exceptions
339 +       catch (mapi_exception &e) // Catch any mapi exceptions
340         {
341                 cout << "MAPI Exception @ main: " <<  e.what() << endl;
342         }
343 -       catch (std::runtime_error e) // Catch runtime exceptions
344 +       catch (std::runtime_error &e) // Catch runtime exceptions
345         {
346                 cout << "std::runtime_error exception @ main: " << e.what() << endl;
347         }
348 diff -up openchange-openchange-2.3-VULCAN/libmapi++/tests/exception_test.cpp.covscan openchange-openchange-2.3-VULCAN/libmapi++/tests/exception_test.cpp
349 --- openchange-openchange-2.3-VULCAN/libmapi++/tests/exception_test.cpp.covscan 2015-05-16 17:22:04.000000000 +0200
350 +++ openchange-openchange-2.3-VULCAN/libmapi++/tests/exception_test.cpp 2018-07-19 13:53:41.287450703 +0200
351 @@ -12,7 +12,7 @@ int main()
352         try {
353                 dotest();
354         }
355 -       catch (libmapipp::mapi_exception e) {
356 +       catch (libmapipp::mapi_exception &e) {
357                 std::cout << e.what() << std::endl;
358         }
359         
360 diff -up openchange-openchange-2.3-VULCAN/libmapi++/tests/profile_test.cpp.covscan openchange-openchange-2.3-VULCAN/libmapi++/tests/profile_test.cpp
361 --- openchange-openchange-2.3-VULCAN/libmapi++/tests/profile_test.cpp.covscan   2015-05-16 17:22:04.000000000 +0200
362 +++ openchange-openchange-2.3-VULCAN/libmapi++/tests/profile_test.cpp   2018-07-19 13:53:41.287450703 +0200
363 @@ -27,15 +27,18 @@
364  #define PROFILEDB_NAME_TEMPLATE "/tmp/mapidbXXXXXX"
365  int main ()
366  {
367 +       char *tmpname = NULL, *tmpname2 = NULL;
368 +
369         try {
370                 libmapipp::profile_database db;
371  
372                 std::cout << "default profile name: " << db.get_default_profile_name() << std::endl;
373  
374                 {
375 -                       char *tmpname = (char*) calloc(sizeof(PROFILEDB_NAME_TEMPLATE) + 1, sizeof(char));
376 -                       strncpy(tmpname, PROFILEDB_NAME_TEMPLATE, sizeof(PROFILEDB_NAME_TEMPLATE));
377 -                       int ret = mkstemp(tmpname);
378 +                       int ret;
379 +
380 +                       tmpname = strdup(PROFILEDB_NAME_TEMPLATE);
381 +                       ret = mkstemp(tmpname);
382                         if (ret < 0) {
383                                 std::cout << "failed to create temporary file: " << strerror(errno) << std::endl;
384                         }
385 @@ -45,12 +48,15 @@ int main ()
386                                 std::cout << "failed to create a temporary profile store" << std::endl;
387                         }
388                         unlink(tmpname);
389 +                       free(tmpname);
390 +                       tmpname = NULL;
391                 }
392                 
393                 {
394 -                       char *tmpname2 = (char*) calloc(sizeof(PROFILEDB_NAME_TEMPLATE) + 1, sizeof(char));
395 -                       strncpy(tmpname2, PROFILEDB_NAME_TEMPLATE, sizeof(PROFILEDB_NAME_TEMPLATE));
396 -                       int ret = mkstemp(tmpname2);
397 +                       int ret;
398 +
399 +                       tmpname2 = strdup(PROFILEDB_NAME_TEMPLATE);
400 +                       ret = mkstemp(tmpname2);
401                         if (ret < 0) {
402                                 std::cout << "failed to create temporary file: " << strerror(errno) << std::endl;
403                         }
404 @@ -60,19 +66,33 @@ int main ()
405                                 std::cout << "failed to create a temporary profile store with std::string" << std::endl;
406                         }
407                         unlink(tmpname2);
408 +                       free(tmpname2);
409 +                       tmpname2 = NULL;
410                 }
411  
412                 std::cout << "finished profile and profile database tests" << std::endl;
413         }
414 -       catch (libmapipp::mapi_exception e) // Catch any mapi exceptions
415 +       catch (libmapipp::mapi_exception &e) // Catch any mapi exceptions
416         {
417                 std::cout << "MAPI Exception @ main: " <<  e.what() << std::endl;
418         }
419 -       catch (std::runtime_error e) // Catch runtime exceptions
420 +       catch (std::runtime_error &e) // Catch runtime exceptions
421         {
422                 std::cout << "std::runtime_error exception @ main: " << e.what() << std::endl;
423  
424         }
425  
426 +       if (tmpname) {
427 +               unlink(tmpname);
428 +               free(tmpname);
429 +               tmpname = NULL;
430 +       }
431 +
432 +       if (tmpname2) {
433 +               unlink(tmpname2);
434 +               free(tmpname2);
435 +               tmpname2 = NULL;
436 +       }
437 +
438         return 0;
439  }
440 diff -up openchange-openchange-2.3-VULCAN/libmapi++/tests/test.cpp.covscan openchange-openchange-2.3-VULCAN/libmapi++/tests/test.cpp
441 --- openchange-openchange-2.3-VULCAN/libmapi++/tests/test.cpp.covscan   2015-05-16 17:22:04.000000000 +0200
442 +++ openchange-openchange-2.3-VULCAN/libmapi++/tests/test.cpp   2018-07-19 13:53:41.288450703 +0200
443 @@ -126,11 +126,11 @@ int main ()
444  
445                 cout << "finished session" << endl;
446         }
447 -       catch (mapi_exception e) // Catch any mapi exceptions
448 +       catch (mapi_exception &e) // Catch any mapi exceptions
449         {
450                 cout << "MAPI Exception @ main: " <<  e.what() << endl;
451         }
452 -       catch (std::runtime_error e) // Catch runtime exceptions
453 +       catch (std::runtime_error &e) // Catch runtime exceptions
454         {
455                 cout << "std::runtime_error exception @ main: " << e.what() << endl;
456  
457 diff -up openchange-openchange-2.3-VULCAN/libocpf/ocpf_api.c.covscan openchange-openchange-2.3-VULCAN/libocpf/ocpf_api.c
458 --- openchange-openchange-2.3-VULCAN/libocpf/ocpf_api.c.covscan 2015-05-16 17:22:04.000000000 +0200
459 +++ openchange-openchange-2.3-VULCAN/libocpf/ocpf_api.c 2018-07-19 13:53:41.288450703 +0200
460 @@ -316,6 +316,8 @@ int ocpf_propvalue(struct ocpf_context *
461         if (!ocpf || !ocpf->mem_ctx) return OCPF_ERROR;
462         if (!ctx) return OCPF_ERROR;
463  
464 +       memset(&lpProps, 0, sizeof(struct SPropValue));
465 +
466         switch (scope) {
467         case kw_PROPERTY:
468                 /* Sanity check: do not insert the same property twice */
469 diff -up openchange-openchange-2.3-VULCAN/libocpf/ocpf_public.c.covscan openchange-openchange-2.3-VULCAN/libocpf/ocpf_public.c
470 --- openchange-openchange-2.3-VULCAN/libocpf/ocpf_public.c.covscan      2015-05-16 17:22:04.000000000 +0200
471 +++ openchange-openchange-2.3-VULCAN/libocpf/ocpf_public.c      2018-07-19 13:53:41.288450703 +0200
472 @@ -537,6 +537,8 @@ static bool set_external_recipients(TALL
473         uint32_t                last;
474         struct SPropValue       SPropValue;
475  
476 +       memset(&SPropValue, 0, sizeof(struct SPropValue));
477 +
478         SRowSet->aRow = talloc_realloc(mem_ctx, SRowSet->aRow, struct SRow, SRowSet->cRows + 2);
479         last = SRowSet->cRows;
480         SRowSet->aRow[last].cValues = 0;
481 @@ -626,6 +628,8 @@ _PUBLIC_ enum MAPISTATUS ocpf_set_Recipi
482  
483         MAPI_RETVAL_IF(!ctx->recipients->cRows, MAPI_E_NOT_FOUND, NULL);
484  
485 +       memset(&SPropValue, 0, sizeof(struct SPropValue));
486 +
487         SPropTagArray = set_SPropTagArray(mem_ctx, 0x8,
488                                           PidTagObjectType,
489                                           PidTagDisplayName,
490 diff -up openchange-openchange-2.3-VULCAN/ndr_mapi.c.covscan openchange-openchange-2.3-VULCAN/ndr_mapi.c
491 --- openchange-openchange-2.3-VULCAN/ndr_mapi.c.covscan 2018-07-19 13:53:41.276450703 +0200
492 +++ openchange-openchange-2.3-VULCAN/ndr_mapi.c 2018-07-19 13:53:41.288450703 +0200
493 @@ -1310,8 +1310,11 @@ _PUBLIC_ enum ndr_err_code ndr_pull_EcDo
494                 NDR_PULL_ALLOC(ndr, r->out.pulTimeStamp);
495                 *r->out.pulTimeStamp = *r->in.pulTimeStamp;
496                 NDR_PULL_ALLOC(ndr, r->out.pcbAuxOut);
497 -               *r->out.pcbAuxOut = *r->in.pcbAuxOut;
498 -       }               
499 +               if (r->in.pcbAuxOut)
500 +                       *r->out.pcbAuxOut = *r->in.pcbAuxOut;
501 +               else
502 +                       *r->out.pcbAuxOut = 0;
503 +       }
504  
505         if (flags & NDR_OUT) {
506                 if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) {
507 diff -up openchange-openchange-2.3-VULCAN/script/makepropslist.py.covscan openchange-openchange-2.3-VULCAN/script/makepropslist.py
508 --- openchange-openchange-2.3-VULCAN/script/makepropslist.py.covscan    2015-05-16 17:22:04.000000000 +0200
509 +++ openchange-openchange-2.3-VULCAN/script/makepropslist.py    2018-07-19 13:53:41.288450703 +0200
510 @@ -992,7 +992,7 @@ def check_duplicate_alternative_names():
511                                 if previous_alternative_names.has_key(altname):
512                                         print "\tIn section", entry["OXPROPS_Sect"], ", alternative name:", altname, "duplicates name in section", previous_alternative_names[altname]
513                                 if previous_canonical_names.has_key(altname):
514 -                                       print "\tIn section", entry["OXPROPS_Sect"], ", alternative name:", altname, "duplicates canonical name in section", previous_alternative_names[altname]
515 +                                       print "\tIn section", entry["OXPROPS_Sect"], ", alternative name:", altname, "duplicates canonical name in section", previous_canonical_names[altname]
516                                 previous_alternative_names[altname] = (entry["OXPROPS_Sect"])
517  
518  def check_duplicate_propids():
519 diff -up openchange-openchange-2.3-VULCAN/testprogs/test_asyncnotif.c.covscan openchange-openchange-2.3-VULCAN/testprogs/test_asyncnotif.c
520 --- openchange-openchange-2.3-VULCAN/testprogs/test_asyncnotif.c.covscan        2015-05-16 17:22:04.000000000 +0200
521 +++ openchange-openchange-2.3-VULCAN/testprogs/test_asyncnotif.c        2018-07-19 13:53:41.288450703 +0200
522 @@ -109,12 +109,16 @@ static int callback(uint16_t Notificatio
523                 break;
524         case fnevMbit|fnevObjectDeleted:
525                 OC_DEBUG(0, "[+] Message deleted");
526 +               break;
527         case fnevMbit|fnevObjectModified:
528                 OC_DEBUG(0, "[+] Message modified");
529 +               break;
530         case fnevMbit|fnevObjectMoved:
531                 OC_DEBUG(0, "[+] Message moved");
532 +               break;
533         case fnevMbit|fnevObjectCopied:
534                 OC_DEBUG(0, "[+] Message copied");
535 +               break;
536         case fnevMbit|fnevTableModified:
537                 ctable = (struct ContentsTableChange *) NotificationData;
538                 switch (ctable->TableEvent) {
539 @@ -143,6 +147,7 @@ static int callback(uint16_t Notificatio
540                 break;
541         case fnevMbit|fnevSbit|fnevObjectModified:
542                 OC_DEBUG(0, "[+] A property on a message in a search folder has changed");
543 +               break;
544         case fnevMbit|fnevSbit|fnevTableModified:
545                 stable = (struct ContentsTableChange *) NotificationData;
546                 switch (stable->TableEvent) {
547 @@ -250,6 +255,7 @@ int main(int argc, const char *argv[])
548  
549         retval = MAPIInitialize(&mapi_ctx, opt_profdb);
550         if (retval != MAPI_E_SUCCESS) {
551 +               talloc_free(mem_ctx);
552                 mapi_errstr("MAPIInitialize", retval);
553                 exit (1);
554         }
555 @@ -261,6 +267,10 @@ int main(int argc, const char *argv[])
556                 SetMAPIDebugLevel(mapi_ctx, atoi(opt_debug));
557         }
558  
559 +       mapi_object_init(&obj_store);
560 +       mapi_object_init(&obj_inbox);
561 +       mapi_object_init(&obj_contentstable);
562 +
563         /* if no profile is supplied use the default one */
564         if (!opt_profname) {
565                 retval = GetDefaultProfile(mapi_ctx, &opt_profname);
566 @@ -280,7 +290,6 @@ int main(int argc, const char *argv[])
567         }
568  
569         /* Open the default message store */
570 -       mapi_object_init(&obj_store);
571  
572         retval = OpenMsgStore(session, &obj_store);
573         if (retval != MAPI_E_SUCCESS) {
574 @@ -292,11 +301,9 @@ int main(int argc, const char *argv[])
575         retval = GetReceiveFolder(&obj_store, &fid, NULL);
576         MAPI_RETVAL_IF(retval, retval, mem_ctx);
577  
578 -       mapi_object_init(&obj_inbox);
579         retval = OpenFolder(&obj_store, fid, &obj_inbox);
580         MAPI_RETVAL_IF(retval, retval, mem_ctx);
581  
582 -       mapi_object_init(&obj_contentstable);
583         retval = GetContentsTable(&obj_inbox, &obj_contentstable, 0, &count);
584         printf("mailbox contains %i messages\n", count);
585  
586 diff -up openchange-openchange-2.3-VULCAN/utils/mapipropsdump.c.covscan openchange-openchange-2.3-VULCAN/utils/mapipropsdump.c
587 --- openchange-openchange-2.3-VULCAN/utils/mapipropsdump.c.covscan      2018-07-19 13:53:41.276450703 +0200
588 +++ openchange-openchange-2.3-VULCAN/utils/mapipropsdump.c      2018-07-19 13:53:41.289450703 +0200
589 @@ -79,21 +79,21 @@
590   */
591  
592  
593 -static const const struct ndr_interface_table *load_exchange_emsmdb_dso(const char *plugin)
594 +static const struct ndr_interface_table *load_exchange_emsmdb_dso(const char *plugin, void **phandle)
595  {
596         const struct ndr_interface_table        *p;
597 -       void                                    *handle;
598  
599 -       handle = dlopen(plugin, RTLD_NOW);
600 -       if (handle == NULL) {
601 +       *phandle = dlopen(plugin, RTLD_NOW);
602 +       if (*phandle == NULL) {
603                 printf("%s: Unable to open: %s\n", plugin, dlerror());
604                 return NULL;
605         }
606  
607 -       p = (const struct ndr_interface_table *) dlsym(handle, "ndr_table_exchange_emsmdb");
608 +       p = (const struct ndr_interface_table *) dlsym(*phandle, "ndr_table_exchange_emsmdb");
609         if (!p) {
610                 OC_DEBUG(0, "%s: Unable to find DCE/RPC interface table for 'ndr_table_exchange_emsmdb': %s", plugin, dlerror());
611 -               dlclose(handle);
612 +               dlclose(*phandle);
613 +               *phandle = NULL;
614                 return NULL;
615         }
616  
617 @@ -409,6 +409,7 @@ int main(int argc, const char *argv[])
618         struct SPropTagArray                    *s;
619         const char                              *opt_reqfile = NULL;
620         const char                              *opt_replfile = NULL;
621 +       void                                    *plhandle = NULL;
622         poptContext                             pc;
623         int                                     opt;
624         int                                     index = -1;
625 @@ -442,7 +443,7 @@ int main(int argc, const char *argv[])
626                 exit (1);
627         }
628  
629 -       p = load_exchange_emsmdb_dso(PLUGIN);
630 +       p = load_exchange_emsmdb_dso(PLUGIN, &plhandle);
631         if (!p) {
632                 exit (1);
633         }
634 @@ -454,6 +455,7 @@ int main(int argc, const char *argv[])
635         s = process_request(mem_ctx, f, opt_reqfile, &opnum, &index);
636         if (!s) {
637                 talloc_free(mem_ctx);
638 +               dlclose(plhandle);
639                 exit (1);
640         }
641  
642 @@ -461,9 +463,12 @@ int main(int argc, const char *argv[])
643         ret = process_response(mem_ctx, f, opt_replfile, s, opnum, index);
644         if (ret == -1) {
645                 talloc_free(mem_ctx);
646 +               dlclose(plhandle);
647                 exit (1);
648         }
649  
650         talloc_free(mem_ctx);
651 +       dlclose(plhandle);
652 +
653         return (0);
654  }
655 diff -up openchange-openchange-2.3-VULCAN/utils/openchangeclient.c.covscan openchange-openchange-2.3-VULCAN/utils/openchangeclient.c
656 --- openchange-openchange-2.3-VULCAN/utils/openchangeclient.c.covscan   2018-07-19 13:53:41.277450703 +0200
657 +++ openchange-openchange-2.3-VULCAN/utils/openchangeclient.c   2018-07-19 13:53:41.289450703 +0200
658 @@ -629,6 +629,8 @@ static bool set_external_recipients(TALL
659         uint32_t                last;
660         struct SPropValue       SPropValue;
661  
662 +       memset(&SPropValue, 0, sizeof(struct SPropValue));
663 +
664         SRowSet->aRow = talloc_realloc(mem_ctx, SRowSet->aRow, struct SRow, SRowSet->cRows + 1);
665         last = SRowSet->cRows;
666         SRowSet->aRow[last].cValues = 0;
667 @@ -821,6 +823,8 @@ static enum MAPISTATUS openchangeclient_
668         mapi_object_init(&obj_outbox);
669         mapi_object_init(&obj_message);
670  
671 +       memset(&SPropValue, 0, sizeof(struct SPropValue));
672 +
673         if (oclient->pf == true) {
674                 retval = openchangeclient_getpfdir(mem_ctx, obj_store, &obj_outbox, oclient->folder);
675                 if (retval != MAPI_E_SUCCESS) return retval;
This page took 0.117295 seconds and 2 git commands to generate.