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

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

ident_url_absolute:
 2390|    583|int ident_url_absolute(const char *url, lien_adrfil *adrfil) {
 2391|    583|  int pos = 0;
 2392|    583|  int scheme = 0;
 2393|       |
 2394|       |  // effacer adrfil->adr et adrfil->fil
 2395|    583|  adrfil->adr[0] = adrfil->fil[0] = '\0';
 2396|       |
 2397|       |  // Reject an over-long URL: a root-relative path is copied whole into fil[].
 2398|    583|  if (strlen(url) >= HTS_URLMAXSIZE * 2)
  ------------------
  |  |  236|    583|#define HTS_URLMAXSIZE 1024
  ------------------
  |  Branch (2398:7): [True: 9, False: 574]
  ------------------
 2399|      9|    return -1;
 2400|       |
 2401|       |#if HDEBUG
 2402|       |  printf("protocol: %s\n", url);
 2403|       |#endif
 2404|       |
 2405|       |  // Scheme?
 2406|    574|  {
 2407|    574|    const char *a = url;
 2408|       |
 2409|    574|    while(isalpha((unsigned char) *a))
  ------------------
  |  Branch (2409:11): [True: 1.44k, False: 574]
  ------------------
 2410|  1.44k|      a++;
 2411|    574|    if (*a == ':')
  ------------------
  |  Branch (2411:9): [True: 150, False: 424]
  ------------------
 2412|    150|      scheme = 1;
 2413|    574|  }
 2414|       |
 2415|       |  // 1. optional scheme ":"
 2416|    574|  if ((pos = strfield(url, "file:"))) { // fichier local!! (pour les tests)
  ------------------
  |  Branch (2416:7): [True: 109, False: 465]
  ------------------
 2417|       |    //!!p+=3;
 2418|    109|    strcpybuff(adrfil->adr, "file://");
  ------------------
  |  |  265|    109|  __builtin_choose_expr(HTS_IS_CHAR_BUFFER(A),                                 \
  |  |  ------------------
  |  |  |  |  113|    109|  (__builtin_types_compatible_p(__typeof__(VAR), char[]))
  |  |  ------------------
  |  |  266|    109|                        strcpy_safe_(A, sizeof(A), B, HTS_SIZEOF_SRC_(B),      \
  |  |  ------------------
  |  |  |  |  125|    109|  (HTS_IS_NOT_CHAR_BUFFER(B) ? (size_t) -1 : sizeof(__typeof__(B)))
  |  |  |  |  ------------------
  |  |  |  |  |  |  119|    109|#define HTS_IS_NOT_CHAR_BUFFER(VAR) (!HTS_IS_CHAR_BUFFER(VAR))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  113|    109|  (__builtin_types_compatible_p(__typeof__(VAR), char[]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (119:37): [Folded, False: 109]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  267|    109|                                     "overflow while copying '" #B "' to '" #A \
  |  |  268|    109|                                     "'",                                      \
  |  |  269|    109|                                     __FILE__, __LINE__),                      \
  |  |  270|    109|                        strcpybuff_ptr_((A), (B)))
  ------------------
 2419|    465|  } else if ((pos = strfield(url, "http:"))) {  // HTTP
  ------------------
  |  Branch (2419:14): [True: 1, False: 464]
  ------------------
 2420|       |    //!!p+=3;
 2421|    464|  } else if ((pos = strfield(url, "ftp:"))) {   // FTP
  ------------------
  |  Branch (2421:14): [True: 38, False: 426]
  ------------------
 2422|     38|    strcpybuff(adrfil->adr, "ftp://");  // FTP!!
  ------------------
  |  |  265|     38|  __builtin_choose_expr(HTS_IS_CHAR_BUFFER(A),                                 \
  |  |  ------------------
  |  |  |  |  113|     38|  (__builtin_types_compatible_p(__typeof__(VAR), char[]))
  |  |  ------------------
  |  |  266|     38|                        strcpy_safe_(A, sizeof(A), B, HTS_SIZEOF_SRC_(B),      \
  |  |  ------------------
  |  |  |  |  125|     38|  (HTS_IS_NOT_CHAR_BUFFER(B) ? (size_t) -1 : sizeof(__typeof__(B)))
  |  |  |  |  ------------------
  |  |  |  |  |  |  119|     38|#define HTS_IS_NOT_CHAR_BUFFER(VAR) (!HTS_IS_CHAR_BUFFER(VAR))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  113|     38|  (__builtin_types_compatible_p(__typeof__(VAR), char[]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (119:37): [Folded, False: 38]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  267|     38|                                     "overflow while copying '" #B "' to '" #A \
  |  |  268|     38|                                     "'",                                      \
  |  |  269|     38|                                     __FILE__, __LINE__),                      \
  |  |  270|     38|                        strcpybuff_ptr_((A), (B)))
  ------------------
 2423|       |    //!!p+=3;
 2424|       |#if HTS_USEOPENSSL
 2425|       |  } else if ((pos = strfield(url, "https:"))) {     // HTTPS
 2426|       |    strcpybuff(adrfil->adr, "https://");
 2427|       |#endif
 2428|    426|  } else if (scheme) {
  ------------------
  |  Branch (2428:14): [True: 2, False: 424]
  ------------------
 2429|      2|    return -1;                  // erreur non reconnu
 2430|      2|  } else
 2431|    424|    pos = 0;
 2432|       |
 2433|       |  // 2. optional "//" authority
 2434|    572|  if (strncmp(url + pos, "//", 2) == 0)
  ------------------
  |  Branch (2434:7): [True: 52, False: 520]
  ------------------
 2435|     52|    pos += 2;
 2436|       |
 2437|       |  // (url+pos) now points to the path (not net path)
 2438|       |
 2439|       |  //## if (adrfil->adr[0]!=lOCAL_CHAR) {    // adrfil->adresse normale http
 2440|    572|  if (!strfield(adrfil->adr, "file:")) {        // PAS adrfil->file://
  ------------------
  |  Branch (2440:7): [True: 463, False: 109]
  ------------------
 2441|    463|    const char *p, *q;
 2442|       |
 2443|    463|    p = url + pos;
 2444|       |
 2445|       |    // p pointe sur le début de l'adrfil->adresse, ex: www.truc.fr/sommaire/index.html
 2446|    463|    q = strchr(jump_identification_const(p), '/');
 2447|    463|    if (q == 0)
  ------------------
  |  Branch (2447:9): [True: 329, False: 134]
  ------------------
 2448|    329|      q = strchr(jump_identification_const(p), '?');  // http://www.foo.com?bar=1
 2449|    463|    if (q == 0)
  ------------------
  |  Branch (2449:9): [True: 284, False: 179]
  ------------------
 2450|    284|      q = p + strlen(p);        // pointe sur \0
 2451|       |    // q pointe sur le chemin, ex: index.html?query=recherche
 2452|       |
 2453|       |    // chemin www... trop long!!
 2454|    463|    if ((((int) (q - p))) > HTS_URLMAXSIZE) {
  ------------------
  |  |  236|    463|#define HTS_URLMAXSIZE 1024
  ------------------
  |  Branch (2454:9): [True: 3, False: 460]
  ------------------
 2455|      3|      return -1;                // erreur
 2456|      3|    }
 2457|       |    // recopier adrfil->adresse www..
 2458|    460|    strncatbuff(adrfil->adr, p, ((int) (q - p)));
  ------------------
  |  |  219|    460|  __builtin_choose_expr(HTS_IS_CHAR_BUFFER(A),                                 \
  |  |  ------------------
  |  |  |  |  113|    460|  (__builtin_types_compatible_p(__typeof__(VAR), char[]))
  |  |  ------------------
  |  |  220|    460|                        strncat_safe_(A, sizeof(A), B, HTS_SIZEOF_SRC_(B), N,  \
  |  |  ------------------
  |  |  |  |  125|    460|  (HTS_IS_NOT_CHAR_BUFFER(B) ? (size_t) -1 : sizeof(__typeof__(B)))
  |  |  |  |  ------------------
  |  |  |  |  |  |  119|    460|#define HTS_IS_NOT_CHAR_BUFFER(VAR) (!HTS_IS_CHAR_BUFFER(VAR))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  113|    460|  (__builtin_types_compatible_p(__typeof__(VAR), char[]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (119:37): [True: 460, Folded]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  221|    460|                                      "overflow while appending '" #B          \
  |  |  222|    460|                                      "' to '" #A "'",                         \
  |  |  223|    460|                                      __FILE__, __LINE__),                     \
  |  |  224|    460|                        strncatbuff_ptr_((A), (B), (N)))
  ------------------
 2459|       |    // *( adrfil->adr+( ((int) q) - ((int) p) ) )=0;  // faut arrêter la fumette!
 2460|       |
 2461|       |    // fil[] holds the path plus a possible leading '/' the top strlen() misses.
 2462|    460|    if (strlen(q) >= sizeof(adrfil->fil) - (q[0] != '/' ? 1 : 0))
  ------------------
  |  Branch (2462:9): [True: 3, False: 457]
  |  Branch (2462:45): [True: 326, False: 134]
  ------------------
 2463|      3|      return -1;
 2464|       |
 2465|       |    // recopier chemin /pub/..
 2466|    457|    if (q[0] != '/')            // page par défaut (/)
  ------------------
  |  Branch (2466:9): [True: 323, False: 134]
  ------------------
 2467|    323|      strcatbuff(adrfil->fil, "/");
  ------------------
  |  |  242|    323|  __builtin_choose_expr(                                                       \
  |  |  243|    323|      HTS_IS_CHAR_BUFFER(A),                                                   \
  |  |  ------------------
  |  |  |  |  113|    323|  (__builtin_types_compatible_p(__typeof__(VAR), char[]))
  |  |  ------------------
  |  |  244|    323|      strncat_safe_(A, sizeof(A), B, HTS_SIZEOF_SRC_(B), (size_t) -1,          \
  |  |  ------------------
  |  |  |  |  125|    323|  (HTS_IS_NOT_CHAR_BUFFER(B) ? (size_t) -1 : sizeof(__typeof__(B)))
  |  |  |  |  ------------------
  |  |  |  |  |  |  119|    323|#define HTS_IS_NOT_CHAR_BUFFER(VAR) (!HTS_IS_CHAR_BUFFER(VAR))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  113|    323|  (__builtin_types_compatible_p(__typeof__(VAR), char[]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (119:37): [Folded, False: 323]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  245|    323|                    "overflow while appending '" #B "' to '" #A "'", __FILE__, \
  |  |  246|       |                    __LINE__),                                                 \
  |  |  247|    323|      strcatbuff_ptr_((A), (B)))
  ------------------
 2468|    457|    strcatbuff(adrfil->fil, q);
  ------------------
  |  |  242|    457|  __builtin_choose_expr(                                                       \
  |  |  243|    457|      HTS_IS_CHAR_BUFFER(A),                                                   \
  |  |  ------------------
  |  |  |  |  113|    457|  (__builtin_types_compatible_p(__typeof__(VAR), char[]))
  |  |  ------------------
  |  |  244|    457|      strncat_safe_(A, sizeof(A), B, HTS_SIZEOF_SRC_(B), (size_t) -1,          \
  |  |  ------------------
  |  |  |  |  125|    457|  (HTS_IS_NOT_CHAR_BUFFER(B) ? (size_t) -1 : sizeof(__typeof__(B)))
  |  |  |  |  ------------------
  |  |  |  |  |  |  119|    457|#define HTS_IS_NOT_CHAR_BUFFER(VAR) (!HTS_IS_CHAR_BUFFER(VAR))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  113|    457|  (__builtin_types_compatible_p(__typeof__(VAR), char[]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (119:37): [True: 457, Folded]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  245|    457|                    "overflow while appending '" #B "' to '" #A "'", __FILE__, \
  |  |  246|       |                    __LINE__),                                                 \
  |  |  247|    457|      strcatbuff_ptr_((A), (B)))
  ------------------
 2469|       |    // SECURITE:
 2470|       |    // simplifier url pour les ../
 2471|    457|    fil_simplifie(adrfil->fil);
 2472|    457|  } else {                      // localhost adrfil->file://
 2473|    109|    const char *p;
 2474|    109|    size_t i;
 2475|    109|    char *a;
 2476|       |
 2477|    109|    p = url + pos;
 2478|    109|    if (*p == '/' || *p == '\\') {      /* adrfil->file:///.. */
  ------------------
  |  Branch (2478:9): [True: 15, False: 94]
  |  Branch (2478:22): [True: 13, False: 81]
  ------------------
 2479|     28|      strcatbuff(adrfil->fil, p);       // fichier local ; adrfil->adr="#"
  ------------------
  |  |  242|     28|  __builtin_choose_expr(                                                       \
  |  |  243|     28|      HTS_IS_CHAR_BUFFER(A),                                                   \
  |  |  ------------------
  |  |  |  |  113|     28|  (__builtin_types_compatible_p(__typeof__(VAR), char[]))
  |  |  ------------------
  |  |  244|     28|      strncat_safe_(A, sizeof(A), B, HTS_SIZEOF_SRC_(B), (size_t) -1,          \
  |  |  ------------------
  |  |  |  |  125|     28|  (HTS_IS_NOT_CHAR_BUFFER(B) ? (size_t) -1 : sizeof(__typeof__(B)))
  |  |  |  |  ------------------
  |  |  |  |  |  |  119|     28|#define HTS_IS_NOT_CHAR_BUFFER(VAR) (!HTS_IS_CHAR_BUFFER(VAR))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  113|     28|  (__builtin_types_compatible_p(__typeof__(VAR), char[]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (119:37): [True: 28, Folded]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  245|     28|                    "overflow while appending '" #B "' to '" #A "'", __FILE__, \
  |  |  246|       |                    __LINE__),                                                 \
  |  |  247|     28|      strcatbuff_ptr_((A), (B)))
  ------------------
 2480|     81|    } else {
 2481|     81|      if (*p == '\0' || p[1] != ':') {  /* empty path: not a DOS drive letter */
  ------------------
  |  Branch (2481:11): [True: 1, False: 80]
  |  Branch (2481:25): [True: 50, False: 30]
  ------------------
 2482|     51|        strcatbuff(adrfil->fil, "//");  /* adrfil->file://server/foo */
  ------------------
  |  |  242|     51|  __builtin_choose_expr(                                                       \
  |  |  243|     51|      HTS_IS_CHAR_BUFFER(A),                                                   \
  |  |  ------------------
  |  |  |  |  113|     51|  (__builtin_types_compatible_p(__typeof__(VAR), char[]))
  |  |  ------------------
  |  |  244|     51|      strncat_safe_(A, sizeof(A), B, HTS_SIZEOF_SRC_(B), (size_t) -1,          \
  |  |  ------------------
  |  |  |  |  125|     51|  (HTS_IS_NOT_CHAR_BUFFER(B) ? (size_t) -1 : sizeof(__typeof__(B)))
  |  |  |  |  ------------------
  |  |  |  |  |  |  119|     51|#define HTS_IS_NOT_CHAR_BUFFER(VAR) (!HTS_IS_CHAR_BUFFER(VAR))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  113|     51|  (__builtin_types_compatible_p(__typeof__(VAR), char[]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (119:37): [Folded, False: 51]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  245|     51|                    "overflow while appending '" #B "' to '" #A "'", __FILE__, \
  |  |  246|       |                    __LINE__),                                                 \
  |  |  247|     51|      strcatbuff_ptr_((A), (B)))
  ------------------
 2483|     51|        strcatbuff(adrfil->fil, p);
  ------------------
  |  |  242|     51|  __builtin_choose_expr(                                                       \
  |  |  243|     51|      HTS_IS_CHAR_BUFFER(A),                                                   \
  |  |  ------------------
  |  |  |  |  113|     51|  (__builtin_types_compatible_p(__typeof__(VAR), char[]))
  |  |  ------------------
  |  |  244|     51|      strncat_safe_(A, sizeof(A), B, HTS_SIZEOF_SRC_(B), (size_t) -1,          \
  |  |  ------------------
  |  |  |  |  125|     51|  (HTS_IS_NOT_CHAR_BUFFER(B) ? (size_t) -1 : sizeof(__typeof__(B)))
  |  |  |  |  ------------------
  |  |  |  |  |  |  119|     51|#define HTS_IS_NOT_CHAR_BUFFER(VAR) (!HTS_IS_CHAR_BUFFER(VAR))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  113|     51|  (__builtin_types_compatible_p(__typeof__(VAR), char[]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (119:37): [True: 51, Folded]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  245|     51|                    "overflow while appending '" #B "' to '" #A "'", __FILE__, \
  |  |  246|       |                    __LINE__),                                                 \
  |  |  247|     51|      strcatbuff_ptr_((A), (B)))
  ------------------
 2484|     51|      } else {
 2485|     30|        strcatbuff(adrfil->fil, p);     // adrfil->file://C:\..
  ------------------
  |  |  242|     30|  __builtin_choose_expr(                                                       \
  |  |  243|     30|      HTS_IS_CHAR_BUFFER(A),                                                   \
  |  |  ------------------
  |  |  |  |  113|     30|  (__builtin_types_compatible_p(__typeof__(VAR), char[]))
  |  |  ------------------
  |  |  244|     30|      strncat_safe_(A, sizeof(A), B, HTS_SIZEOF_SRC_(B), (size_t) -1,          \
  |  |  ------------------
  |  |  |  |  125|     30|  (HTS_IS_NOT_CHAR_BUFFER(B) ? (size_t) -1 : sizeof(__typeof__(B)))
  |  |  |  |  ------------------
  |  |  |  |  |  |  119|     30|#define HTS_IS_NOT_CHAR_BUFFER(VAR) (!HTS_IS_CHAR_BUFFER(VAR))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  113|     30|  (__builtin_types_compatible_p(__typeof__(VAR), char[]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (119:37): [True: 30, Folded]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  245|     30|                    "overflow while appending '" #B "' to '" #A "'", __FILE__, \
  |  |  246|       |                    __LINE__),                                                 \
  |  |  247|     30|      strcatbuff_ptr_((A), (B)))
  ------------------
 2486|     30|      }
 2487|     81|    }
 2488|       |
 2489|    109|    a = strchr(adrfil->fil, '?');
 2490|    109|    if (a)
  ------------------
  |  Branch (2490:9): [True: 19, False: 90]
  ------------------
 2491|     19|      *a = '\0';                /* couper query (inutile pour adrfil->file:// lors de la requête) */
 2492|       |    // adrfil->filtrer les \\ -> / pour les fichiers DOS
 2493|  39.4k|    for(i = 0; adrfil->fil[i] != '\0'; i++)
  ------------------
  |  Branch (2493:16): [True: 39.3k, False: 109]
  ------------------
 2494|  39.3k|      if (adrfil->fil[i] == '\\')
  ------------------
  |  Branch (2494:11): [True: 858, False: 38.5k]
  ------------------
 2495|    858|        adrfil->fil[i] = '/';
 2496|       |    // collapse ../ like the http branch above (path-traversal safety)
 2497|    109|    fil_simplifie(adrfil->fil);
 2498|    109|  }
 2499|       |
 2500|       |  // no hostname
 2501|    566|  if (!strnotempty(adrfil->adr))
  ------------------
  |  |  313|    566|#define strnotempty(A) (((A) != NULL && (A)[0] != '\0'))
  |  |  ------------------
  |  |  |  Branch (313:26): [True: 566, False: 0]
  |  |  |  Branch (313:41): [True: 462, False: 104]
  |  |  ------------------
  ------------------
 2502|    104|    return -1;                  // erreur non reconnu
 2503|       |
 2504|       |  // nommer au besoin.. (non utilisé normalement)
 2505|    462|  if (!strnotempty(adrfil->fil))
  ------------------
  |  |  313|    462|#define strnotempty(A) (((A) != NULL && (A)[0] != '\0'))
  |  |  ------------------
  |  |  |  Branch (313:26): [True: 462, False: 0]
  |  |  |  Branch (313:41): [True: 462, False: 0]
  |  |  ------------------
  ------------------
 2506|      0|    strcpybuff(adrfil->fil, "default-index.html");
  ------------------
  |  |  265|      0|  __builtin_choose_expr(HTS_IS_CHAR_BUFFER(A),                                 \
  |  |  ------------------
  |  |  |  |  113|      0|  (__builtin_types_compatible_p(__typeof__(VAR), char[]))
  |  |  ------------------
  |  |  266|      0|                        strcpy_safe_(A, sizeof(A), B, HTS_SIZEOF_SRC_(B),      \
  |  |  ------------------
  |  |  |  |  125|      0|  (HTS_IS_NOT_CHAR_BUFFER(B) ? (size_t) -1 : sizeof(__typeof__(B)))
  |  |  |  |  ------------------
  |  |  |  |  |  |  119|      0|#define HTS_IS_NOT_CHAR_BUFFER(VAR) (!HTS_IS_CHAR_BUFFER(VAR))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  113|      0|  (__builtin_types_compatible_p(__typeof__(VAR), char[]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (119:37): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  267|      0|                                     "overflow while copying '" #B "' to '" #A \
  |  |  268|      0|                                     "'",                                      \
  |  |  269|      0|                                     __FILE__, __LINE__),                      \
  |  |  270|      0|                        strcpybuff_ptr_((A), (B)))
  ------------------
 2507|       |
 2508|       |  // case insensitive pour adrfil->adresse
 2509|    462|  {
 2510|    462|    char *a = jump_identification(adrfil->adr);
 2511|       |
 2512|  13.5k|    while(*a) {
  ------------------
  |  Branch (2512:11): [True: 13.1k, False: 462]
  ------------------
 2513|  13.1k|      if ((*a >= 'A') && (*a <= 'Z'))
  ------------------
  |  Branch (2513:11): [True: 5.27k, False: 7.83k]
  |  Branch (2513:26): [True: 2.58k, False: 2.69k]
  ------------------
 2514|  2.58k|        *a += 'a' - 'A';
 2515|  13.1k|      a++;
 2516|  13.1k|    }
 2517|    462|  }
 2518|       |
 2519|    462|  return 0;
 2520|    566|}
