LLVMFuzzerTestOneInput:
   35|    543|int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
   36|    543|  char *s = fuzz_strdup(data, size);
   37|    543|  lien_adrfil *af = calloct(1, sizeof(*af));
  ------------------
  |  |  723|    543|#define calloct(A, B) calloc((A), (B))
  ------------------
   38|       |  /* fil_simplifie rewrites in place and may grow an empty path to "./" */
   39|    543|  char *path = malloct(size + 3);
  ------------------
  |  |  719|    543|#define malloct(A) malloc(A)
  ------------------
   40|       |
   41|    543|  (void) ident_url_absolute(s, af);
   42|    543|  memcpy(path, s, size + 1);
   43|    543|  fil_simplifie(path);
   44|       |
   45|    543|  freet(path);
  ------------------
  |  |  730|    543|  do {                                                                         \
  |  |  731|    543|    if ((A) != NULL) {                                                         \
  |  |  ------------------
  |  |  |  Branch (731:9): [True: 543, False: 0]
  |  |  ------------------
  |  |  732|    543|      free(A);                                                                 \
  |  |  733|    543|      (A) = NULL;                                                              \
  |  |  734|    543|    }                                                                          \
  |  |  735|    543|  } while (0)
  |  |  ------------------
  |  |  |  Branch (735:12): [Folded, False: 543]
  |  |  ------------------
  ------------------
   46|    543|  freet(af);
  ------------------
  |  |  730|    543|  do {                                                                         \
  |  |  731|    543|    if ((A) != NULL) {                                                         \
  |  |  ------------------
  |  |  |  Branch (731:9): [True: 543, False: 0]
  |  |  ------------------
  |  |  732|    543|      free(A);                                                                 \
  |  |  733|    543|      (A) = NULL;                                                              \
  |  |  734|    543|    }                                                                          \
  |  |  735|    543|  } while (0)
  |  |  ------------------
  |  |  |  Branch (735:12): [Folded, False: 543]
  |  |  ------------------
  ------------------
   47|       |  freet(s);
  ------------------
  |  |  730|    543|  do {                                                                         \
  |  |  731|    543|    if ((A) != NULL) {                                                         \
  |  |  ------------------
  |  |  |  Branch (731:9): [True: 543, False: 0]
  |  |  ------------------
  |  |  732|    543|      free(A);                                                                 \
  |  |  733|    543|      (A) = NULL;                                                              \
  |  |  734|    543|    }                                                                          \
  |  |  735|    543|  } while (0)
  |  |  ------------------
  |  |  |  Branch (735:12): [Folded, False: 543]
  |  |  ------------------
  ------------------
   48|    543|  return 0;
   49|    543|}

fuzz-url.c:fuzz_strdup:
   41|    543|HTS_UNUSED static char *fuzz_strdup(const uint8_t *data, size_t size) {
   42|    543|  char *s = malloct(size + 1);
  ------------------
  |  |  719|    543|#define malloct(A) malloc(A)
  ------------------
   43|       |
   44|    543|  memcpy(s, data, size);
   45|    543|  s[size] = '\0';
   46|    543|  return s;
   47|    543|}

