osip_www_authenticate.c
20 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
/*
The oSIP library implements the Session Initiation Protocol (SIP -rfc3261-)
Copyright (C) 2001-2020 Aymeric MOIZARD amoizard@antisip.com
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <osipparser2/internal.h>
#include <osipparser2/osip_port.h>
#include <osipparser2/osip_message.h>
#include <osipparser2/osip_parser.h>
#include "parser.h"
int osip_www_authenticate_init(osip_www_authenticate_t **dest) {
*dest = (osip_www_authenticate_t *) osip_malloc(sizeof(osip_www_authenticate_t));
if (*dest == NULL)
return OSIP_NOMEM;
memset(*dest, 0, sizeof(osip_www_authenticate_t));
return OSIP_SUCCESS;
}
/* fills the www-authenticate header of message. */
/* INPUT : char *hvalue | value of header. */
/* OUTPUT: osip_message_t *sip | structure to save results. */
/* returns -1 on error. */
int osip_message_set_www_authenticate(osip_message_t *sip, const char *hvalue) {
osip_www_authenticate_t *www_authenticate;
int i;
if (hvalue == NULL || hvalue[0] == '\0')
return OSIP_SUCCESS;
if (sip == NULL)
return OSIP_BADPARAMETER;
i = osip_www_authenticate_init(&www_authenticate);
if (i != 0)
return i;
i = osip_www_authenticate_parse(www_authenticate, hvalue);
if (i != 0) {
osip_www_authenticate_free(www_authenticate);
return i;
}
sip->message_property = 2;
osip_list_add(&sip->www_authenticates, www_authenticate, -1);
return OSIP_SUCCESS;
}
int __osip_quoted_string_set(const char *name, const char *str, char **result, const char **next) {
*next = str;
if (*result != NULL)
return OSIP_SUCCESS; /* already parsed */
*next = NULL;
while ((' ' == *str) || ('\t' == *str) || (',' == *str))
if (*str)
str++;
else
return OSIP_SYNTAXERROR; /* bad header format */
if (osip_strncasecmp(name, str, strlen(name)) == 0) {
const char *quote1;
const char *quote2;
const char *tmp;
const char *hack = strchr(str, '=');
if (hack == NULL)
return OSIP_SYNTAXERROR;
while (' ' == *(hack - 1)) /* get rid of extra spaces */
hack--;
if ((size_t)(hack - str) != strlen(name)) {
*next = str;
return OSIP_SUCCESS;
}
quote1 = __osip_quote_find(str);
if (quote1 == NULL)
return OSIP_SYNTAXERROR; /* bad header format... */
quote2 = __osip_quote_find(quote1 + 1);
if (quote2 == NULL)
return OSIP_SYNTAXERROR; /* bad header format... */
if (quote2 - quote1 == 1) {
/* this is a special case! The quote contains nothing! */
/* example: Digest opaque="",cnonce="" */
/* in this case, we just forget the parameter... this */
/* this should prevent from user manipulating empty */
/* strings */
tmp = quote2 + 1; /* next element start here */
tmp += strspn(tmp, " \t");
tmp += strspn(tmp, "\n\r");
*next = NULL;
if (*tmp == '\0') /* end of header detected */
return OSIP_SUCCESS;
if (*tmp != '\t' && *tmp != ' ')
/* LWS here ? */
*next = tmp;
else { /* it is: skip it... */
tmp += strspn(tmp, " \t");
if (*tmp == '\0') /* end of header detected */
return OSIP_SUCCESS;
*next = tmp;
}
return OSIP_SUCCESS;
}
*result = (char *) osip_malloc(quote2 - quote1 + 3);
if (*result == NULL)
return OSIP_NOMEM;
osip_strncpy(*result, quote1, quote2 - quote1 + 1);
tmp = quote2 + 1; /* next element start here */
tmp += strspn(tmp, " \t");
tmp += strspn(tmp, "\n\r");
*next = NULL;
if (*tmp == '\0') /* end of header detected */
return OSIP_SUCCESS;
if (*tmp != '\t' && *tmp != ' ')
/* LWS here ? */
*next = tmp;
else { /* it is: skip it... */
tmp += strspn(tmp, " \t");
if (*tmp == '\0') /* end of header detected */
return OSIP_SUCCESS;
*next = tmp;
}
} else
*next = str; /* wrong header asked! */
return OSIP_SUCCESS;
}
int __osip_token_set(const char *name, const char *str, char **result, const char **next) {
const char *beg;
const char *tmp;
*next = str;
if (*result != NULL)
return OSIP_SUCCESS; /* already parsed */
*next = NULL;
beg = strchr(str, '=');
if (beg == NULL)
return OSIP_SYNTAXERROR; /* bad header format... */
if (strlen(str) < 6)
return OSIP_SUCCESS; /* end of header... */
while ((' ' == *str) || ('\t' == *str) || (',' == *str))
if (*str)
str++;
else
return OSIP_SYNTAXERROR; /* bad header format */
if (osip_strncasecmp(name, str, strlen(name)) == 0) {
const char *end;
end = strchr(str, ',');
if (end == NULL)
end = str + strlen(str); /* This is the end of the header */
if (end - beg < 2)
return OSIP_SYNTAXERROR;
*result = (char *) osip_malloc(end - beg);
if (*result == NULL)
return OSIP_NOMEM;
osip_clrncpy(*result, beg + 1, end - beg - 1);
/* make sure the element does not contain more parameter */
tmp = (*end) ? (end + 1) : end;
tmp += strspn(tmp, " \t");
tmp += strspn(tmp, "\n\r");
*next = NULL;
if (*tmp == '\0') /* end of header detected */
return OSIP_SUCCESS;
if (*tmp != '\t' && *tmp != ' ')
/* LWS here ? */
*next = tmp;
else { /* it is: skip it... */
tmp += strspn(tmp, " \t");
if (*tmp == '\0') /* end of header detected */
return OSIP_SUCCESS;
*next = tmp;
}
} else
*next = str; /* next element start here */
return OSIP_SUCCESS;
}
/* fills the www-authenticate strucuture. */
/* INPUT : char *hvalue | value of header. */
/* OUTPUT: osip_message_t *sip | structure to save results. */
/* returns -1 on error. */
/* TODO:
digest-challenge tken has no order preference??
verify many situations (extra SP....)
*/
int osip_www_authenticate_parse(osip_www_authenticate_t *wwwa, const char *hvalue) {
const char *space;
const char *next = NULL;
int i;
space = strchr(hvalue, ' '); /* SEARCH FOR SPACE */
if (space == NULL)
return OSIP_SYNTAXERROR;
if (space - hvalue + 1 < 2)
return OSIP_SYNTAXERROR;
wwwa->auth_type = (char *) osip_malloc(space - hvalue + 1);
if (wwwa->auth_type == NULL)
return OSIP_NOMEM;
osip_strncpy(wwwa->auth_type, hvalue, space - hvalue);
for (;;) {
int parse_ok = 0;
i = __osip_quoted_string_set("realm", space, &(wwwa->realm), &next);
if (i != 0)
return i;
if (next == NULL)
return OSIP_SUCCESS; /* end of header detected! */
else if (next != space) {
space = next;
parse_ok++;
}
i = __osip_quoted_string_set("domain", space, &(wwwa->domain), &next);
if (i != 0)
return i;
if (next == NULL)
return OSIP_SUCCESS; /* end of header detected! */
else if (next != space) {
space = next;
parse_ok++;
}
i = __osip_quoted_string_set("nonce", space, &(wwwa->nonce), &next);
if (i != 0)
return i;
if (next == NULL)
return OSIP_SUCCESS; /* end of header detected! */
else if (next != space) {
space = next;
parse_ok++;
}
i = __osip_quoted_string_set("opaque", space, &(wwwa->opaque), &next);
if (i != 0)
return i;
if (next == NULL)
return OSIP_SUCCESS; /* end of header detected! */
else if (next != space) {
space = next;
parse_ok++;
}
i = __osip_token_set("stale", space, &(wwwa->stale), &next);
if (i != 0)
return i;
if (next == NULL)
return OSIP_SUCCESS; /* end of header detected! */
else if (next != space) {
space = next;
parse_ok++;
}
i = __osip_token_set("algorithm", space, &(wwwa->algorithm), &next);
if (i != 0)
return i;
if (next == NULL)
return OSIP_SUCCESS; /* end of header detected! */
else if (next != space) {
space = next;
parse_ok++;
}
i = __osip_quoted_string_set("qop", space, &(wwwa->qop_options), &next);
if (i != 0)
return i;
if (next == NULL)
return OSIP_SUCCESS; /* end of header detected! */
else if (next != space) {
space = next;
parse_ok++;
}
i = __osip_token_set("version", space, &(wwwa->version), &next);
if (i != 0)
return i;
if (next == NULL)
return OSIP_SUCCESS; /* end of header detected! */
else if (next != space) {
space = next;
parse_ok++;
}
i = __osip_quoted_string_set("targetname", space, &(wwwa->targetname), &next);
if (i != 0)
return i;
if (next == NULL)
return OSIP_SUCCESS; /* end of header detected! */
else if (next != space) {
space = next;
parse_ok++;
}
i = __osip_quoted_string_set("gssapi-data", space, &(wwwa->gssapi_data), &next);
if (i != 0)
return i;
if (next == NULL)
return OSIP_SUCCESS; /* end of header detected! */
else if (next != space) {
space = next;
parse_ok++;
}
if (0 == parse_ok) {
const char *quote1, *quote2, *tmp;
/* CAUTION */
/* parameter not understood!!! I'm too lazy to handle IT */
/* let's simply bypass it */
if (strlen(space) < 1)
return OSIP_SUCCESS;
tmp = strchr(space + 1, ',');
if (tmp == NULL) /* it was the last header */
return OSIP_SUCCESS;
quote1 = __osip_quote_find(space);
if ((quote1 != NULL) && (quote1 < tmp)) { /* this may be a quoted string! */
quote2 = __osip_quote_find(quote1 + 1);
if (quote2 == NULL)
return OSIP_SYNTAXERROR; /* bad header format... */
if (tmp < quote2) /* the comma is inside the quotes! */
space = strchr(quote2, ',');
else
space = tmp;
if (space == NULL) /* it was the last header */
return OSIP_SUCCESS;
} else
space = tmp;
/* continue parsing... */
}
}
return OSIP_SUCCESS; /* ok */
}
#ifndef MINISIZE
/* returns the www_authenticate header. */
/* INPUT : osip_message_t *sip | sip message. */
/* returns null on error. */
int osip_message_get_www_authenticate(const osip_message_t *sip, int pos, osip_www_authenticate_t **dest) {
osip_www_authenticate_t *www_authenticate;
*dest = NULL;
if (osip_list_size(&sip->www_authenticates) <= pos)
return OSIP_UNDEFINED_ERROR; /* does not exist */
www_authenticate = (osip_www_authenticate_t *) osip_list_get(&sip->www_authenticates, pos);
*dest = www_authenticate;
return pos;
}
#endif
char *osip_www_authenticate_get_auth_type(osip_www_authenticate_t *www_authenticate) {
return www_authenticate->auth_type;
}
void osip_www_authenticate_set_auth_type(osip_www_authenticate_t *www_authenticate, char *auth_type) {
www_authenticate->auth_type = (char *) auth_type;
}
char *osip_www_authenticate_get_realm(osip_www_authenticate_t *www_authenticate) {
return www_authenticate->realm;
}
void osip_www_authenticate_set_realm(osip_www_authenticate_t *www_authenticate, char *realm) {
www_authenticate->realm = (char *) realm;
}
char *osip_www_authenticate_get_domain(osip_www_authenticate_t *www_authenticate) {
return www_authenticate->domain;
}
void osip_www_authenticate_set_domain(osip_www_authenticate_t *www_authenticate, char *domain) {
www_authenticate->domain = (char *) domain;
}
char *osip_www_authenticate_get_nonce(osip_www_authenticate_t *www_authenticate) {
return www_authenticate->nonce;
}
void osip_www_authenticate_set_nonce(osip_www_authenticate_t *www_authenticate, char *nonce) {
www_authenticate->nonce = (char *) nonce;
}
char *osip_www_authenticate_get_stale(osip_www_authenticate_t *www_authenticate) {
return www_authenticate->stale;
}
void osip_www_authenticate_set_stale(osip_www_authenticate_t *www_authenticate, char *stale) {
www_authenticate->stale = (char *) stale;
}
char *osip_www_authenticate_get_opaque(osip_www_authenticate_t *www_authenticate) {
return www_authenticate->opaque;
}
void osip_www_authenticate_set_opaque(osip_www_authenticate_t *www_authenticate, char *opaque) {
www_authenticate->opaque = (char *) opaque;
}
char *osip_www_authenticate_get_algorithm(osip_www_authenticate_t *www_authenticate) {
return www_authenticate->algorithm;
}
void osip_www_authenticate_set_algorithm(osip_www_authenticate_t *www_authenticate, char *algorithm) {
www_authenticate->algorithm = (char *) algorithm;
}
char *osip_www_authenticate_get_qop_options(osip_www_authenticate_t *www_authenticate) {
return www_authenticate->qop_options;
}
void osip_www_authenticate_set_qop_options(osip_www_authenticate_t *www_authenticate, char *qop_options) {
www_authenticate->qop_options = (char *) qop_options;
}
char *osip_www_authenticate_get_version(osip_www_authenticate_t *www_authenticate) {
return www_authenticate->version;
}
void osip_www_authenticate_set_version(osip_www_authenticate_t *www_authenticate, char *version) {
www_authenticate->version = (char *) version;
}
char *osip_www_authenticate_get_targetname(osip_www_authenticate_t *www_authenticate) {
return www_authenticate->targetname;
}
void osip_www_authenticate_set_targetname(osip_www_authenticate_t *www_authenticate, char *targetname) {
www_authenticate->targetname = (char *) targetname;
}
char *osip_www_authenticate_get_gssapi_data(osip_www_authenticate_t *www_authenticate) {
return www_authenticate->gssapi_data;
}
void osip_www_authenticate_set_gssapi_data(osip_www_authenticate_t *www_authenticate, char *gssapi_data) {
www_authenticate->gssapi_data = (char *) gssapi_data;
}
/* returns the www_authenticate header as a string. */
/* INPUT : osip_www_authenticate_t *www_authenticate | www_authenticate header. */
/* returns null on error. */
int osip_www_authenticate_to_str(const osip_www_authenticate_t *wwwa, char **dest) {
size_t len;
char *tmp;
*dest = NULL;
if ((wwwa == NULL) || (wwwa->auth_type == NULL))
return OSIP_BADPARAMETER;
len = strlen(wwwa->auth_type) + 1;
if (wwwa->realm != NULL)
len = len + strlen(wwwa->realm) + 7;
if (wwwa->nonce != NULL)
len = len + strlen(wwwa->nonce) + 8;
len = len + 2;
if (wwwa->domain != NULL)
len = len + strlen(wwwa->domain) + 9;
if (wwwa->opaque != NULL)
len = len + strlen(wwwa->opaque) + 9;
if (wwwa->stale != NULL)
len = len + strlen(wwwa->stale) + 8;
if (wwwa->algorithm != NULL)
len = len + strlen(wwwa->algorithm) + 12;
if (wwwa->qop_options != NULL)
len = len + strlen(wwwa->qop_options) + 6;
if (wwwa->version != NULL)
len = len + strlen(wwwa->version) + 10;
if (wwwa->targetname != NULL)
len = len + strlen(wwwa->targetname) + 13;
if (wwwa->gssapi_data != NULL)
len = len + strlen(wwwa->gssapi_data) + 14;
tmp = (char *) osip_malloc(len);
if (tmp == NULL)
return OSIP_NOMEM;
*dest = tmp;
tmp = osip_str_append(tmp, wwwa->auth_type);
if (wwwa->realm != NULL) {
tmp = osip_strn_append(tmp, " realm=", 7);
tmp = osip_str_append(tmp, wwwa->realm);
}
if (wwwa->domain != NULL) {
tmp = osip_strn_append(tmp, ", domain=", 9);
tmp = osip_str_append(tmp, wwwa->domain);
}
if (wwwa->nonce != NULL) {
tmp = osip_strn_append(tmp, ", nonce=", 8);
tmp = osip_str_append(tmp, wwwa->nonce);
}
if (wwwa->opaque != NULL) {
tmp = osip_strn_append(tmp, ", opaque=", 9);
tmp = osip_str_append(tmp, wwwa->opaque);
}
if (wwwa->stale != NULL) {
tmp = osip_strn_append(tmp, ", stale=", 8);
tmp = osip_str_append(tmp, wwwa->stale);
}
if (wwwa->algorithm != NULL) {
tmp = osip_strn_append(tmp, ", algorithm=", 12);
tmp = osip_str_append(tmp, wwwa->algorithm);
}
if (wwwa->qop_options != NULL) {
tmp = osip_strn_append(tmp, ", qop=", 6);
tmp = osip_str_append(tmp, wwwa->qop_options);
}
if (wwwa->version != NULL) {
tmp = osip_strn_append(tmp, ", version=", 10);
tmp = osip_str_append(tmp, wwwa->version);
}
if (wwwa->targetname != NULL) {
tmp = osip_strn_append(tmp, ", targetname=", 13);
tmp = osip_str_append(tmp, wwwa->targetname);
}
if (wwwa->gssapi_data != NULL) {
tmp = osip_strn_append(tmp, ", gssapi-data=", 14);
tmp = osip_str_append(tmp, wwwa->gssapi_data);
}
if (wwwa->realm == NULL) {
/* remove comma */
len = strlen(wwwa->auth_type);
if ((*dest)[len] == ',')
(*dest)[len] = ' ';
}
return OSIP_SUCCESS;
}
/* deallocates a osip_www_authenticate_t structure. */
/* INPUT : osip_www_authenticate_t *www_authenticate | www_authenticate. */
void osip_www_authenticate_free(osip_www_authenticate_t *www_authenticate) {
if (www_authenticate == NULL)
return;
osip_free(www_authenticate->auth_type);
osip_free(www_authenticate->realm);
osip_free(www_authenticate->domain);
osip_free(www_authenticate->nonce);
osip_free(www_authenticate->opaque);
osip_free(www_authenticate->stale);
osip_free(www_authenticate->algorithm);
osip_free(www_authenticate->qop_options);
osip_free(www_authenticate->version);
osip_free(www_authenticate->targetname);
osip_free(www_authenticate->gssapi_data);
osip_free(www_authenticate);
}
int osip_www_authenticate_clone(const osip_www_authenticate_t *wwwa, osip_www_authenticate_t **dest) {
int i;
osip_www_authenticate_t *wa;
*dest = NULL;
if (wwwa == NULL)
return OSIP_BADPARAMETER;
if (wwwa->auth_type == NULL)
return OSIP_BADPARAMETER;
i = osip_www_authenticate_init(&wa);
if (i != 0) /* allocation failed */
return i;
wa->auth_type = osip_strdup(wwwa->auth_type);
if (wa->auth_type == NULL && wwwa->auth_type != NULL) {
osip_www_authenticate_free(wa);
return OSIP_NOMEM;
}
if (wwwa->realm != NULL)
wa->realm = osip_strdup(wwwa->realm);
if (wa->realm == NULL && wwwa->realm != NULL) {
osip_www_authenticate_free(wa);
return OSIP_NOMEM;
}
if (wwwa->domain != NULL)
wa->domain = osip_strdup(wwwa->domain);
if (wa->domain == NULL && wwwa->domain != NULL) {
osip_www_authenticate_free(wa);
return OSIP_NOMEM;
}
if (wwwa->nonce != NULL)
wa->nonce = osip_strdup(wwwa->nonce);
if (wa->nonce == NULL && wwwa->nonce != NULL) {
osip_www_authenticate_free(wa);
return OSIP_NOMEM;
}
if (wwwa->opaque != NULL)
wa->opaque = osip_strdup(wwwa->opaque);
if (wa->opaque == NULL && wwwa->opaque != NULL) {
osip_www_authenticate_free(wa);
return OSIP_NOMEM;
}
if (wwwa->stale != NULL)
wa->stale = osip_strdup(wwwa->stale);
if (wa->stale == NULL && wwwa->stale != NULL) {
osip_www_authenticate_free(wa);
return OSIP_NOMEM;
}
if (wwwa->algorithm != NULL)
wa->algorithm = osip_strdup(wwwa->algorithm);
if (wa->algorithm == NULL && wwwa->algorithm != NULL) {
osip_www_authenticate_free(wa);
return OSIP_NOMEM;
}
if (wwwa->qop_options != NULL)
wa->qop_options = osip_strdup(wwwa->qop_options);
if (wa->qop_options == NULL && wwwa->qop_options != NULL) {
osip_www_authenticate_free(wa);
return OSIP_NOMEM;
}
if (wwwa->version != NULL)
wa->version = osip_strdup(wwwa->version);
if (wa->version == NULL && wwwa->version != NULL) {
osip_www_authenticate_free(wa);
return OSIP_NOMEM;
}
if (wwwa->targetname != NULL)
wa->targetname = osip_strdup(wwwa->targetname);
if (wa->targetname == NULL && wwwa->targetname != NULL) {
osip_www_authenticate_free(wa);
return OSIP_NOMEM;
}
if (wwwa->gssapi_data != NULL)
wa->gssapi_data = osip_strdup(wwwa->gssapi_data);
if (wa->gssapi_data == NULL && wwwa->gssapi_data != NULL) {
osip_www_authenticate_free(wa);
return OSIP_NOMEM;
}
*dest = wa;
return OSIP_SUCCESS;
}