Initialize Tizen 2.3
[framework/system/oma-dm-agent.git] / src / agent / serviceadapter / sa_elements.c
1 /*
2  * oma-dm-agent
3  * Copyright (c) 2012 Samsung Electronics Co., Ltd.
4  *
5  * Licensed under the Apache License, Version 2.0 (the License);
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  *     http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17
18 /*sync-agent*/
19 #include <sync_agent.h>
20
21 /*dm-agent*/
22 #include "common/dm_common.h"
23 #include "common/util/util.h"
24 #include "serviceadapter/protocolbinder/syncml_def.h"
25 #include "serviceadapter/sa_elements.h"
26 #include "serviceadapter/sa_elements_internal.h"
27 #include "serviceadapter/sa_session_internal.h"
28 #include "serviceadapter/sa_command.h"
29 #include "mo-handler/dm_mo_common.h"
30
31 #ifndef OMADM_AGENT_LOG
32 #undef LOG_TAG
33 #define LOG_TAG "OMA_DM_SA"
34 #endif
35
36 DM_ERROR create_hmac(char *auth_name, char *auth_type, char *mac, Session ** session)
37 {
38         _EXTERN_FUNC_ENTER;
39
40         DM_ERROR ret = DM_OK;
41
42         retvm_if((auth_name) == NULL, COMMON_ERR_INTERNAL_NO_MEMORY, "auth_name is NULL!!");
43         retvm_if((auth_type) == NULL, COMMON_ERR_INTERNAL_NO_MEMORY, "auth_type is NULL!!");
44         retvm_if((mac) == NULL, COMMON_ERR_INTERNAL_NO_MEMORY, "mac is NULL!!");
45
46         if ((*session)->reqhmacinfo == NULL) {
47                 (*session)->reqhmacinfo = (Hmac *) calloc(1, sizeof(Hmac));
48                 if ((*session)->reqhmacinfo == NULL) {
49                         ret = COMMON_ERR_ALLOC;
50                         goto error;
51                 }
52         }
53
54         if ((*session)->reqhmacinfo->username != NULL) {
55                 str_free(&(*session)->reqhmacinfo->username);
56         }
57         if ((*session)->reqhmacinfo->authtype != NULL) {
58                 str_free(&(*session)->reqhmacinfo->authtype);
59         }
60         if ((*session)->reqhmacinfo->mac != NULL) {
61                 str_free(&(*session)->reqhmacinfo->mac);
62         }
63
64         (*session)->reqhmacinfo->username = strdup(auth_name);
65         (*session)->reqhmacinfo->authtype = strdup(auth_type);
66         (*session)->reqhmacinfo->mac = strdup(mac);
67
68         _DEBUG_INFO("user name : %s", auth_name);
69         _DEBUG_INFO("auth type : %s", auth_type);
70         _DEBUG_INFO("mac : %s", mac);
71
72         _DEBUG_INFO(" end : %d", ret);
73         _EXTERN_FUNC_EXIT;
74         return ret;
75  error:
76         _DEBUG_INFO(" end error : %d", ret);
77         _EXTERN_FUNC_EXIT;
78         return ret;
79 }
80
81 DM_ERROR create_location(const char *locURI, const char *locName, Location ** pLocation)
82 {
83         _EXTERN_FUNC_ENTER;
84
85         DM_ERROR ret = DM_OK;
86
87         retvm_if((locURI) == NULL, COMMON_ERR_INTERNAL_NO_MEMORY, "locURI is NULL!!");
88         _DEBUG_INFO("start with locURI = %s", locURI);
89
90         if(locName != NULL){
91                 _DEBUG_INFO("locName = %s", locName);
92         }
93
94         *pLocation = (Location *) calloc(1, sizeof(Location) + 1);
95         if (*pLocation == NULL) {
96                 ret = COMMON_ERR_ALLOC;
97                 goto error;
98         }
99         (*pLocation)->locURI = g_strdup(locURI);
100
101         if (locName != NULL) {
102                 (*pLocation)->locName = g_strdup(locName);
103         }
104
105         _DEBUG_INFO("end");
106         _EXTERN_FUNC_EXIT;
107         return ret;
108
109  error:
110         _DEBUG_INFO(" error : %d\n", ret);
111         _EXTERN_FUNC_EXIT;
112         return ret;
113 }
114
115 Location *dup_location(Location * pLocation)
116 {
117         _EXTERN_FUNC_ENTER;
118
119         DM_ERROR ret = DM_OK;
120
121         retvm_if((pLocation) == NULL, NULL, "pLocation is NULL!!");
122
123         Location *location = NULL;
124         ret = create_location(pLocation->locURI, pLocation->locName, &location);
125         if (ret != DM_OK)
126                 goto error;
127
128         _EXTERN_FUNC_EXIT;
129         return location;
130
131  error:
132         _DEBUG_INFO(" error : %d\n", ret);
133         _EXTERN_FUNC_EXIT;
134         return NULL;
135
136 }
137
138 char *get_location_locname(Location * location)
139 {
140         _EXTERN_FUNC_ENTER;
141
142         retvm_if((location) == NULL, NULL, "location is NULL!!");
143
144         _EXTERN_FUNC_EXIT;
145
146         return location->locName;
147 }
148
149 char *get_location_locuri(Location * location)
150 {
151         _EXTERN_FUNC_ENTER;
152
153         retvm_if((location) == NULL, NULL, "location is NULL!!");
154
155         _EXTERN_FUNC_EXIT;
156
157         return location->locURI;
158 }
159
160 void free_location(Location * loc)
161 {
162         _EXTERN_FUNC_ENTER;
163
164         retm_if((loc) == NULL, "loc is NULL!!");
165
166         if (loc->locURI != NULL) {
167                 _DEBUG_INFO(" loc->locURI = %s\n", loc->locURI);
168                 free(loc->locURI);
169                 loc->locURI = NULL;
170         }
171
172         if (loc->locName != NULL) {
173                 _DEBUG_INFO(" loc->locName = %s\n", loc->locName);
174                 free(loc->locName);
175                 loc->locName = NULL;
176         }
177         if (loc != NULL) {
178                 free(loc);
179                 loc = NULL;
180         }
181         _EXTERN_FUNC_EXIT;
182 }
183
184 void free_cred(Cred * cred)
185 {
186         _EXTERN_FUNC_ENTER;
187
188         if (cred == NULL)
189                 return;
190
191         if (cred->data != NULL) {
192                 free(cred->data);
193                 cred->data = NULL;
194         }
195
196         if (cred->username != NULL) {
197                 free(cred->username);
198                 cred->username = NULL;
199         }
200
201         if (cred->password != NULL) {
202                 free(cred->password);
203                 cred->password = NULL;
204         }
205         if (cred != NULL) {
206                 free(cred);
207                 cred = NULL;
208         }
209
210         _EXTERN_FUNC_EXIT;
211 }
212
213 DM_ERROR create_auth_cred(char *userName, char *pwd, AuthType authType, FormatType formatType, char *data, Cred ** cred)
214 {
215
216         _EXTERN_FUNC_ENTER;
217
218         DM_ERROR ret = DM_OK;
219
220         retvm_if((userName) == NULL, COMMON_ERR_INTERNAL_NO_MEMORY, "userName is NULL!!");
221         retvm_if((pwd) == NULL, COMMON_ERR_INTERNAL_NO_MEMORY, "pwd is NULL!!");
222
223         _DEBUG_INFO(" user : %s , pwd : %s, authtype : %d,. formattype : %d, cred : %s\n", userName, pwd, authType, formatType, data);
224
225         if (strlen(userName) == 0 || strlen(pwd) == 0) {
226                 ret = COMMON_ERR_INTERNAL_NOT_DEFINED;
227                 goto error;
228         }
229
230         if (data != NULL) {
231                 *cred = (Cred *) calloc(1, sizeof(Cred));
232                 if (*cred == NULL) {
233                         ret = COMMON_ERR_ALLOC;
234                         goto error;
235                 }
236
237                 (*cred)->type = authType;
238                 (*cred)->format = formatType;
239                 (*cred)->username = strdup(userName);
240                 (*cred)->password = strdup(pwd);
241
242                 (*cred)->data = strdup(data);
243         } else if (data == NULL && authType == AUTH_TYPE_HMAC) {
244                 /* hmac  */
245         } else {
246                 /*error */
247                 ret = COMMON_ERR_IS_NULL;
248         }
249
250         _EXTERN_FUNC_EXIT;
251         return ret;
252  error:
253         _DEBUG_INFO(" error : %d\n", ret);
254         _EXTERN_FUNC_EXIT;
255         return ret;
256
257 }
258
259 Cred *create_credwithdata(AuthType authType, char *data)
260 {
261         _EXTERN_FUNC_ENTER;
262
263         DM_ERROR ret = DM_OK;
264
265         retvm_if((data) == NULL, NULL, "data is NULL!!");
266
267         Cred *cred = (Cred *) calloc(1, sizeof(Cred));
268         if (cred == NULL) {
269                 ret = COMMON_ERR_ALLOC;
270                 goto error;
271         }
272
273         cred->type = authType;
274         cred->data = strdup(data);
275
276         _EXTERN_FUNC_EXIT;
277         return cred;
278  error:
279         _DEBUG_INFO(" error : %d\n", ret);
280         _EXTERN_FUNC_EXIT;
281         return NULL;
282
283 }
284
285 void set_credformattype(Cred * cred, FormatType formatType)
286 {
287         _EXTERN_FUNC_ENTER;
288
289         retm_if((cred) == NULL, "cred is NULL!!");
290
291         cred->format = formatType;
292
293         _EXTERN_FUNC_EXIT;
294 }
295
296 DM_ERROR check_server_cred(Cred * hdrCred, Session * session)   //Cred *sessionCred)
297 {
298         _EXTERN_FUNC_ENTER;
299
300         DM_ERROR ret = DM_OK;
301
302         retvm_if((hdrCred) == NULL, COMMON_ERR_INTERNAL_NO_MEMORY, "hdrCred is NULL!!");
303         retvm_if((session) == NULL, COMMON_ERR_INTERNAL_NO_MEMORY, "session is NULL!!");
304
305         char *server_id;
306         char *server_pwd;
307         char *sourceUrl;
308         char *targetUrl;
309         int isBase64;
310         char *nextNonce;
311         char *authType;
312
313         ret = get_server_dmacc(session->pServer_id, &server_id, &server_pwd, &sourceUrl, &targetUrl, &isBase64, &nextNonce, &authType);
314         if (ret != DM_OK)
315                 goto error;
316         _DEBUG_INFO("packet server pw data : %s", hdrCred->data);
317         _DEBUG_INFO("server pw : %s", server_pwd);
318         if (hdrCred->data != NULL) {
319                 if (strcmp(hdrCred->data, server_pwd) == 0) {
320                         ret = DM_OK;
321                 } else {
322                         ret = DM_ERR_UNAUTHORIZED;
323                 }
324         } else {
325                 //do nothing
326         }
327         str_free(&server_id);
328         str_free(&server_pwd);
329         str_free(&sourceUrl);
330         str_free(&targetUrl);
331         str_free(&nextNonce);
332         str_free(&authType);
333
334         _EXTERN_FUNC_EXIT;
335         return ret;
336  error:
337         _DEBUG_INFO(" end error : %d", ret);
338         _EXTERN_FUNC_EXIT;
339         return ret;
340 }
341
342 DM_ERROR create_chal(FormatType format, AuthType type, char *nextnonce, Chal ** pChal)
343 {
344         _EXTERN_FUNC_ENTER;
345
346         retvm_if((nextnonce) == NULL, COMMON_ERR_INTERNAL_NO_MEMORY, "nextnonce is NULL!!");
347         _DEBUG_INFO("start with format = %d, type = %d Nextnonce =  %s\n", format, type, nextnonce);
348
349         DM_ERROR ret = DM_OK;
350
351         *pChal = (Chal *) calloc(1, sizeof(Chal));
352         if (*pChal == NULL) {
353                 ret = COMMON_ERR_ALLOC;
354                 goto error;
355         }
356
357         (*pChal)->format = format;
358         (*pChal)->type = type;
359         if (type == AUTH_TYPE_MD5 || type == AUTH_TYPE_HMAC) {
360                 (*pChal)->nonce_plain = g_strdup(nextnonce);
361         }
362
363         _EXTERN_FUNC_EXIT;
364         return ret;
365
366  error:
367         _DEBUG_INFO(" error : %d\n", ret);
368         _EXTERN_FUNC_EXIT;
369         return ret;
370 }
371
372 void free_chal(Chal * pChal)
373 {
374         _EXTERN_FUNC_ENTER;
375         if (pChal == NULL) {
376                 _EXTERN_FUNC_EXIT;
377                 return;
378         }
379
380         pChal->format = 0;
381         pChal->type = 0;
382         pChal->nonce_length = 0;
383
384         if (pChal->nonce_plain != NULL) {
385                 free(pChal->nonce_plain);
386                 pChal->nonce_plain = NULL;
387         }
388
389         if (pChal->nonce_b64 != NULL) {
390                 free(pChal->nonce_b64);
391                 pChal->nonce_b64 = NULL;
392         }
393
394         if (pChal != NULL) {
395                 free(pChal);
396                 pChal = NULL;
397         }
398
399         _EXTERN_FUNC_EXIT;
400 }
401
402 Chal *dup_chal(Chal * pChal)
403 {
404         _EXTERN_FUNC_ENTER;
405
406         retvm_if((pChal) == NULL, NULL, "pChal is NULL!!");
407
408         Chal *temp = (Chal *) calloc(1, sizeof(Chal));
409         if (temp == NULL) {
410                 _EXTERN_FUNC_EXIT;
411                 return 0;
412         }
413
414         temp->type = pChal->type;
415         temp->format = pChal->format;
416
417         if (pChal->nonce_b64 != NULL)
418                 temp->nonce_b64 = strdup(pChal->nonce_b64);
419
420         if (pChal->nonce_length != 0)
421                 temp->nonce_length = pChal->nonce_length;
422
423         if (pChal->nonce_plain != NULL)
424                 temp->nonce_plain = strdup(pChal->nonce_plain);
425
426         _EXTERN_FUNC_EXIT;
427         return temp;
428 }
429
430 void free_hmac(Hmac * hmac)
431 {
432         _EXTERN_FUNC_ENTER;
433
434         if (hmac != NULL) {
435                 str_free(&(hmac->authtype));
436                 str_free(&(hmac->username));
437                 str_free(&(hmac->mac));
438
439                 free(hmac);
440                 hmac = NULL;
441         }
442
443         _EXTERN_FUNC_EXIT;
444 }
445
446 AuthType converttoauthtype(char *authType)
447 {
448         _EXTERN_FUNC_ENTER;
449
450         retvm_if((authType) == NULL, AUTH_TYPE_UNKNOWN, "authType is NULL!!");
451
452         if (strcmp(authType, ELEMENT_AUTH_BASIC) == 0) {
453                 _EXTERN_FUNC_EXIT;
454                 return AUTH_TYPE_BASIC;
455         } else if (strcmp(authType, ELEMENT_AUTH_MD5) == 0) {
456                 _EXTERN_FUNC_EXIT;
457                 return AUTH_TYPE_MD5;
458         } else if (strcmp(authType, ELEMENT_AUTH_HMAC) == 0) {
459                 _EXTERN_FUNC_EXIT;
460                 return AUTH_TYPE_HMAC;
461         }
462
463         _EXTERN_FUNC_EXIT;
464         return AUTH_TYPE_UNKNOWN;
465 }
466
467 FormatType converttoformattype(char *formatType)
468 {
469         _EXTERN_FUNC_ENTER;
470
471         retvm_if((formatType) == NULL, FORMAT_TYPE_UNKNOWN, "formatType is NULL!!");
472
473         if (strcmp(formatType, ELEMENT_FORMAT_BASE64) == 0) {
474                 _EXTERN_FUNC_EXIT;
475                 return FORMAT_TYPE_BASE64;
476         }
477
478         _EXTERN_FUNC_EXIT;
479         return FORMAT_TYPE_UNKNOWN;
480 }
481
482 DM_ERROR construct_Item(char *sourceUrl, const char *format, const char *contenttype, const char *data, unsigned int size, int moreData, Item ** pItem)
483 {
484         _EXTERN_FUNC_ENTER;
485
486         DM_ERROR ret = DM_OK;
487
488         retvm_if((sourceUrl) == NULL, COMMON_ERR_INTERNAL_NOT_DEFINED, "sourceUrl is NULL!!");
489
490         Location *pLocation = NULL;
491
492         ret = create_item_data((char *)data, size, pItem);
493         if (ret != DM_OK)
494                 goto error;
495
496         if (contenttype != NULL)
497                 (*pItem)->contenttype = g_strdup(contenttype);
498
499         if (format != NULL)
500                 (*pItem)->format = g_strdup(format);
501
502         (*pItem)->moreData = moreData;
503
504         ret = create_location(sourceUrl, NULL, &pLocation);
505         if (ret != DM_OK)
506                 goto error;
507
508         set_itemsource((*pItem), pLocation);
509
510         _EXTERN_FUNC_EXIT;
511         return ret;
512
513  error:
514         _DEBUG_INFO(" error : %d\n", ret);
515         _EXTERN_FUNC_EXIT;
516         return ret;
517 }
518
519 Item *create_Item()
520 {
521         _EXTERN_FUNC_ENTER;
522
523         DM_ERROR ret = DM_OK;
524
525         Item *item = (Item *) calloc(1, sizeof(Item));
526         if (item == NULL) {
527                 ret = COMMON_ERR_ALLOC;
528                 goto error;
529         }
530
531         item->dataType = ITEM_UNKNOWN;
532
533         _EXTERN_FUNC_EXIT;
534         return item;
535
536  error:
537         _DEBUG_INFO(" error : %d\n", ret);
538         _EXTERN_FUNC_EXIT;
539         return NULL;
540 }
541
542 DM_ERROR create_item_data(char *data, unsigned int size, Item ** pItem)
543 {
544         _EXTERN_FUNC_ENTER;
545
546         DM_ERROR ret = DM_OK;
547
548         (*pItem) = create_Item();
549         if ((*pItem) == NULL) {
550                 ret = COMMON_ERR_INTERNAL_NO_MEMORY;
551                 goto error;
552         }
553
554         if (data != NULL) {
555                 (*pItem)->private.data = strdup(data);
556         }
557
558         (*pItem)->dataType = ITEM_DATA;
559         (*pItem)->size = size;
560
561         _EXTERN_FUNC_EXIT;
562         return ret;
563  error:
564         _DEBUG_INFO(" error : %d\n", ret);
565         _EXTERN_FUNC_EXIT;
566         return ret;
567 }
568
569 void set_itemtarget(Item * item, Location * target)
570 {
571         _EXTERN_FUNC_ENTER;
572
573         retm_if((item) == NULL, "item is NULL!!");
574
575         item->target = target;
576
577         _EXTERN_FUNC_EXIT;
578 }
579
580 void set_itemsource(Item * item, Location * source)
581 {
582         _EXTERN_FUNC_ENTER;
583
584         retm_if((item) == NULL, "item is NULL!!");
585
586         item->source = source;
587
588         _EXTERN_FUNC_EXIT;
589 }
590
591 void free_Item(Item * item)
592 {
593         _EXTERN_FUNC_ENTER;
594
595         retm_if((item) == NULL, "item is NULL!!");
596
597         if (item->source != NULL) {
598                 free_location(item->source);
599                 item->source = NULL;
600         }
601
602         if (item->target != NULL) {
603                 free_location(item->target);
604                 item->target = NULL;
605         }
606
607         switch (item->dataType) {
608         case ITEM_DATA:
609                 if (item->private.data != NULL) {
610                         free(item->private.data);
611                         item->private.data = NULL;
612                 }
613                 break;
614         case ITEM_UNKNOWN:
615                 //noting to free
616                 break;
617         }
618
619         if (item->contenttype != NULL) {
620                 free(item->contenttype);
621                 item->contenttype = NULL;
622         }
623
624         if (item->format != NULL) {
625                 free(item->format);
626                 item->format = NULL;
627         }
628
629         free(item);
630         item = NULL;
631
632         _EXTERN_FUNC_EXIT;
633 }
634
635 DM_ERROR create_syncml(SyncHdr * syncHdr, GList * status, GList * commands, int isFinal, SyncML ** pSyncML)
636 {
637         _EXTERN_FUNC_ENTER;
638
639         DM_ERROR ret = DM_OK;
640
641         retvm_if((syncHdr) == NULL, COMMON_ERR_INTERNAL_NOT_DEFINED, "syncHdr is NULL!!");
642
643         *pSyncML = (SyncML *) calloc(1, sizeof(SyncML));
644         if (*pSyncML == NULL) {
645                 ret = COMMON_ERR_ALLOC;
646                 goto error;
647         }
648
649         (*pSyncML)->hdr = syncHdr;
650         (*pSyncML)->status = status;
651         (*pSyncML)->commands = commands;
652         (*pSyncML)->final = isFinal;
653
654         _EXTERN_FUNC_EXIT;
655         return ret;
656  error:
657         _DEBUG_INFO(" error : %d", ret);
658         _EXTERN_FUNC_EXIT;
659         return ret;
660
661 }
662
663 void free_syncml(SyncML * syncML)
664 {
665         _EXTERN_FUNC_ENTER;
666
667         retm_if((syncML) == NULL, "syncML is NULL!!");
668
669         free_synchdr(syncML->hdr);
670         syncML->hdr = NULL;
671
672         free_statuses(syncML->status);
673         syncML->status = NULL;
674
675         free_commands(syncML->commands);
676         syncML->commands = NULL;
677
678         if (syncML != NULL) {
679                 free(syncML);
680                 syncML = NULL;
681         }
682
683         _EXTERN_FUNC_EXIT;
684 }
685
686 DM_ERROR create_syncml_hdr(Session * session, SyncHdr ** pSyncHdr)
687 {
688         _EXTERN_FUNC_ENTER;
689
690         DM_ERROR ret = DM_OK;
691
692         retvm_if((session) == NULL, COMMON_ERR_INTERNAL_NOT_DEFINED, "session is NULL!!");
693
694         if (session->protocolVersion == VERSION_UNKNOWN) {
695                 ret = COMMON_ERR_INTERNAL_NOT_DEFINED;
696                 goto error;
697         }
698
699         if (session->protocolType != PROTOCOL_TYPE_DM) {
700                 ret = COMMON_ERR_INTERNAL_NOT_DEFINED;
701                 goto error;
702         }
703
704         if (session->source == NULL) {
705                 ret = COMMON_ERR_INTERNAL_NOT_DEFINED;
706                 goto error;
707         }
708
709         if (session->target == NULL) {
710                 ret = COMMON_ERR_INTERNAL_NOT_DEFINED;
711                 goto error;
712         }
713
714         *pSyncHdr = (SyncHdr *) calloc(1, sizeof(SyncHdr));
715
716         if (*pSyncHdr == NULL) {
717                 ret = COMMON_ERR_ALLOC;
718                 goto error;
719         }
720
721         (*pSyncHdr)->version = session->protocolVersion;
722         (*pSyncHdr)->protocol = session->protocolType;
723         (*pSyncHdr)->target = session->target;  //don't free    free in session free section
724         (*pSyncHdr)->source = session->source;  //don't free    free in session free section
725
726         if (session->cred != NULL)
727                 (*pSyncHdr)->cred = session->cred;      //don't free    free in session free section
728
729         (*pSyncHdr)->sessionID = strdup(session->sessionID);    //free
730         (*pSyncHdr)->messageID = ++session->msgID;
731
732         (*pSyncHdr)->maxmsgsize = session->sourceMaxMsgSize;
733         (*pSyncHdr)->maxobjsize = session->sourceMaxObjSize;
734
735         _EXTERN_FUNC_EXIT;
736         return ret;
737
738  error:
739         _DEBUG_INFO(" error : %d\n", ret);
740         _EXTERN_FUNC_EXIT;
741         return ret;
742 }
743
744 void free_synchdr(SyncHdr * syncHdr)
745 {
746         _EXTERN_FUNC_ENTER;
747
748         retm_if((syncHdr) == NULL, "syncHdr is NULL!!");
749
750         if (syncHdr->sessionID != NULL) {
751                 free(syncHdr->sessionID);
752                 syncHdr->sessionID = NULL;
753         }
754
755         if (syncHdr->responseURI != NULL) {
756                 free(syncHdr->responseURI);
757                 syncHdr->responseURI = NULL;
758         }
759
760         syncHdr->source = NULL;
761         syncHdr->target = NULL;
762         syncHdr->cred = NULL;
763
764         if (syncHdr != NULL) {
765                 free(syncHdr);
766                 syncHdr = NULL;
767         }
768
769         _EXTERN_FUNC_EXIT;
770 }