ident_url_absolute:
 3423|    543|int ident_url_absolute(const char *url, lien_adrfil *adrfil) {
 3424|    543|  int pos = 0;
 3425|    543|  int scheme = 0;
 3426|       |
 3427|       |  // effacer adrfil->adr et adrfil->fil
 3428|    543|  adrfil->adr[0] = adrfil->fil[0] = '\0';
 3429|       |
 3430|       |  // Reject an over-long URL: a root-relative path is copied whole into fil[].
 3431|    543|  if (strlen(url) >= HTS_URLMAXSIZE * 2)
  ------------------
  |  |  263|    543|#define HTS_URLMAXSIZE 1024
  ------------------
  |  Branch (3431:7): [True: 9, False: 534]
  ------------------
 3432|      9|    return -1;
 3433|       |
 3434|       |#if HDEBUG
 3435|       |  printf("protocol: %s\n", url);
 3436|       |#endif
 3437|       |
 3438|       |  // Scheme?
 3439|    534|  {
 3440|    534|    const char *a = url;
 3441|       |
 3442|    534|    while(isalpha((unsigned char) *a))
  ------------------
  |  Branch (3442:11): [True: 1.37k, False: 534]
  ------------------
 3443|  1.37k|      a++;
 3444|    534|    if (*a == ':')
  ------------------
  |  Branch (3444:9): [True: 152, False: 382]
  ------------------
 3445|    152|      scheme = 1;
 3446|    534|  }
 3447|       |
 3448|       |  // 1. optional scheme ":"
 3449|    534|  if ((pos = strfield(url, "file:"))) { // fichier local!! (pour les tests)
  ------------------
  |  Branch (3449:7): [True: 113, False: 421]
  ------------------
 3450|       |    //!!p+=3;
 3451|    113|    strcpybuff(adrfil->adr, "file://");
  ------------------
  |  |  272|    113|  __builtin_choose_expr(HTS_IS_CHAR_BUFFER(A),                                 \
  |  |  ------------------
  |  |  |  |  132|    113|  (__builtin_types_compatible_p(__typeof__(VAR), char[]))
  |  |  ------------------
  |  |  273|    113|                        strcpy_safe_(A, sizeof(A), B, HTS_SIZEOF_SRC_(B),      \
  |  |  ------------------
  |  |  |  |  144|    113|  (HTS_IS_NOT_CHAR_BUFFER(B) ? (size_t) -1 : sizeof(__typeof__(B)))
  |  |  |  |  ------------------
  |  |  |  |  |  |  138|    113|#define HTS_IS_NOT_CHAR_BUFFER(VAR) (!HTS_IS_CHAR_BUFFER(VAR))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  132|    113|  (__builtin_types_compatible_p(__typeof__(VAR), char[]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (138:37): [Folded, False: 113]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  274|    113|                                     "overflow while copying '" #B "' to '" #A \
  |  |  275|    113|                                     "'",                                      \
  |  |  276|    113|                                     __FILE__, __LINE__),                      \
  |  |  277|    113|                        strcpybuff_ptr_((A), (B)))
  ------------------
 3452|    421|  } else if ((pos = strfield(url, "http:"))) {  // HTTP
  ------------------
  |  Branch (3452:14): [True: 1, False: 420]
  ------------------
 3453|       |    //!!p+=3;
 3454|    420|  } else if ((pos = strfield(url, "ftp:"))) {   // FTP
  ------------------
  |  Branch (3454:14): [True: 36, False: 384]
  ------------------
 3455|     36|    strcpybuff(adrfil->adr, "ftp://");  // FTP!!
  ------------------
  |  |  272|     36|  __builtin_choose_expr(HTS_IS_CHAR_BUFFER(A),                                 \
  |  |  ------------------
  |  |  |  |  132|     36|  (__builtin_types_compatible_p(__typeof__(VAR), char[]))
  |  |  ------------------
  |  |  273|     36|                        strcpy_safe_(A, sizeof(A), B, HTS_SIZEOF_SRC_(B),      \
  |  |  ------------------
  |  |  |  |  144|     36|  (HTS_IS_NOT_CHAR_BUFFER(B) ? (size_t) -1 : sizeof(__typeof__(B)))
  |  |  |  |  ------------------
  |  |  |  |  |  |  138|     36|#define HTS_IS_NOT_CHAR_BUFFER(VAR) (!HTS_IS_CHAR_BUFFER(VAR))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  132|     36|  (__builtin_types_compatible_p(__typeof__(VAR), char[]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (138:37): [Folded, False: 36]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  274|     36|                                     "overflow while copying '" #B "' to '" #A \
  |  |  275|     36|                                     "'",                                      \
  |  |  276|     36|                                     __FILE__, __LINE__),                      \
  |  |  277|     36|                        strcpybuff_ptr_((A), (B)))
  ------------------
 3456|       |    //!!p+=3;
 3457|       |#if HTS_USEOPENSSL
 3458|       |  } else if ((pos = strfield(url, "https:"))) {     // HTTPS
 3459|       |    strcpybuff(adrfil->adr, "https://");
 3460|       |#endif
 3461|    384|  } else if (scheme) {
  ------------------
  |  Branch (3461:14): [True: 2, False: 382]
  ------------------
 3462|      2|    return -1;                  // erreur non reconnu
 3463|      2|  } else
 3464|    382|    pos = 0;
 3465|       |
 3466|       |  // 2. optional "//" authority
 3467|    532|  if (strncmp(url + pos, "//", 2) == 0)
  ------------------
  |  Branch (3467:7): [True: 51, False: 481]
  ------------------
 3468|     51|    pos += 2;
 3469|       |
 3470|       |  // (url+pos) now points to the path (not net path)
 3471|       |
 3472|       |  //## if (adrfil->adr[0]!=lOCAL_CHAR) {    // adrfil->adresse normale http
 3473|    532|  if (!strfield(adrfil->adr, "file:")) {        // PAS adrfil->file://
  ------------------
  |  Branch (3473:7): [True: 419, False: 113]
  ------------------
 3474|    419|    const char *p, *q;
 3475|       |
 3476|    419|    p = url + pos;
 3477|       |
 3478|       |    // p pointe sur le début de l'adrfil->adresse, ex: www.truc.fr/sommaire/index.html
 3479|    419|    q = strchr(jump_identification_const(p), '/');
 3480|    419|    if (q == 0)
  ------------------
  |  Branch (3480:9): [True: 290, False: 129]
  ------------------
 3481|    290|      q = strchr(jump_identification_const(p), '?');  // http://www.foo.com?bar=1
 3482|    419|    if (q == 0)
  ------------------
  |  Branch (3482:9): [True: 250, False: 169]
  ------------------
 3483|    250|      q = p + strlen(p);        // pointe sur \0
 3484|       |    // q pointe sur le chemin, ex: index.html?query=recherche
 3485|       |
 3486|       |    // chemin www... trop long!!
 3487|    419|    if ((((int) (q - p))) > HTS_URLMAXSIZE) {
  ------------------
  |  |  263|    419|#define HTS_URLMAXSIZE 1024
  ------------------
  |  Branch (3487:9): [True: 2, False: 417]
  ------------------
 3488|      2|      return -1;                // erreur
 3489|      2|    }
 3490|       |    // recopier adrfil->adresse www..
 3491|    417|    strncatbuff(adrfil->adr, p, ((int) (q - p)));
  ------------------
  |  |  232|    417|  __builtin_choose_expr(HTS_IS_CHAR_BUFFER(A),                                 \
  |  |  ------------------
  |  |  |  |  132|    417|  (__builtin_types_compatible_p(__typeof__(VAR), char[]))
  |  |  ------------------
  |  |  233|    417|                        strncat_safe_(A, sizeof(A), B, HTS_SIZEOF_SRC_(B), N,  \
  |  |  ------------------
  |  |  |  |  144|    417|  (HTS_IS_NOT_CHAR_BUFFER(B) ? (size_t) -1 : sizeof(__typeof__(B)))
  |  |  |  |  ------------------
  |  |  |  |  |  |  138|    417|#define HTS_IS_NOT_CHAR_BUFFER(VAR) (!HTS_IS_CHAR_BUFFER(VAR))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  132|    417|  (__builtin_types_compatible_p(__typeof__(VAR), char[]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (138:37): [True: 417, Folded]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  234|    417|                                      "overflow while appending '" #B          \
  |  |  235|    417|                                      "' to '" #A "'",                         \
  |  |  236|    417|                                      __FILE__, __LINE__),                     \
  |  |  237|    417|                        strncatbuff_ptr_((A), (B), (N)))
  ------------------
 3492|       |    // *( adrfil->adr+( ((int) q) - ((int) p) ) )=0;  // faut arrêter la fumette!
 3493|       |
 3494|       |    // fil[] holds the path plus a possible leading '/' the top strlen() misses.
 3495|    417|    if (strlen(q) >= sizeof(adrfil->fil) - (q[0] != '/' ? 1 : 0))
  ------------------
  |  Branch (3495:9): [True: 3, False: 414]
  |  Branch (3495:45): [True: 288, False: 129]
  ------------------
 3496|      3|      return -1;
 3497|       |
 3498|       |    // recopier chemin /pub/..
 3499|    414|    if (q[0] != '/')            // page par défaut (/)
  ------------------
  |  Branch (3499:9): [True: 285, False: 129]
  ------------------
 3500|    285|      strcatbuff(adrfil->fil, "/");
  ------------------
  |  |  252|    285|  __builtin_choose_expr(                                                       \
  |  |  253|    285|      HTS_IS_CHAR_BUFFER(A),                                                   \
  |  |  ------------------
  |  |  |  |  132|    285|  (__builtin_types_compatible_p(__typeof__(VAR), char[]))
  |  |  ------------------
  |  |  254|    285|      strncat_safe_(A, sizeof(A), B, HTS_SIZEOF_SRC_(B), (size_t) -1,          \
  |  |  ------------------
  |  |  |  |  144|    285|  (HTS_IS_NOT_CHAR_BUFFER(B) ? (size_t) -1 : sizeof(__typeof__(B)))
  |  |  |  |  ------------------
  |  |  |  |  |  |  138|    285|#define HTS_IS_NOT_CHAR_BUFFER(VAR) (!HTS_IS_CHAR_BUFFER(VAR))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  132|    285|  (__builtin_types_compatible_p(__typeof__(VAR), char[]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (138:37): [Folded, False: 285]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  255|    285|                    "overflow while appending '" #B "' to '" #A "'", __FILE__, \
  |  |  256|       |                    __LINE__),                                                 \
  |  |  257|    285|      strcatbuff_ptr_((A), (B)))
  ------------------
 3501|    414|    strcatbuff(adrfil->fil, q);
  ------------------
  |  |  252|    414|  __builtin_choose_expr(                                                       \
  |  |  253|    414|      HTS_IS_CHAR_BUFFER(A),                                                   \
  |  |  ------------------
  |  |  |  |  132|    414|  (__builtin_types_compatible_p(__typeof__(VAR), char[]))
  |  |  ------------------
  |  |  254|    414|      strncat_safe_(A, sizeof(A), B, HTS_SIZEOF_SRC_(B), (size_t) -1,          \
  |  |  ------------------
  |  |  |  |  144|    414|  (HTS_IS_NOT_CHAR_BUFFER(B) ? (size_t) -1 : sizeof(__typeof__(B)))
  |  |  |  |  ------------------
  |  |  |  |  |  |  138|    414|#define HTS_IS_NOT_CHAR_BUFFER(VAR) (!HTS_IS_CHAR_BUFFER(VAR))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  132|    414|  (__builtin_types_compatible_p(__typeof__(VAR), char[]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (138:37): [True: 414, Folded]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  255|    414|                    "overflow while appending '" #B "' to '" #A "'", __FILE__, \
  |  |  256|       |                    __LINE__),                                                 \
  |  |  257|    414|      strcatbuff_ptr_((A), (B)))
  ------------------
 3502|       |    // SECURITE:
 3503|       |    // simplifier url pour les ../
 3504|    414|    fil_simplifie(adrfil->fil);
 3505|    414|  } else {                      // localhost adrfil->file://
 3506|    113|    const char *p;
 3507|    113|    size_t i;
 3508|    113|    char *a;
 3509|       |
 3510|    113|    p = url + pos;
 3511|    113|    if (*p == '/' || *p == '\\') {      /* adrfil->file:///.. */
  ------------------
  |  Branch (3511:9): [True: 9, False: 104]
  |  Branch (3511:22): [True: 17, False: 87]
  ------------------
 3512|     26|      strcatbuff(adrfil->fil, p);       // fichier local ; adrfil->adr="#"
  ------------------
  |  |  252|     26|  __builtin_choose_expr(                                                       \
  |  |  253|     26|      HTS_IS_CHAR_BUFFER(A),                                                   \
  |  |  ------------------
  |  |  |  |  132|     26|  (__builtin_types_compatible_p(__typeof__(VAR), char[]))
  |  |  ------------------
  |  |  254|     26|      strncat_safe_(A, sizeof(A), B, HTS_SIZEOF_SRC_(B), (size_t) -1,          \
  |  |  ------------------
  |  |  |  |  144|     26|  (HTS_IS_NOT_CHAR_BUFFER(B) ? (size_t) -1 : sizeof(__typeof__(B)))
  |  |  |  |  ------------------
  |  |  |  |  |  |  138|     26|#define HTS_IS_NOT_CHAR_BUFFER(VAR) (!HTS_IS_CHAR_BUFFER(VAR))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  132|     26|  (__builtin_types_compatible_p(__typeof__(VAR), char[]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (138:37): [True: 26, Folded]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  255|     26|                    "overflow while appending '" #B "' to '" #A "'", __FILE__, \
  |  |  256|       |                    __LINE__),                                                 \
  |  |  257|     26|      strcatbuff_ptr_((A), (B)))
  ------------------
 3513|     87|    } else {
 3514|     87|      if (*p == '\0' || p[1] != ':') {  /* empty path: not a DOS drive letter */
  ------------------
  |  Branch (3514:11): [True: 1, False: 86]
  |  Branch (3514:25): [True: 56, False: 30]
  ------------------
 3515|     57|        strcatbuff(adrfil->fil, "//");  /* adrfil->file://server/foo */
  ------------------
  |  |  252|     57|  __builtin_choose_expr(                                                       \
  |  |  253|     57|      HTS_IS_CHAR_BUFFER(A),                                                   \
  |  |  ------------------
  |  |  |  |  132|     57|  (__builtin_types_compatible_p(__typeof__(VAR), char[]))
  |  |  ------------------
  |  |  254|     57|      strncat_safe_(A, sizeof(A), B, HTS_SIZEOF_SRC_(B), (size_t) -1,          \
  |  |  ------------------
  |  |  |  |  144|     57|  (HTS_IS_NOT_CHAR_BUFFER(B) ? (size_t) -1 : sizeof(__typeof__(B)))
  |  |  |  |  ------------------
  |  |  |  |  |  |  138|     57|#define HTS_IS_NOT_CHAR_BUFFER(VAR) (!HTS_IS_CHAR_BUFFER(VAR))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  132|     57|  (__builtin_types_compatible_p(__typeof__(VAR), char[]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (138:37): [Folded, False: 57]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  255|     57|                    "overflow while appending '" #B "' to '" #A "'", __FILE__, \
  |  |  256|       |                    __LINE__),                                                 \
  |  |  257|     57|      strcatbuff_ptr_((A), (B)))
  ------------------
 3516|     57|        strcatbuff(adrfil->fil, p);
  ------------------
  |  |  252|     57|  __builtin_choose_expr(                                                       \
  |  |  253|     57|      HTS_IS_CHAR_BUFFER(A),                                                   \
  |  |  ------------------
  |  |  |  |  132|     57|  (__builtin_types_compatible_p(__typeof__(VAR), char[]))
  |  |  ------------------
  |  |  254|     57|      strncat_safe_(A, sizeof(A), B, HTS_SIZEOF_SRC_(B), (size_t) -1,          \
  |  |  ------------------
  |  |  |  |  144|     57|  (HTS_IS_NOT_CHAR_BUFFER(B) ? (size_t) -1 : sizeof(__typeof__(B)))
  |  |  |  |  ------------------
  |  |  |  |  |  |  138|     57|#define HTS_IS_NOT_CHAR_BUFFER(VAR) (!HTS_IS_CHAR_BUFFER(VAR))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  132|     57|  (__builtin_types_compatible_p(__typeof__(VAR), char[]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (138:37): [True: 57, Folded]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  255|     57|                    "overflow while appending '" #B "' to '" #A "'", __FILE__, \
  |  |  256|       |                    __LINE__),                                                 \
  |  |  257|     57|      strcatbuff_ptr_((A), (B)))
  ------------------
 3517|     57|      } else {
 3518|     30|        strcatbuff(adrfil->fil, p);     // adrfil->file://C:\..
  ------------------
  |  |  252|     30|  __builtin_choose_expr(                                                       \
  |  |  253|     30|      HTS_IS_CHAR_BUFFER(A),                                                   \
  |  |  ------------------
  |  |  |  |  132|     30|  (__builtin_types_compatible_p(__typeof__(VAR), char[]))
  |  |  ------------------
  |  |  254|     30|      strncat_safe_(A, sizeof(A), B, HTS_SIZEOF_SRC_(B), (size_t) -1,          \
  |  |  ------------------
  |  |  |  |  144|     30|  (HTS_IS_NOT_CHAR_BUFFER(B) ? (size_t) -1 : sizeof(__typeof__(B)))
  |  |  |  |  ------------------
  |  |  |  |  |  |  138|     30|#define HTS_IS_NOT_CHAR_BUFFER(VAR) (!HTS_IS_CHAR_BUFFER(VAR))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  132|     30|  (__builtin_types_compatible_p(__typeof__(VAR), char[]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (138:37): [True: 30, Folded]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  255|     30|                    "overflow while appending '" #B "' to '" #A "'", __FILE__, \
  |  |  256|       |                    __LINE__),                                                 \
  |  |  257|     30|      strcatbuff_ptr_((A), (B)))
  ------------------
 3519|     30|      }
 3520|     87|    }
 3521|       |
 3522|    113|    a = strchr(adrfil->fil, '?');
 3523|    113|    if (a)
  ------------------
  |  Branch (3523:9): [True: 16, False: 97]
  ------------------
 3524|     16|      *a = '\0';                /* couper query (inutile pour adrfil->file:// lors de la requête) */
 3525|       |    // adrfil->filtrer les \\ -> / pour les fichiers DOS
 3526|  49.2k|    for(i = 0; adrfil->fil[i] != '\0'; i++)
  ------------------
  |  Branch (3526:16): [True: 49.1k, False: 113]
  ------------------
 3527|  49.1k|      if (adrfil->fil[i] == '\\')
  ------------------
  |  Branch (3527:11): [True: 7.17k, False: 41.9k]
  ------------------
 3528|  7.17k|        adrfil->fil[i] = '/';
 3529|       |    // collapse ../ like the http branch above (path-traversal safety)
 3530|    113|    fil_simplifie(adrfil->fil);
 3531|    113|  }
 3532|       |
 3533|       |  // no hostname
 3534|    527|  if (!strnotempty(adrfil->adr))
  ------------------
  |  |  348|    527|#define strnotempty(A) (((A) != NULL && (A)[0] != '\0'))
  |  |  ------------------
  |  |  |  Branch (348:26): [True: 527, False: 0]
  |  |  |  Branch (348:41): [True: 432, False: 95]
  |  |  ------------------
  ------------------
 3535|     95|    return -1;                  // erreur non reconnu
 3536|       |
 3537|       |  // nommer au besoin.. (non utilisé normalement)
 3538|    432|  if (!strnotempty(adrfil->fil))
  ------------------
  |  |  348|    432|#define strnotempty(A) (((A) != NULL && (A)[0] != '\0'))
  |  |  ------------------
  |  |  |  Branch (348:26): [True: 432, False: 0]
  |  |  |  Branch (348:41): [True: 432, False: 0]
  |  |  ------------------
  ------------------
 3539|      0|    strcpybuff(adrfil->fil, "default-index.html");
  ------------------
  |  |  272|      0|  __builtin_choose_expr(HTS_IS_CHAR_BUFFER(A),                                 \
  |  |  ------------------
  |  |  |  |  132|      0|  (__builtin_types_compatible_p(__typeof__(VAR), char[]))
  |  |  ------------------
  |  |  273|      0|                        strcpy_safe_(A, sizeof(A), B, HTS_SIZEOF_SRC_(B),      \
  |  |  ------------------
  |  |  |  |  144|      0|  (HTS_IS_NOT_CHAR_BUFFER(B) ? (size_t) -1 : sizeof(__typeof__(B)))
  |  |  |  |  ------------------
  |  |  |  |  |  |  138|      0|#define HTS_IS_NOT_CHAR_BUFFER(VAR) (!HTS_IS_CHAR_BUFFER(VAR))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  132|      0|  (__builtin_types_compatible_p(__typeof__(VAR), char[]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (138:37): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  274|      0|                                     "overflow while copying '" #B "' to '" #A \
  |  |  275|      0|                                     "'",                                      \
  |  |  276|      0|                                     __FILE__, __LINE__),                      \
  |  |  277|      0|                        strcpybuff_ptr_((A), (B)))
  ------------------
 3540|       |
 3541|       |  // case insensitive pour adrfil->adresse
 3542|    432|  {
 3543|    432|    char *a = jump_identification(adrfil->adr);
 3544|       |
 3545|  14.6k|    while(*a) {
  ------------------
  |  Branch (3545:11): [True: 14.1k, False: 432]
  ------------------
 3546|  14.1k|      if ((*a >= 'A') && (*a <= 'Z'))
  ------------------
  |  Branch (3546:11): [True: 5.10k, False: 9.07k]
  |  Branch (3546:26): [True: 2.82k, False: 2.28k]
  ------------------
 3547|  2.82k|        *a += 'a' - 'A';
 3548|  14.1k|      a++;
 3549|  14.1k|    }
 3550|    432|  }
 3551|       |
 3552|    432|  return 0;
 3553|    527|}