fil_simplifie:
 2523|  1.14k|void fil_simplifie(char *f) {
 2524|  1.14k|  char *a, *b;
 2525|  1.14k|  char *rollback[128];
 2526|  1.14k|  int rollid = 0;
 2527|  1.14k|  char lc = '/';
 2528|  1.14k|  int query = 0;
 2529|  1.14k|  int wasAbsolute = (*f == '/');
 2530|       |
 2531|   632k|  for(a = b = f; *a != '\0';) {
  ------------------
  |  Branch (2531:18): [True: 631k, False: 1.13k]
  ------------------
 2532|   631k|    if (*a == '?')
  ------------------
  |  Branch (2532:9): [True: 605, False: 630k]
  ------------------
 2533|    605|      query = 1;
 2534|   631k|    if (query == 0 && lc == '/' && a[0] == '.' && a[1] == '/') {        /* foo/./bar or ./foo  */
  ------------------
  |  Branch (2534:9): [True: 268k, False: 362k]
  |  Branch (2534:23): [True: 11.0k, False: 257k]
  |  Branch (2534:36): [True: 4.29k, False: 6.74k]
  |  Branch (2534:51): [True: 374, False: 3.92k]
  ------------------
 2535|    374|      a += 2;
 2536|   631k|    } else if (query == 0 && lc == '/' && a[0] == '.' && a[1] == '.' && (a[2] == '/' || a[2] == '\0')) {        /* foo/../bar or ../foo or .. */
  ------------------
  |  Branch (2536:16): [True: 268k, False: 362k]
  |  Branch (2536:30): [True: 10.6k, False: 257k]
  |  Branch (2536:43): [True: 3.92k, False: 6.74k]
  |  Branch (2536:58): [True: 3.12k, False: 799]
  |  Branch (2536:74): [True: 2.49k, False: 634]
  |  Branch (2536:89): [True: 66, False: 568]
  ------------------
 2537|  2.55k|      if (a[2] == '\0')
  ------------------
  |  Branch (2537:11): [True: 66, False: 2.49k]
  ------------------
 2538|     66|        a += 2;
 2539|  2.49k|      else
 2540|  2.49k|        a += 3;
 2541|  2.55k|      if (rollid > 1) {
  ------------------
  |  Branch (2541:11): [True: 1.21k, False: 1.34k]
  ------------------
 2542|  1.21k|        rollid--;
 2543|  1.21k|        b = rollback[rollid - 1];
 2544|  1.34k|      } else {                  /* too many ../ */
 2545|  1.34k|        rollid = 0;
 2546|  1.34k|        b = f;
 2547|  1.34k|        if (wasAbsolute)
  ------------------
  |  Branch (2547:13): [True: 685, False: 663]
  ------------------
 2548|    685|          b++;                  /* after the / */
 2549|  1.34k|      }
 2550|   628k|    } else {
 2551|   628k|      *b++ = lc = *a;
 2552|   628k|      if (*a == '/') {
  ------------------
  |  Branch (2552:11): [True: 8.77k, False: 619k]
  ------------------
 2553|  8.77k|        rollback[rollid++] = b;
 2554|  8.77k|        if (rollid >= 127) {
  ------------------
  |  Branch (2554:13): [True: 16, False: 8.76k]
  ------------------
 2555|     16|          *f = '\0';            /* ERROR */
 2556|     16|          break;
 2557|     16|        }
 2558|  8.77k|      }
 2559|   628k|      a++;
 2560|   628k|    }
 2561|   631k|  }
 2562|  1.14k|  *b = '\0';
 2563|  1.14k|  if (*f == '\0') {
  ------------------
  |  Branch (2563:7): [True: 38, False: 1.11k]
  ------------------
 2564|     38|    if (wasAbsolute) {
  ------------------
  |  Branch (2564:9): [True: 7, False: 31]
  ------------------
 2565|      7|      f[0] = '/';
 2566|      7|      f[1] = '\0';
 2567|     31|    } else {
 2568|     31|      f[0] = '.';
 2569|     31|      f[1] = '/';
 2570|     31|      f[2] = '\0';
 2571|     31|    }
 2572|     38|  }
 2573|  1.14k|}
