Line data Source code
1 : /* tst_badutf8.c --- Self tests for malformed UTF-8 regressions. 2 : * Copyright (C) 2015-2020 Simon Josefsson 3 : * 4 : * This file is part of GNU Libidn. 5 : * 6 : * This program is free software: you can redistribute it and/or modify 7 : * it under the terms of the GNU General Public License as published by 8 : * the Free Software Foundation, either version 3 of the License, or 9 : * (at your option) any later version. 10 : * 11 : * This program is distributed in the hope that it will be useful, 12 : * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 : * GNU General Public License for more details. 15 : * 16 : * You should have received a copy of the GNU General Public License 17 : * along with this program. If not, see <http://www.gnu.org/licenses/>. 18 : * 19 : */ 20 : 21 : #ifdef HAVE_CONFIG_H 22 : # include "config.h" 23 : #endif 24 : 25 : #include <stdio.h> 26 : #include <stdlib.h> 27 : #include <stdarg.h> 28 : #include <string.h> 29 : 30 : #include <idna.h> 31 : #include <idn-free.h> 32 : 33 : #include "utils.h" 34 : 35 : void 36 1 : doit (void) 37 : { 38 1 : char *badutf8 = strdup ("\x7e\x64\x61\x72\x10\x2f\x2f\xf9\x2b\x71" 39 : "\x60\x79\x7b\x2e\x63\x75\x2b\x61\x65\x72" 40 : "\x75\x65\x56\x66\x7f\x62\xc5\x76\xe5\x00"); 41 1 : char *s = NULL; 42 : int rc; 43 : 44 1 : rc = idna_to_ascii_8z (badutf8, &s, 0); 45 1 : free (badutf8); 46 1 : if (rc != IDNA_ICONV_ERROR) 47 0 : fail ("rc %d\n", rc); 48 : 49 1 : idn_free (s); 50 1 : }