fil_simplifie:
 3556|  1.07k|void fil_simplifie(char *f) {
 3557|  1.07k|  char *a, *b;
 3558|  1.07k|  char *rollback[128];
 3559|  1.07k|  int rollid = 0;
 3560|  1.07k|  char lc = '/';
 3561|  1.07k|  int query = 0;
 3562|  1.07k|  int wasAbsolute = (*f == '/');
 3563|       |
 3564|   383k|  for(a = b = f; *a != '\0';) {
  ------------------
  |  Branch (3564:18): [True: 382k, False: 1.05k]
  ------------------
 3565|   382k|    if (*a == '?')
  ------------------
  |  Branch (3565:9): [True: 10.4k, False: 371k]
  ------------------
 3566|  10.4k|      query = 1;
 3567|   382k|    if (query == 0 && lc == '/' && a[0] == '.' && a[1] == '/') {        /* foo/./bar or ./foo  */
  ------------------
  |  Branch (3567:9): [True: 221k, False: 160k]
  |  Branch (3567:23): [True: 16.9k, False: 204k]
  |  Branch (3567:36): [True: 7.87k, False: 9.03k]
  |  Branch (3567:51): [True: 2.23k, False: 5.64k]
  ------------------
 3568|  2.23k|      a += 2;
 3569|   379k|    } else if (query == 0 && lc == '/' && a[0] == '.' && a[1] == '.' && (a[2] == '/' || a[2] == '\0')) {        /* foo/../bar or ../foo or .. */
  ------------------
  |  Branch (3569:16): [True: 219k, False: 160k]
  |  Branch (3569:30): [True: 14.6k, False: 204k]
  |  Branch (3569:43): [True: 5.64k, False: 9.03k]
  |  Branch (3569:58): [True: 4.49k, False: 1.15k]
  |  Branch (3569:74): [True: 3.29k, False: 1.20k]
  |  Branch (3569:89): [True: 77, False: 1.12k]
  ------------------
 3570|  3.36k|      if (a[2] == '\0')
  ------------------
  |  Branch (3570:11): [True: 77, False: 3.29k]
  ------------------
 3571|     77|        a += 2;
 3572|  3.29k|      else
 3573|  3.29k|        a += 3;
 3574|  3.36k|      if (rollid > 1) {
  ------------------
  |  Branch (3574:11): [True: 2.47k, False: 889]
  ------------------
 3575|  2.47k|        rollid--;
 3576|  2.47k|        b = rollback[rollid - 1];
 3577|  2.47k|      } else {                  /* too many ../ */
 3578|    889|        rollid = 0;
 3579|    889|        b = f;
 3580|    889|        if (wasAbsolute)
  ------------------
  |  Branch (3580:13): [True: 509, False: 380]
  ------------------
 3581|    509|          b++;                  /* after the / */
 3582|    889|      }
 3583|   376k|    } else {
 3584|   376k|      *b++ = lc = *a;
 3585|   376k|      if (*a == '/') {
  ------------------
  |  Branch (3585:11): [True: 11.5k, False: 364k]
  ------------------
 3586|  11.5k|        rollback[rollid++] = b;
 3587|  11.5k|        if (rollid >= 127) {
  ------------------
  |  Branch (3587:13): [True: 15, False: 11.5k]
  ------------------
 3588|     15|          *f = '\0';            /* ERROR */
 3589|     15|          break;
 3590|     15|        }
 3591|  11.5k|      }
 3592|   376k|      a++;
 3593|   376k|    }
 3594|   382k|  }
 3595|  1.07k|  *b = '\0';
 3596|  1.07k|  if (*f == '\0') {
  ------------------
  |  Branch (3596:7): [True: 39, False: 1.03k]
  ------------------
 3597|     39|    if (wasAbsolute) {
  ------------------
  |  Branch (3597:9): [True: 10, False: 29]
  ------------------
 3598|     10|      f[0] = '/';
 3599|     10|      f[1] = '\0';
 3600|     29|    } else {
 3601|     29|      f[0] = '.';
 3602|     29|      f[1] = '/';
 3603|     29|      f[2] = '\0';
 3604|     29|    }
 3605|     39|  }
 3606|  1.07k|}