jump_identification_const:
 3405|  1.25k|HTSEXT_API const char *jump_identification_const(const char *source) {
 3406|  1.25k|  const char *a, *trytofind;
 3407|       |
 3408|  1.25k|  if (strcmp(source, "file://") == 0)
  ------------------
  |  Branch (3408:7): [True: 110, False: 1.14k]
  ------------------
 3409|    110|    return source;
 3410|       |  // rechercher dernier @ (car parfois email transmise dans adresse!)
 3411|       |  // mais sauter ftp:// éventuel
 3412|  1.14k|  a = jump_protocol_const(source);
 3413|  1.14k|  trytofind = strrchr_limit(a, '@', strchr(a, '/'));
 3414|  1.14k|  return trytofind != NULL ? trytofind : a;
  ------------------
  |  Branch (3414:10): [True: 63, False: 1.08k]
  ------------------
 3415|  1.25k|}
strrchr_limit:
 4058|  1.14k|const char *strrchr_limit(const char *s, char c, const char *limit) {
 4059|  1.14k|  if (limit == NULL) {
  ------------------
  |  Branch (4059:7): [True: 1.00k, False: 135]
  ------------------
 4060|  1.00k|    const char *p = strrchr(s, c);
 4061|       |
 4062|  1.00k|    return p ? (p + 1) : NULL;
  ------------------
  |  Branch (4062:12): [True: 52, False: 957]
  ------------------
 4063|  1.00k|  } else {
 4064|    135|    const char *a = NULL, *p;
 4065|       |
 4066|    396|    for(;;) {
 4067|    396|      p = strchr((a) ? a : s, c);
  ------------------
  |  Branch (4067:18): [True: 261, False: 135]
  ------------------
 4068|    396|      if ((p >= limit) || (p == NULL))
  ------------------
  |  Branch (4068:11): [True: 2, False: 394]
  |  Branch (4068:27): [True: 133, False: 261]
  ------------------
 4069|    135|        return a;
 4070|    261|      a = p + 1;
 4071|    261|    }
 4072|    135|  }
 4073|  1.14k|}
