Mercurial > hg > freeDiameter
comparison libfdproto/ostr.c @ 1561:699c3fb0c57b
Switch from libidn to libidn2.
libidn2 is the backwards compatible successor to libidn,
and at least Red Hat 8 does not provide a dev package for libidn1.
author | Thomas Klausner <wiz@gatalith.at> |
---|---|
date | Wed, 16 Jun 2021 18:44:45 +0200 |
parents | 1af09cc156d6 |
children |
comparison
equal
deleted
inserted
replaced
1560:9084c6f94a0a | 1561:699c3fb0c57b |
---|---|
34 *********************************************************************************************************/ | 34 *********************************************************************************************************/ |
35 | 35 |
36 #include "fdproto-internal.h" | 36 #include "fdproto-internal.h" |
37 | 37 |
38 #if (!defined(DIAMID_IDNA_IGNORE) && !defined(DIAMID_IDNA_REJECT)) | 38 #if (!defined(DIAMID_IDNA_IGNORE) && !defined(DIAMID_IDNA_REJECT)) |
39 /* Process IDNA with stringprep -- See RFC5890 -- and libidn documentation... */ | 39 /* Process IDNA with stringprep -- See RFC5890 -- and libidn2 documentation... */ |
40 #include <idna.h> /* idna_to_ascii_8z() */ | 40 #include <idn2.h> /* idn2_to_ascii_8z() */ |
41 #endif /* !defined(DIAMID_IDNA_IGNORE) && !defined(DIAMID_IDNA_REJECT) */ | 41 #endif /* !defined(DIAMID_IDNA_IGNORE) && !defined(DIAMID_IDNA_REJECT) */ |
42 | 42 |
43 /* Similar to strdup with (must have been verified) os0_t */ | 43 /* Similar to strdup with (must have been verified) os0_t */ |
44 os0_t os0dup_int(os0_t s, size_t l) { | 44 os0_t os0dup_int(os0_t s, size_t l) { |
45 os0_t r; | 45 os0_t r; |
224 CHECK_MALLOC( *id = realloc(*id, *inoutsz + 1) ); | 224 CHECK_MALLOC( *id = realloc(*id, *inoutsz + 1) ); |
225 (*id)[*inoutsz] = '0'; | 225 (*id)[*inoutsz] = '0'; |
226 } | 226 } |
227 } | 227 } |
228 | 228 |
229 ret = idna_to_ascii_8z ( *id, &processed, IDNA_USE_STD3_ASCII_RULES ); | 229 ret = idn2_to_ascii_8z ( *id, &processed, IDNA_USE_STD3_ASCII_RULES ); |
230 if (ret == IDNA_SUCCESS) { | 230 if (ret == IDN2_OK) { |
231 TRACE_DEBUG(INFO, "The string '%s' is not a valid DiameterIdentity, it was changed to '%s'", *id, processed); | 231 TRACE_DEBUG(INFO, "The string '%s' is not a valid DiameterIdentity, it was changed to '%s'", *id, processed); |
232 if (memory == 0) | 232 if (memory == 0) |
233 free(*id); | 233 free(*id); |
234 *id = processed; | 234 *id = processed; |
235 *inoutsz = strlen(processed); | 235 *inoutsz = strlen(processed); |
236 /* Done! */ | 236 /* Done! */ |
237 } else { | 237 } else { |
238 TRACE_DEBUG(INFO, "The string '%s' is not a valid DiameterIdentity and cannot be sanitanized: %s", *id, idna_strerror (ret)); | 238 TRACE_DEBUG(INFO, "The string '%s' is not a valid DiameterIdentity and cannot be sanitized: %s", *id, idn2_strerror (ret)); |
239 return EINVAL; | 239 return EINVAL; |
240 } | 240 } |
241 | 241 |
242 #endif /* DIAMID_IDNA_REJECT */ | 242 #endif /* DIAMID_IDNA_REJECT */ |
243 } else | 243 } else |