jump_identification_const:
 4530|  1.14k|HTSEXT_API const char *jump_identification_const(const char *source) {
 4531|  1.14k|  const char *a, *trytofind;
 4532|       |
 4533|  1.14k|  if (strcmp(source, "file://") == 0)
  ------------------
  |  Branch (4533:7): [True: 114, False: 1.02k]
  ------------------
 4534|    114|    return source;
 4535|       |  // rechercher dernier @ (car parfois email transmise dans adresse!)
 4536|       |  // mais sauter ftp:// éventuel
 4537|  1.02k|  a = jump_protocol_const(source);
 4538|  1.02k|  trytofind = strrchr_limit(a, '@', strchr(a, '/'));
 4539|  1.02k|  return trytofind != NULL ? trytofind : a;
  ------------------
  |  Branch (4539:10): [True: 80, False: 947]
  ------------------
 4540|  1.14k|}
strrchr_limit:
 5095|  1.02k|const char *strrchr_limit(const char *s, char c, const char *limit) {
 5096|  1.02k|  if (limit == NULL) {
  ------------------
  |  Branch (5096:7): [True: 897, False: 130]
  ------------------
 5097|    897|    const char *p = strrchr(s, c);
 5098|       |
 5099|    897|    return p ? (p + 1) : NULL;
  ------------------
  |  Branch (5099:12): [True: 70, False: 827]
  ------------------
 5100|    897|  } else {
 5101|    130|    const char *a = NULL, *p;
 5102|       |
 5103|    327|    for(;;) {
 5104|    327|      p = strchr((a) ? a : s, c);
  ------------------
  |  Branch (5104:18): [True: 197, False: 130]
  ------------------
 5105|    327|      if ((p >= limit) || (p == NULL))
  ------------------
  |  Branch (5105:11): [True: 3, False: 324]
  |  Branch (5105:27): [True: 127, False: 197]
  ------------------
 5106|    130|        return a;
 5107|    197|      a = p + 1;
 5108|    197|    }
 5109|    130|  }
 5110|  1.02k|}