jump_protocol_const:
 4076|  1.14k|const char *jump_protocol_const(const char *source) {
 4077|  1.14k|  int p;
 4078|       |
 4079|       |  // scheme
 4080|       |  // "Comparisons of scheme names MUST be case-insensitive" (RFC2616)
 4081|  1.14k|  if ((p = strfield(source, "http:")))
  ------------------
  |  Branch (4081:7): [True: 11, False: 1.13k]
  ------------------
 4082|     11|    source += p;
 4083|  1.13k|  else if ((p = strfield(source, "ftp:")))
  ------------------
  |  Branch (4083:12): [True: 43, False: 1.09k]
  ------------------
 4084|     43|    source += p;
 4085|  1.09k|  else if ((p = strfield(source, "https:")))
  ------------------
  |  Branch (4085:12): [True: 8, False: 1.08k]
  ------------------
 4086|      8|    source += p;
 4087|  1.08k|  else if ((p = strfield(source, "file:")))
  ------------------
  |  Branch (4087:12): [True: 53, False: 1.02k]
  ------------------
 4088|     53|    source += p;
 4089|  1.02k|  else if ((p = strfield(source, "socks5h:")))
  ------------------
  |  Branch (4089:12): [True: 8, False: 1.02k]
  ------------------
 4090|      8|    source += p;
 4091|  1.02k|  else if ((p = strfield(source, "socks5:")))
  ------------------
  |  Branch (4091:12): [True: 7, False: 1.01k]
  ------------------
 4092|      7|    source += p;
 4093|  1.01k|  else if ((p = strfield(source, "connect:")))
  ------------------
  |  Branch (4093:12): [True: 5, False: 1.00k]
  ------------------
 4094|      5|    source += p;
 4095|       |  // net_path
 4096|  1.14k|  if (strncmp(source, "//", 2) == 0)
  ------------------
  |  Branch (4096:7): [True: 79, False: 1.06k]
  ------------------
 4097|     79|    source += 2;
 4098|  1.14k|  return source;
 4099|  1.14k|}