jump_protocol_const:
 5113|  1.02k|const char *jump_protocol_const(const char *source) {
 5114|  1.02k|  int p;
 5115|       |
 5116|       |  // scheme
 5117|       |  // "Comparisons of scheme names MUST be case-insensitive" (RFC2616)
 5118|  1.02k|  if ((p = strfield(source, "http:")))
  ------------------
  |  Branch (5118:7): [True: 7, False: 1.02k]
  ------------------
 5119|      7|    source += p;
 5120|  1.02k|  else if ((p = strfield(source, "ftp:")))
  ------------------
  |  Branch (5120:12): [True: 41, False: 979]
  ------------------
 5121|     41|    source += p;
 5122|    979|  else if ((p = strfield(source, "https:")))
  ------------------
  |  Branch (5122:12): [True: 9, False: 970]
  ------------------
 5123|      9|    source += p;
 5124|    970|  else if ((p = strfield(source, "file:")))
  ------------------
  |  Branch (5124:12): [True: 49, False: 921]
  ------------------
 5125|     49|    source += p;
 5126|    921|  else if ((p = strfield(source, "socks5h:")))
  ------------------
  |  Branch (5126:12): [True: 7, False: 914]
  ------------------
 5127|      7|    source += p;
 5128|    914|  else if ((p = strfield(source, "socks5:")))
  ------------------
  |  Branch (5128:12): [True: 7, False: 907]
  ------------------
 5129|      7|    source += p;
 5130|    907|  else if ((p = strfield(source, "connect:")))
  ------------------
  |  Branch (5130:12): [True: 5, False: 902]
  ------------------
 5131|      5|    source += p;
 5132|       |  // net_path
 5133|  1.02k|  if (strncmp(source, "//", 2) == 0)
  ------------------
  |  Branch (5133:7): [True: 79, False: 948]
  ------------------
 5134|     79|    source += 2;
 5135|  1.02k|  return source;
 5136|  1.02k|}

htslib.c:strfield:
  895|  8.64k|HTS_STATIC int strfield(const char *f, const char *s) {
  896|  8.64k|  int r = 0;
  897|       |
  898|  12.2k|  while(streql(*f, *s) && ((*f) != 0) && ((*s) != 0)) {
  ------------------
  |  |  104|  24.5k|#define streql(a,b) (hichar(a)==hichar(b))
  |  |  ------------------
  |  |  |  |  102|  12.2k|#define hichar(a) ((((a)>='a') && ((a)<='z')) ? ((a)-('a'-'A')) : (a))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (102:21): [True: 5.27k, False: 7.02k]
  |  |  |  |  |  Branch (102:35): [True: 5.12k, False: 155]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define streql(a,b) (hichar(a)==hichar(b))
  |  |  ------------------
  |  |  |  |  102|  12.2k|#define hichar(a) ((((a)>='a') && ((a)<='z')) ? ((a)-('a'-'A')) : (a))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (102:21): [True: 11.3k, False: 978]
  |  |  |  |  |  Branch (102:35): [True: 11.3k, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (104:21): [True: 3.70k, False: 8.59k]
  |  |  ------------------
  ------------------
  |  Branch (898:27): [True: 3.65k, False: 51]
  |  Branch (898:42): [True: 3.65k, False: 0]
  ------------------
  899|  3.65k|    f++;
  900|  3.65k|    s++;
  901|  3.65k|    r++;
  902|  3.65k|  }
  903|  8.64k|  if (*s == 0)
  ------------------
  |  Branch (903:7): [True: 388, False: 8.25k]
  ------------------
  904|    388|    return r;
  905|  8.25k|  else
  906|  8.25k|    return 0;
  907|  8.64k|}

htslib.c:strcpy_safe_:
  379|    149|             const char *exp, const char *file, int line) {
  380|    149|  assertf_(sizeof_dest != 0, file, line);
  ------------------
  |  |  100|    149|#define assertf_(exp, file, line) assertf__(exp, #exp, file, line)
  |  |  ------------------
  |  |  |  |   96|    149|  (void) ((exp) || (abortf_(sexp, file, line), 0))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (96:11): [True: 149, False: 0]
  |  |  |  |  |  Branch (96:20): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  381|      0|  dest[0] = '\0';
  382|    149|  return strncat_safe_(dest, sizeof_dest, source, sizeof_source, (size_t) -1,
  383|    149|                       exp, file, line);
  384|    149|}