htslib.c:strfield:
  562|  9.58k|HTS_STATIC int strfield(const char *f, const char *s) {
  563|  9.58k|  int r = 0;
  564|       |
  565|  13.5k|  while(streql(*f, *s) && ((*f) != 0) && ((*s) != 0)) {
  ------------------
  |  |  105|  27.0k|#define streql(a,b) (hichar(a)==hichar(b))
  |  |  ------------------
  |  |  |  |  103|  13.5k|#define hichar(a) ((((a)>='a') && ((a)<='z')) ? ((a)-('a'-'A')) : (a))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (103:21): [True: 5.10k, False: 8.39k]
  |  |  |  |  |  Branch (103:35): [True: 4.95k, False: 150]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define streql(a,b) (hichar(a)==hichar(b))
  |  |  ------------------
  |  |  |  |  103|  13.5k|#define hichar(a) ((((a)>='a') && ((a)<='z')) ? ((a)-('a'-'A')) : (a))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (103:21): [True: 12.5k, False: 992]
  |  |  |  |  |  Branch (103:35): [True: 12.5k, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (105:21): [True: 3.96k, False: 9.53k]
  |  |  ------------------
  ------------------
  |  Branch (565:27): [True: 3.91k, False: 53]
  |  Branch (565:42): [True: 3.91k, False: 0]
  ------------------
  566|  3.91k|    f++;
  567|  3.91k|    s++;
  568|  3.91k|    r++;
  569|  3.91k|  }
  570|  9.58k|  if (*s == 0)
  ------------------
  |  Branch (570:7): [True: 392, False: 9.19k]
  ------------------
  571|    392|    return r;
  572|  9.19k|  else
  573|  9.19k|    return 0;
  574|  9.58k|}

htslib.c:strcpy_safe_:
  376|    147|             const char *exp, const char *file, int line) {
  377|    147|  assertf_(sizeof_dest != 0, file, line);
  ------------------
  |  |   86|    147|#define assertf_(exp, file, line) assertf__(exp, #exp, file, line)
  |  |  ------------------
  |  |  |  |   81|    147|  (void) ((exp) || (abortf_(sexp, file, line), 0))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (81:11): [True: 147, False: 0]
  |  |  |  |  |  Branch (81:20): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  378|    147|  dest[0] = '\0';
  379|    147|  return strncat_safe_(dest, sizeof_dest, source, sizeof_source, (size_t) -1,
  380|    147|                       exp, file, line);
  381|    147|}