htslib.c:strncat_safe_:
  361|  1.43k|              const size_t n, const char *exp, const char *file, int line) {
  362|  1.43k|  const size_t source_len = strlen_safe_(source, sizeof_source, file, line);
  363|  1.43k|  const size_t dest_len = strlen_safe_(dest, sizeof_dest, file, line);
  364|       |  /* note: "size_t is an unsigned integral type" ((size_t) -1 is positive) */
  365|  1.43k|  const size_t source_copy = source_len <= n ? source_len : n;
  ------------------
  |  Branch (365:30): [True: 1.26k, False: 169]
  ------------------
  366|  1.43k|  const size_t dest_final_len = dest_len + source_copy;
  367|  1.43k|  assertf__(dest_final_len < sizeof_dest, exp, file, line);
  ------------------
  |  |   96|  1.43k|  (void) ((exp) || (abortf_(sexp, file, line), 0))
  |  |  ------------------
  |  |  |  Branch (96:11): [True: 1.43k, False: 0]
  |  |  |  Branch (96:20): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  368|      0|  memcpy(dest + dest_len, source, source_copy);
  369|  1.43k|  dest[dest_final_len] = '\0';
  370|  1.43k|  return dest;
  371|  1.43k|}
htslib.c:strlen_safe_:
  344|  2.87k|                                                 const char *file, int line) {
  345|  2.87k|  size_t size;
  346|  2.87k|  assertf_(source != NULL, file, line);
  ------------------
  |  |  100|  2.87k|#define assertf_(exp, file, line) assertf__(exp, #exp, file, line)
  |  |  ------------------
  |  |  |  |   96|  2.87k|  (void) ((exp) || (abortf_(sexp, file, line), 0))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (96:11): [True: 2.87k, False: 0]
  |  |  |  |  |  Branch (96:20): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  347|  2.87k|  size = sizeof_source != (size_t) -1 ? htssafe_strnlen_(source, sizeof_source)
  ------------------
  |  Branch (347:10): [True: 1.92k, False: 944]
  ------------------
  348|  2.87k|                                      : strlen(source);
  349|  2.87k|  assertf_(size < sizeof_source, file, line);
  ------------------
  |  |  100|  2.87k|#define assertf_(exp, file, line) assertf__(exp, #exp, file, line)
  |  |  ------------------
  |  |  |  |   96|  2.87k|  (void) ((exp) || (abortf_(sexp, file, line), 0))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (96:11): [True: 2.87k, False: 0]
  |  |  |  |  |  Branch (96:20): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  350|      0|  return size;
  351|  2.87k|}
htslib.c:htssafe_strnlen_:
  319|  1.92k|                                                     size_t maxlen) {
  320|  1.92k|#if (defined(_WIN32) || (defined(HAVE_STRNLEN) && !defined(__STRICT_ANSI__)))
  321|  1.92k|  return strnlen(s, maxlen);
  322|       |#else
  323|       |  size_t i;
  324|       |  for (i = 0; i < maxlen && s[i] != '\0'; i++)
  325|       |    ;
  326|       |  return i;
  327|       |#endif
  328|  1.92k|}