htslib.c:strncat_safe_:
  358|  1.54k|              const size_t n, const char *exp, const char *file, int line) {
  359|  1.54k|  const size_t source_len = strlen_safe_(source, sizeof_source, file, line);
  360|  1.54k|  const size_t dest_len = strlen_safe_(dest, sizeof_dest, file, line);
  361|       |  /* note: "size_t is an unsigned integral type" ((size_t) -1 is positive) */
  362|  1.54k|  const size_t source_copy = source_len <= n ? source_len : n;
  ------------------
  |  Branch (362:30): [True: 1.36k, False: 179]
  ------------------
  363|  1.54k|  const size_t dest_final_len = dest_len + source_copy;
  364|  1.54k|  assertf__(dest_final_len < sizeof_dest, exp, file, line);
  ------------------
  |  |   81|  1.54k|  (void) ((exp) || (abortf_(sexp, file, line), 0))
  |  |  ------------------
  |  |  |  Branch (81:11): [True: 1.54k, False: 0]
  |  |  |  Branch (81:20): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  365|  1.54k|  memcpy(dest + dest_len, source, source_copy);
  366|  1.54k|  dest[dest_final_len] = '\0';
  367|  1.54k|  return dest;
  368|  1.54k|}
htslib.c:strlen_safe_:
  341|  3.09k|                                                 const char *file, int line) {
  342|  3.09k|  size_t size;
  343|  3.09k|  assertf_(source != NULL, file, line);
  ------------------
  |  |   86|  3.09k|#define assertf_(exp, file, line) assertf__(exp, #exp, file, line)
  |  |  ------------------
  |  |  |  |   81|  3.09k|  (void) ((exp) || (abortf_(sexp, file, line), 0))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (81:11): [True: 3.09k, False: 0]
  |  |  |  |  |  Branch (81:20): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  344|  3.09k|  size = sizeof_source != (size_t) -1 ? htssafe_strnlen_(source, sizeof_source)
  ------------------
  |  Branch (344:10): [True: 2.06k, False: 1.02k]
  ------------------
  345|  3.09k|                                      : strlen(source);
  346|  3.09k|  assertf_(size < sizeof_source, file, line);
  ------------------
  |  |   86|  3.09k|#define assertf_(exp, file, line) assertf__(exp, #exp, file, line)
  |  |  ------------------
  |  |  |  |   81|  3.09k|  (void) ((exp) || (abortf_(sexp, file, line), 0))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (81:11): [True: 3.09k, False: 0]
  |  |  |  |  |  Branch (81:20): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  347|  3.09k|  return size;
  348|  3.09k|}
htslib.c:htssafe_strnlen_:
  316|  2.06k|                                                     size_t maxlen) {
  317|  2.06k|#if (defined(_WIN32) || (defined(HAVE_STRNLEN) && !defined(__STRICT_ANSI__)))
  318|  2.06k|  return strnlen(s, maxlen);
  319|       |#else
  320|       |  size_t i;
  321|       |  for (i = 0; i < maxlen && s[i] != '\0'; i++)
  322|       |    ;
  323|       |  return i;
  324|       |#endif
  325|  2.06k|}

