eventlog_free_contents:
   38|    415|{
   39|    415|    size_t i;
   40|    415|    debug_decl(eventlog_free_contents, SUDO_DEBUG_UTIL);
  ------------------
  |  |  119|    415|    debug_decl_vars((funcname), (subsys));				       \
  |  |  ------------------
  |  |  |  |  110|    415|    const unsigned int sudo_debug_subsys = (subsys)
  |  |  ------------------
  |  |  120|    415|    sudo_debug_enter(__func__, __FILE__, __LINE__, sudo_debug_subsys)
  |  |  ------------------
  |  |  |  |  236|    415|# define sudo_debug_enter(_a, _b, _c, _d)		((void)&(_d))
  |  |  ------------------
  ------------------
   41|       |
   42|    415|    free(evlog->iolog_path);
   43|    415|    free(evlog->command);
   44|    415|    free(evlog->cwd);
   45|    415|    free(evlog->runchroot);
   46|    415|    free(evlog->runcwd);
   47|    415|    free(evlog->rungroup);
   48|    415|    free(evlog->runuser);
   49|    415|    free(evlog->peeraddr);
   50|    415|    free(evlog->signal_name);
   51|    415|    free(evlog->source);
   52|    415|    if (evlog->submitenv != NULL) {
  ------------------
  |  Branch (52:9): [True: 0, False: 415]
  ------------------
   53|      0|	for (i = 0; evlog->submitenv[i] != NULL; i++)
  ------------------
  |  Branch (53:14): [True: 0, False: 0]
  ------------------
   54|      0|	    free(evlog->submitenv[i]);
   55|      0|	free(evlog->submitenv);
   56|      0|    }
   57|    415|    free(evlog->submithost);
   58|    415|    free(evlog->submituser);
   59|    415|    free(evlog->submitgroup);
   60|    415|    free(evlog->ttyname);
   61|    415|    if (evlog->runargv != NULL) {
  ------------------
  |  Branch (61:9): [True: 0, False: 415]
  ------------------
   62|      0|	for (i = 0; evlog->runargv[i] != NULL; i++)
  ------------------
  |  Branch (62:14): [True: 0, False: 0]
  ------------------
   63|      0|	    free(evlog->runargv[i]);
   64|      0|	free(evlog->runargv);
   65|      0|    }
   66|    415|    if (evlog->runenv != NULL) {
  ------------------
  |  Branch (66:9): [True: 0, False: 415]
  ------------------
   67|      0|	for (i = 0; evlog->runenv[i] != NULL; i++)
  ------------------
  |  Branch (67:14): [True: 0, False: 0]
  ------------------
   68|      0|	    free(evlog->runenv[i]);
   69|      0|	free(evlog->runenv);
   70|      0|    }
   71|    415|    if (evlog->env_add != NULL) {
  ------------------
  |  Branch (71:9): [True: 0, False: 415]
  ------------------
   72|      0|	for (i = 0; evlog->env_add[i] != NULL; i++)
  ------------------
  |  Branch (72:14): [True: 0, False: 0]
  ------------------
   73|      0|	    free(evlog->env_add[i]);
   74|      0|	free(evlog->env_add);
   75|      0|    }
   76|       |
   77|    415|    debug_return;
  ------------------
  |  |  257|    415|    do {								       \
  |  |  258|    415|	sudo_debug_exit(__func__, __FILE__, __LINE__, sudo_debug_subsys);      \
  |  |  ------------------
  |  |  |  |  237|    415|# define sudo_debug_exit(_a, _b, _c, _d)		((void)&(_d))
  |  |  ------------------
  |  |  259|    415|	return;								       \
  |  |  260|    415|    } while (0)
  |  |  ------------------
  |  |  |  Branch (260:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
   78|    415|}
eventlog_free:
   85|    415|{
   86|    415|    debug_decl(eventlog_free, SUDO_DEBUG_UTIL);
  ------------------
  |  |  119|    415|    debug_decl_vars((funcname), (subsys));				       \
  |  |  ------------------
  |  |  |  |  110|    415|    const unsigned int sudo_debug_subsys = (subsys)
  |  |  ------------------
  |  |  120|    415|    sudo_debug_enter(__func__, __FILE__, __LINE__, sudo_debug_subsys)
  |  |  ------------------
  |  |  |  |  236|    415|# define sudo_debug_enter(_a, _b, _c, _d)		((void)&(_d))
  |  |  ------------------
  ------------------
   87|       |
   88|    415|    if (evlog != NULL) {
  ------------------
  |  Branch (88:9): [True: 415, False: 0]
  ------------------
   89|    415|	eventlog_free_contents(evlog);
   90|    415|	free(evlog);
   91|    415|    }
   92|       |
   93|    415|    debug_return;
  ------------------
  |  |  257|    415|    do {								       \
  |  |  258|    415|	sudo_debug_exit(__func__, __FILE__, __LINE__, sudo_debug_subsys);      \
  |  |  ------------------
  |  |  |  |  237|    415|# define sudo_debug_exit(_a, _b, _c, _d)		((void)&(_d))
  |  |  ------------------
  |  |  259|    415|	return;								       \
  |  |  260|    415|    } while (0)
  |  |  ------------------
  |  |  |  Branch (260:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
   94|    415|}

iolog_parse_loginfo_legacy:
   44|    415|{
   45|    415|    char *buf = NULL, *cp, *ep;
   46|    415|    const char *errstr;
   47|    415|    size_t bufsize = 0, cwdsize = 0, cmdsize = 0;
   48|    415|    bool ret = false;
   49|    415|    debug_decl(iolog_parse_loginfo_legacy, SUDO_DEBUG_UTIL);
  ------------------
  |  |  119|    415|    debug_decl_vars((funcname), (subsys));				       \
  |  |  ------------------
  |  |  |  |  110|    415|    const unsigned int sudo_debug_subsys = (subsys)
  |  |  ------------------
  |  |  120|    415|    sudo_debug_enter(__func__, __FILE__, __LINE__, sudo_debug_subsys)
  |  |  ------------------
  |  |  |  |  236|    415|# define sudo_debug_enter(_a, _b, _c, _d)		((void)&(_d))
  |  |  ------------------
  ------------------
   50|       |
   51|       |    /*
   52|       |     * Info file has three lines:
   53|       |     *  1) a log info line
   54|       |     *  2) cwd
   55|       |     *  3) command with args
   56|       |     */
   57|    415|    if (getdelim(&buf, &bufsize, '\n', fp) == -1 ||
  ------------------
  |  Branch (57:9): [True: 0, False: 415]
  ------------------
   58|    415|	getdelim(&evlog->cwd, &cwdsize, '\n', fp) == -1 ||
  ------------------
  |  Branch (58:2): [True: 24, False: 391]
  ------------------
   59|    391|	getdelim(&evlog->command, &cmdsize, '\n', fp) == -1) {
  ------------------
  |  Branch (59:2): [True: 21, False: 370]
  ------------------
   60|     45|	sudo_warn(U_("%s: invalid log file"), iolog_dir);
  ------------------
  |  |   44|     45|# define sudo_warn sudo_warn_nodebug_v1
  ------------------
              	sudo_warn(U_("%s: invalid log file"), iolog_dir);
  ------------------
  |  |   59|     45|# define U_(String) sudo_warn_gettext(String)
  |  |  ------------------
  |  |  |  |  208|     45|# define sudo_warn_gettext(_a) sudo_warn_gettext_v1(NULL, (_a))
  |  |  ------------------
  ------------------
   61|     45|	goto done;
   62|     45|    }
   63|       |
   64|       |    /* Strip the newline from the cwd and command. */
   65|    370|    evlog->cwd[strcspn(evlog->cwd, "\n")] = '\0';
   66|    370|    evlog->command[strcspn(evlog->command, "\n")] = '\0';
   67|       |
   68|       |    /*
   69|       |     * Crack the log line (lines and cols not present in old versions).
   70|       |     *	timestamp:user:runas_user:runas_group:tty:lines:cols
   71|       |     * XXX - probably better to use strtok and switch on the state.
   72|       |     */
   73|    370|    buf[strcspn(buf, "\n")] = '\0';
   74|    370|    cp = buf;
   75|       |
   76|       |    /* timestamp */
   77|    370|    if ((ep = strchr(cp, ':')) == NULL) {
  ------------------
  |  Branch (77:9): [True: 19, False: 351]
  ------------------
   78|     19|	sudo_warn(U_("%s: time stamp field is missing"), iolog_dir);
  ------------------
  |  |   44|     19|# define sudo_warn sudo_warn_nodebug_v1
  ------------------
              	sudo_warn(U_("%s: time stamp field is missing"), iolog_dir);
  ------------------
  |  |   59|     19|# define U_(String) sudo_warn_gettext(String)
  |  |  ------------------
  |  |  |  |  208|     19|# define sudo_warn_gettext(_a) sudo_warn_gettext_v1(NULL, (_a))
  |  |  ------------------
  ------------------
   79|     19|	goto done;
   80|     19|    }
   81|    351|    *ep = '\0';
   82|    351|    evlog->event_time.tv_sec =
   83|    351|	(time_t)sudo_strtonum(cp, 0, TIME_T_MAX, &errstr);
  ------------------
  |  |   53|    351|#  define TIME_T_MAX	LLONG_MAX
  ------------------
   84|    351|    if (errstr != NULL) {
  ------------------
  |  Branch (84:9): [True: 112, False: 239]
  ------------------
   85|    112|	sudo_warn(U_("%s: time stamp %s: %s"), iolog_dir, cp, errstr);
  ------------------
  |  |   44|    112|# define sudo_warn sudo_warn_nodebug_v1
  ------------------
              	sudo_warn(U_("%s: time stamp %s: %s"), iolog_dir, cp, errstr);
  ------------------
  |  |   59|    112|# define U_(String) sudo_warn_gettext(String)
  |  |  ------------------
  |  |  |  |  208|    112|# define sudo_warn_gettext(_a) sudo_warn_gettext_v1(NULL, (_a))
  |  |  ------------------
  ------------------
   86|    112|	goto done;
   87|    112|    }
   88|       |
   89|       |    /* submit user */
   90|    239|    cp = ep + 1;
   91|    239|    if ((ep = strchr(cp, ':')) == NULL) {
  ------------------
  |  Branch (91:9): [True: 155, False: 84]
  ------------------
   92|    155|	sudo_warn(U_("%s: user field is missing"), iolog_dir);
  ------------------
  |  |   44|    155|# define sudo_warn sudo_warn_nodebug_v1
  ------------------
              	sudo_warn(U_("%s: user field is missing"), iolog_dir);
  ------------------
  |  |   59|    155|# define U_(String) sudo_warn_gettext(String)
  |  |  ------------------
  |  |  |  |  208|    155|# define sudo_warn_gettext(_a) sudo_warn_gettext_v1(NULL, (_a))
  |  |  ------------------
  ------------------
   93|    155|	goto done;
   94|    155|    }
   95|     84|    if ((evlog->submituser = strndup(cp, (size_t)(ep - cp))) == NULL) {
  ------------------
  |  Branch (95:9): [True: 0, False: 84]
  ------------------
   96|      0|	sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
  ------------------
  |  |   45|      0|# define sudo_warnx sudo_warnx_nodebug_v1
  ------------------
              	sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
  ------------------
  |  |   59|      0|# define U_(String) sudo_warn_gettext(String)
  |  |  ------------------
  |  |  |  |  208|      0|# define sudo_warn_gettext(_a) sudo_warn_gettext_v1(NULL, (_a))
  |  |  ------------------
  ------------------
              	sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
  ------------------
  |  |   59|      0|# define U_(String) sudo_warn_gettext(String)
  |  |  ------------------
  |  |  |  |  208|      0|# define sudo_warn_gettext(_a) sudo_warn_gettext_v1(NULL, (_a))
  |  |  ------------------
  ------------------
   97|      0|	goto done;
   98|      0|    }
   99|       |
  100|       |    /* runas user */
  101|     84|    cp = ep + 1;
  102|     84|    if ((ep = strchr(cp, ':')) == NULL) {
  ------------------
  |  Branch (102:9): [True: 1, False: 83]
  ------------------
  103|      1|	sudo_warn(U_("%s: runas user field is missing"), iolog_dir);
  ------------------
  |  |   44|      1|# define sudo_warn sudo_warn_nodebug_v1
  ------------------
              	sudo_warn(U_("%s: runas user field is missing"), iolog_dir);
  ------------------
  |  |   59|      1|# define U_(String) sudo_warn_gettext(String)
  |  |  ------------------
  |  |  |  |  208|      1|# define sudo_warn_gettext(_a) sudo_warn_gettext_v1(NULL, (_a))
  |  |  ------------------
  ------------------
  104|      1|	goto done;
  105|      1|    }
  106|     83|    if ((evlog->runuser = strndup(cp, (size_t)(ep - cp))) == NULL) {
  ------------------
  |  Branch (106:9): [True: 0, False: 83]
  ------------------
  107|      0|	sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
  ------------------
  |  |   45|      0|# define sudo_warnx sudo_warnx_nodebug_v1
  ------------------
              	sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
  ------------------
  |  |   59|      0|# define U_(String) sudo_warn_gettext(String)
  |  |  ------------------
  |  |  |  |  208|      0|# define sudo_warn_gettext(_a) sudo_warn_gettext_v1(NULL, (_a))
  |  |  ------------------
  ------------------
              	sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
  ------------------
  |  |   59|      0|# define U_(String) sudo_warn_gettext(String)
  |  |  ------------------
  |  |  |  |  208|      0|# define sudo_warn_gettext(_a) sudo_warn_gettext_v1(NULL, (_a))
  |  |  ------------------
  ------------------
  108|      0|	goto done;
  109|      0|    }
  110|       |
  111|       |    /* runas group */
  112|     83|    cp = ep + 1;
  113|     83|    if ((ep = strchr(cp, ':')) == NULL) {
  ------------------
  |  Branch (113:9): [True: 1, False: 82]
  ------------------
  114|      1|	sudo_warn(U_("%s: runas group field is missing"), iolog_dir);
  ------------------
  |  |   44|      1|# define sudo_warn sudo_warn_nodebug_v1
  ------------------
              	sudo_warn(U_("%s: runas group field is missing"), iolog_dir);
  ------------------
  |  |   59|      1|# define U_(String) sudo_warn_gettext(String)
  |  |  ------------------
  |  |  |  |  208|      1|# define sudo_warn_gettext(_a) sudo_warn_gettext_v1(NULL, (_a))
  |  |  ------------------
  ------------------
  115|      1|	goto done;
  116|      1|    }
  117|     82|    if (cp != ep) {
  ------------------
  |  Branch (117:9): [True: 1, False: 81]
  ------------------
  118|      1|	if ((evlog->rungroup = strndup(cp, (size_t)(ep - cp))) == NULL) {
  ------------------
  |  Branch (118:6): [True: 0, False: 1]
  ------------------
  119|      0|	    sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
  ------------------
  |  |   45|      0|# define sudo_warnx sudo_warnx_nodebug_v1
  ------------------
              	    sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
  ------------------
  |  |   59|      0|# define U_(String) sudo_warn_gettext(String)
  |  |  ------------------
  |  |  |  |  208|      0|# define sudo_warn_gettext(_a) sudo_warn_gettext_v1(NULL, (_a))
  |  |  ------------------
  ------------------
              	    sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
  ------------------
  |  |   59|      0|# define U_(String) sudo_warn_gettext(String)
  |  |  ------------------
  |  |  |  |  208|      0|# define sudo_warn_gettext(_a) sudo_warn_gettext_v1(NULL, (_a))
  |  |  ------------------
  ------------------
  120|      0|	    goto done;
  121|      0|	}
  122|      1|    }
  123|       |
  124|       |    /* tty, followed by optional lines + cols */
  125|     82|    cp = ep + 1;
  126|     82|    if ((ep = strchr(cp, ':')) == NULL) {
  ------------------
  |  Branch (126:9): [True: 2, False: 80]
  ------------------
  127|       |	/* just the tty */
  128|      2|	if ((evlog->ttyname = strdup(cp)) == NULL) {
  ------------------
  |  Branch (128:6): [True: 0, False: 2]
  ------------------
  129|      0|	    sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
  ------------------
  |  |   45|      0|# define sudo_warnx sudo_warnx_nodebug_v1
  ------------------
              	    sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
  ------------------
  |  |   59|      0|# define U_(String) sudo_warn_gettext(String)
  |  |  ------------------
  |  |  |  |  208|      0|# define sudo_warn_gettext(_a) sudo_warn_gettext_v1(NULL, (_a))
  |  |  ------------------
  ------------------
              	    sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
  ------------------
  |  |   59|      0|# define U_(String) sudo_warn_gettext(String)
  |  |  ------------------
  |  |  |  |  208|      0|# define sudo_warn_gettext(_a) sudo_warn_gettext_v1(NULL, (_a))
  |  |  ------------------
  ------------------
  130|      0|	    goto done;
  131|      0|	}
  132|     80|    } else {
  133|       |	/* tty followed by lines + cols */
  134|     80|	if ((evlog->ttyname = strndup(cp, (size_t)(ep - cp))) == NULL) {
  ------------------
  |  Branch (134:6): [True: 0, False: 80]
  ------------------
  135|      0|	    sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
  ------------------
  |  |   45|      0|# define sudo_warnx sudo_warnx_nodebug_v1
  ------------------
              	    sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
  ------------------
  |  |   59|      0|# define U_(String) sudo_warn_gettext(String)
  |  |  ------------------
  |  |  |  |  208|      0|# define sudo_warn_gettext(_a) sudo_warn_gettext_v1(NULL, (_a))
  |  |  ------------------
  ------------------
              	    sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
  ------------------
  |  |   59|      0|# define U_(String) sudo_warn_gettext(String)
  |  |  ------------------
  |  |  |  |  208|      0|# define sudo_warn_gettext(_a) sudo_warn_gettext_v1(NULL, (_a))
  |  |  ------------------
  ------------------
  136|      0|	    goto done;
  137|      0|	}
  138|     80|	cp = ep + 1;
  139|       |	/* need to NULL out separator to use sudo_strtonum() */
  140|       |	/* XXX - use sudo_strtonumx */
  141|     80|	if ((ep = strchr(cp, ':')) != NULL) {
  ------------------
  |  Branch (141:6): [True: 12, False: 68]
  ------------------
  142|     12|	    *ep = '\0';
  143|     12|	}
  144|     80|	evlog->lines = (int)sudo_strtonum(cp, 1, INT_MAX, &errstr);
  145|     80|	if (errstr != NULL) {
  ------------------
  |  Branch (145:6): [True: 55, False: 25]
  ------------------
  146|     55|	    sudo_debug_printf(SUDO_DEBUG_ERROR|SUDO_DEBUG_LINENO,
  ------------------
  |  |  394|     55|    sudo_debug_printf2(__func__, __FILE__, __LINE__, (pri)|sudo_debug_subsys, \
  |  |  ------------------
  |  |  |  |  443|     55|#define sudo_debug_printf2 sudo_debug_printf2_v1
  |  |  ------------------
  |  |  395|     55|    __VA_ARGS__)
  ------------------
  147|     55|		"%s: tty lines %s: %s", iolog_dir, cp, errstr);
  148|     55|	}
  149|     80|	if (ep != NULL) {
  ------------------
  |  Branch (149:6): [True: 12, False: 68]
  ------------------
  150|     12|	    cp = ep + 1;
  151|     12|	    evlog->columns = (int)sudo_strtonum(cp, 1, INT_MAX, &errstr);
  152|     12|	    if (errstr != NULL) {
  ------------------
  |  Branch (152:10): [True: 8, False: 4]
  ------------------
  153|      8|		sudo_debug_printf(SUDO_DEBUG_ERROR|SUDO_DEBUG_LINENO,
  ------------------
  |  |  394|      8|    sudo_debug_printf2(__func__, __FILE__, __LINE__, (pri)|sudo_debug_subsys, \
  |  |  ------------------
  |  |  |  |  443|      8|#define sudo_debug_printf2 sudo_debug_printf2_v1
  |  |  ------------------
  |  |  395|      8|    __VA_ARGS__)
  ------------------
  154|      8|		    "%s: tty cols %s: %s", iolog_dir, cp, errstr);
  155|      8|	    }
  156|     12|	}
  157|     80|    }
  158|       |
  159|     82|    ret = true;
  160|       |
  161|    415|done:
  162|    415|    free(buf);
  163|       |    debug_return_bool(ret);
  ------------------
  |  |  335|    415|    do {								       \
  |  |  336|    415|	bool sudo_debug_ret = (ret);					       \
  |  |  337|    415|	sudo_debug_exit_bool(__func__, __FILE__, __LINE__, sudo_debug_subsys,  \
  |  |  ------------------
  |  |  |  |  247|    415|# define sudo_debug_exit_bool(_a, _b, _c, _d, _e)	((void)&(_d))
  |  |  ------------------
  |  |  338|    415|	    sudo_debug_ret);						       \
  |  |  339|    415|	return sudo_debug_ret;						       \
  |  |  340|    415|    } while (0)
  |  |  ------------------
  |  |  |  Branch (340:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  164|    415|}

LLVMFuzzerTestOneInput:
   93|    415|{
   94|    415|    struct eventlog *evlog = NULL;
   95|    415|    FILE *fp;
   96|       |
   97|    415|    initprogname("fuzz_iolog_legacy");
   98|    415|    if (getenv("SUDO_FUZZ_VERBOSE") == NULL)
  ------------------
  |  Branch (98:9): [True: 415, False: 0]
  ------------------
   99|    415|	sudo_warn_set_conversation(fuzz_conversation);
  ------------------
  |  |  203|    415|#define sudo_warn_set_conversation(_a) sudo_warn_set_conversation_v1(_a)
  ------------------
  100|       |
  101|    415|    fp = open_data(data, size);
  102|    415|    if (fp == NULL)
  ------------------
  |  Branch (102:9): [True: 0, False: 415]
  ------------------
  103|      0|        return 0;
  104|       |
  105|       |    /* Parsed contents of an I/O log info file are stored in evlog. */
  106|    415|    evlog = calloc(1, sizeof(*evlog));
  107|    415|    if (evlog != NULL) {
  ------------------
  |  Branch (107:9): [True: 415, False: 0]
  ------------------
  108|    415|	evlog->runuid = (uid_t)-1;
  109|    415|	evlog->rungid = (gid_t)-1;
  110|       |
  111|       |	/* Try to parse buffer as a legacy-format I/O log info file. */
  112|    415|	iolog_parse_loginfo_legacy(fp, "fuzz.legacy", evlog);
  113|    415|	eventlog_free(evlog);
  114|    415|    }
  115|    415|    fclose(fp);
  116|    415|    fflush(stdout);
  117|       |
  118|    415|    return 0;
  119|    415|}
fuzz_iolog_legacy.c:fuzz_conversation:
   68|    333|{
   69|    333|    int n;
   70|       |
   71|  2.33k|    for (n = 0; n < num_msgs; n++) {
  ------------------
  |  Branch (71:17): [True: 1.99k, False: 333]
  ------------------
   72|  1.99k|	const struct sudo_conv_message *msg = &msgs[n];
   73|       |
   74|  1.99k|	switch (msg->msg_type & 0xff) {
   75|      0|	    case SUDO_CONV_PROMPT_ECHO_ON:
  ------------------
  |  |   44|      0|#define SUDO_CONV_PROMPT_ECHO_ON    0x0002  /* echo user input */
  ------------------
  |  Branch (75:6): [True: 0, False: 1.99k]
  ------------------
   76|      0|	    case SUDO_CONV_PROMPT_MASK:
  ------------------
  |  |   47|      0|#define SUDO_CONV_PROMPT_MASK	    0x0005  /* mask user input */
  ------------------
  |  Branch (76:6): [True: 0, False: 1.99k]
  ------------------
   77|      0|	    case SUDO_CONV_PROMPT_ECHO_OFF:
  ------------------
  |  |   43|      0|#define SUDO_CONV_PROMPT_ECHO_OFF   0x0001  /* do not echo user input */
  ------------------
  |  Branch (77:6): [True: 0, False: 1.99k]
  ------------------
   78|       |		/* input not supported */
   79|      0|		return -1;
   80|  1.99k|	    case SUDO_CONV_ERROR_MSG:
  ------------------
  |  |   45|  1.99k|#define SUDO_CONV_ERROR_MSG	    0x0003  /* error message */
  ------------------
  |  Branch (80:6): [True: 1.99k, False: 0]
  ------------------
   81|  1.99k|	    case SUDO_CONV_INFO_MSG:
  ------------------
  |  |   46|  1.99k|#define SUDO_CONV_INFO_MSG	    0x0004  /* informational message */
  ------------------
  |  Branch (81:6): [True: 0, False: 1.99k]
  ------------------
   82|       |		/* no output for fuzzers */
   83|  1.99k|		break;
   84|      0|	    default:
  ------------------
  |  Branch (84:6): [True: 0, False: 1.99k]
  ------------------
   85|      0|		return -1;
   86|  1.99k|	}
   87|  1.99k|    }
   88|    333|    return 0;
   89|    333|}
fuzz_iolog_legacy.c:open_data:
   41|    415|{
   42|    415|#ifdef HAVE_FMEMOPEN
   43|       |    /* Operate in-memory. */
   44|    415|    return fmemopen((void *)data, size, "r");
   45|       |#else
   46|       |    char tempfile[] = "/tmp/legacy.XXXXXX";
   47|       |    size_t nwritten;
   48|       |    int fd;
   49|       |
   50|       |    /* Use (unlinked) temporary file. */
   51|       |    fd = mkstemp(tempfile);
   52|       |    if (fd == -1)
   53|       |	return NULL;
   54|       |    unlink(tempfile);
   55|       |    nwritten = write(fd, data, size);
   56|       |    if (nwritten != size) {
   57|       |	close(fd);
   58|       |	return NULL;
   59|       |    }
   60|       |    lseek(fd, 0, SEEK_SET);
   61|       |    return fdopen(fd, "r");
   62|       |#endif
   63|    415|}

sudo_warn_nodebug_v1:
  112|    333|{
  113|    333|    va_list ap;
  114|       |
  115|    333|    va_start(ap, fmt);
  116|    333|    warning(strerror(errno), fmt, ap);
  117|       |    va_end(ap);
  118|    333|}
sudo_warn_set_conversation_v1:
  306|    415|{
  307|    415|    sudo_warn_conversation = conv;
  308|    415|}
sudo_warn_gettext_v1:
  324|    333|{
  325|    333|    int cookie;
  326|    333|    char *msg;
  327|       |
  328|       |    /* Set user locale if setter was specified. */
  329|    333|    if (sudo_warn_setlocale != NULL)
  ------------------
  |  Branch (329:9): [True: 0, False: 333]
  ------------------
  330|      0|	sudo_warn_setlocale(false, &cookie);
  331|       |
  332|    333|    msg = dgettext(domainname, msgid);
  333|       |
  334|       |    /* Restore old locale as needed. */
  335|    333|    if (sudo_warn_setlocale != NULL)
  ------------------
  |  Branch (335:9): [True: 0, False: 333]
  ------------------
  336|      0|	sudo_warn_setlocale(true, &cookie);
  337|       |
  338|    333|    return msg;
  339|    333|}
fatal.c:warning:
  179|    333|{
  180|    333|    int cookie;
  181|    333|    const int saved_errno = errno;
  182|       |
  183|       |    /* Set user locale if setter was specified. */
  184|    333|    if (sudo_warn_setlocale != NULL)
  ------------------
  |  Branch (184:9): [True: 0, False: 333]
  ------------------
  185|      0|	sudo_warn_setlocale(false, &cookie);
  186|       |
  187|    333|    if (sudo_warn_conversation != NULL) {
  ------------------
  |  Branch (187:9): [True: 333, False: 0]
  ------------------
  188|    333|	struct sudo_conv_message msgs[6];
  189|    333|	char static_buf[1024], *buf = static_buf;
  190|    333|	int nmsgs = 0;
  191|       |
  192|       |	/* Use conversation function. */
  193|    333|        msgs[nmsgs].msg_type = SUDO_CONV_ERROR_MSG;
  ------------------
  |  |   45|    333|#define SUDO_CONV_ERROR_MSG	    0x0003  /* error message */
  ------------------
  194|    333|	msgs[nmsgs++].msg = getprogname();
  ------------------
  |  |  540|    333|# define getprogname() sudo_getprogname()
  ------------------
  195|    333|        if (fmt != NULL) {
  ------------------
  |  Branch (195:13): [True: 333, False: 0]
  ------------------
  196|    333|		va_list ap2;
  197|    333|		int buflen;
  198|       |
  199|       |		/* Use static buffer if possible, else dynamic. */
  200|    333|		va_copy(ap2, ap);
  201|    333|		buflen = vsnprintf(static_buf, sizeof(static_buf), fmt, ap2);
  202|    333|		va_end(ap2);
  203|    333|		if (buflen >= ssizeof(static_buf)) {
  ------------------
  |  |  139|    333|#define ssizeof(_x)	((ssize_t)sizeof(_x))
  ------------------
  |  Branch (203:7): [True: 28, False: 305]
  ------------------
  204|       |		    /* Not enough room in static buf, allocate dynamically. */
  205|     28|		    if (vasprintf(&buf, fmt, ap) == -1)
  ------------------
  |  Branch (205:11): [True: 0, False: 28]
  ------------------
  206|      0|			buf = static_buf;
  207|     28|		}
  208|    333|		if (buflen > 0) {
  ------------------
  |  Branch (208:7): [True: 333, False: 0]
  ------------------
  209|    333|		    msgs[nmsgs].msg_type = SUDO_CONV_ERROR_MSG;
  ------------------
  |  |   45|    333|#define SUDO_CONV_ERROR_MSG	    0x0003  /* error message */
  ------------------
  210|    333|		    msgs[nmsgs++].msg = ": ";
  211|    333|		    msgs[nmsgs].msg_type = SUDO_CONV_ERROR_MSG;
  ------------------
  |  |   45|    333|#define SUDO_CONV_ERROR_MSG	    0x0003  /* error message */
  ------------------
  212|    333|		    msgs[nmsgs++].msg = buf;
  213|    333|		}
  214|    333|        }
  215|    333|        if (errstr != NULL) {
  ------------------
  |  Branch (215:13): [True: 333, False: 0]
  ------------------
  216|    333|	    msgs[nmsgs].msg_type = SUDO_CONV_ERROR_MSG;
  ------------------
  |  |   45|    333|#define SUDO_CONV_ERROR_MSG	    0x0003  /* error message */
  ------------------
  217|    333|	    msgs[nmsgs++].msg = ": ";
  218|    333|	    msgs[nmsgs].msg_type = SUDO_CONV_ERROR_MSG;
  ------------------
  |  |   45|    333|#define SUDO_CONV_ERROR_MSG	    0x0003  /* error message */
  ------------------
  219|    333|	    msgs[nmsgs++].msg = errstr;
  220|    333|        }
  221|    333|	msgs[nmsgs].msg_type = SUDO_CONV_ERROR_MSG;
  ------------------
  |  |   45|    333|#define SUDO_CONV_ERROR_MSG	    0x0003  /* error message */
  ------------------
  222|    333|	msgs[nmsgs++].msg = "\n";
  223|    333|	sudo_warn_conversation(nmsgs, msgs, NULL, NULL);
  224|    333|	if (buf != static_buf)
  ------------------
  |  Branch (224:6): [True: 28, False: 305]
  ------------------
  225|     28|	    free(buf);
  226|    333|    } else {
  227|       |	/* Write to the standard error. */
  228|      0|        fputs(getprogname(), stderr);
  ------------------
  |  |  540|      0|# define getprogname() sudo_getprogname()
  ------------------
  229|      0|        if (fmt != NULL) {
  ------------------
  |  Branch (229:13): [True: 0, False: 0]
  ------------------
  230|      0|                fputs(": ", stderr);
  231|      0|                vfprintf(stderr, fmt, ap);
  232|      0|        }
  233|      0|        if (errstr != NULL) {
  ------------------
  |  Branch (233:13): [True: 0, False: 0]
  ------------------
  234|      0|            fputs(": ", stderr);
  235|      0|            fputs(errstr, stderr);
  236|      0|        }
  237|       |#ifndef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
  238|       |        if (sudo_term_is_raw(fileno(stderr)))
  239|       |            putc('\r', stderr);
  240|       |#endif
  241|      0|        putc('\n', stderr);
  242|      0|    }
  243|       |
  244|       |    /* Restore old locale as needed. */
  245|    333|    if (sudo_warn_setlocale != NULL)
  ------------------
  |  Branch (245:9): [True: 0, False: 333]
  ------------------
  246|      0|	sudo_warn_setlocale(true, &cookie);
  247|       |
  248|       |    /* Do not clobber errno. */
  249|       |    errno = saved_errno;
  250|    333|}

sudo_getprogname:
   42|    748|{
   43|    748|    return __progname;
   44|    748|}
initprogname2:
   57|    415|{
   58|    415|    const char *progname;
   59|    415|    size_t i;
   60|       |
   61|       |    /* Fall back on "name" if getprogname() returns an empty string. */
   62|    415|    if ((progname = getprogname()) != NULL && *progname != '\0') {
  ------------------
  |  |  540|    415|# define getprogname() sudo_getprogname()
  ------------------
  |  Branch (62:9): [True: 415, False: 0]
  |  Branch (62:47): [True: 415, False: 0]
  ------------------
   63|    415|	name = progname;
   64|    415|    } else {
   65|       |	/* Make sure user-specified name is relative. */
   66|      0|	name = sudo_basename(name);
  ------------------
  |  |  189|      0|#define sudo_basename(_a) sudo_basename_v1(_a)
  ------------------
   67|      0|    }
   68|       |
   69|       |    /* Check for libtool prefix and strip it if present. */
   70|    415|    if (name[0] == 'l' && name[1] == 't' && name[2] == '-' && name[3] != '\0')
  ------------------
  |  Branch (70:9): [True: 0, False: 415]
  |  Branch (70:27): [True: 0, False: 0]
  |  Branch (70:45): [True: 0, False: 0]
  |  Branch (70:63): [True: 0, False: 0]
  ------------------
   71|      0|	name += 3;
   72|       |
   73|       |    /* Check allow list if present (first element is the default). */
   74|    415|    if (allowed != NULL) {
  ------------------
  |  Branch (74:9): [True: 0, False: 415]
  ------------------
   75|      0|	for (i = 0; ; i++) {
   76|      0|	    if (allowed[i] == NULL) {
  ------------------
  |  Branch (76:10): [True: 0, False: 0]
  ------------------
   77|      0|		name = allowed[0];
   78|      0|		break;
   79|      0|	    }
   80|      0|	    if (strcmp(allowed[i], name) == 0)
  ------------------
  |  Branch (80:10): [True: 0, False: 0]
  ------------------
   81|      0|		break;
   82|      0|	}
   83|      0|    }
   84|       |
   85|       |    /* Update internal progname if needed. */
   86|    415|    if (name != progname)
  ------------------
  |  Branch (86:9): [True: 0, False: 415]
  ------------------
   87|      0|	setprogname(name);
  ------------------
  |  |  545|      0|# define setprogname(_a) sudo_setprogname(_a)
  ------------------
   88|    415|    return;
   89|    415|}
initprogname:
   93|    415|{
   94|       |    initprogname2(name, NULL);
   95|    415|}

sudo_strtonumx:
   43|    443|{
   44|    443|    enum strtonum_err errval = STN_INITIAL;
   45|    443|    long long lastval, result = 0;
   46|    443|    const char *cp = str;
   47|    443|    int remainder;
   48|    443|    char ch, sign;
   49|       |
   50|    443|    if (minval > maxval) {
  ------------------
  |  Branch (50:9): [True: 0, False: 443]
  ------------------
   51|      0|	errval = STN_INVALID;
   52|      0|	goto done;
   53|      0|    }
   54|       |
   55|       |    /* Trim leading space and check sign, if any. */
   56|    668|    do {
   57|    668|	ch = *cp++;
   58|    668|    } while (isspace((unsigned char)ch));
  ------------------
  |  Branch (58:14): [True: 225, False: 443]
  ------------------
   59|    443|    switch (ch) {
   60|     55|    case '-':
  ------------------
  |  Branch (60:5): [True: 55, False: 388]
  ------------------
   61|     55|	sign = '-';
   62|     55|	ch = *cp++;
   63|     55|	break;
   64|      6|    case '+':
  ------------------
  |  Branch (64:5): [True: 6, False: 437]
  ------------------
   65|      6|	ch = *cp++;
   66|      6|	FALLTHROUGH;
  ------------------
  |  | 1642|      6|# define FALLTHROUGH		[[__fallthrough__]]
  ------------------
   67|    388|    default:
  ------------------
  |  Branch (67:5): [True: 382, False: 61]
  ------------------
   68|    388|	sign = '+';
   69|    388|	break;
   70|    443|    }
   71|       |
   72|       |    /*
   73|       |     * To prevent overflow we determine the highest (or lowest in
   74|       |     * the case of negative numbers) value result can have *before*
   75|       |     * if its multiplied (divided) by 10 as well as the remainder.
   76|       |     * If result matches this value and the next digit is larger than
   77|       |     * the remainder, we know the result is out of range.
   78|       |     * The remainder is always positive since it is compared against
   79|       |     * an unsigned digit.
   80|       |     */
   81|    443|    if (sign == '-') {
  ------------------
  |  Branch (81:9): [True: 55, False: 388]
  ------------------
   82|     55|	lastval = minval / 10;
   83|     55|	remainder = -(int)(minval % 10);
   84|     55|	if (remainder < 0) {
  ------------------
  |  Branch (84:6): [True: 9, False: 46]
  ------------------
   85|      9|	    lastval += 1;
   86|      9|	    remainder += 10;
   87|      9|	}
   88|    550|	for (;; ch = *cp++) {
   89|    550|	    if (!isdigit((unsigned char)ch))
  ------------------
  |  Branch (89:10): [True: 18, False: 532]
  ------------------
   90|     18|		break;
   91|    532|	    ch -= '0';
   92|    532|	    if (result < lastval || (result == lastval && ch > remainder)) {
  ------------------
  |  Branch (92:10): [True: 3, False: 529]
  |  Branch (92:31): [True: 529, False: 0]
  |  Branch (92:52): [True: 34, False: 495]
  ------------------
   93|       |		/* Skip remaining digits. */
   94|  3.11M|		do {
   95|  3.11M|		    ch = *cp++;
   96|  3.11M|		} while (isdigit((unsigned char)ch));
  ------------------
  |  Branch (96:12): [True: 3.11M, False: 37]
  ------------------
   97|     37|		errval = STN_TOOSMALL;
   98|     37|		break;
   99|    495|	    } else {
  100|    495|		result *= 10;
  101|    495|		result -= ch;
  102|    495|		errval = STN_VALID;
  103|    495|	    }
  104|    532|	}
  105|     55|	if (result > maxval)
  ------------------
  |  Branch (105:6): [True: 0, False: 55]
  ------------------
  106|      0|	    errval = STN_TOOBIG;
  107|    388|    } else {
  108|    388|	lastval = maxval / 10;
  109|    388|	remainder = (int)(maxval % 10);
  110|  8.39k|	for (;; ch = *cp++) {
  111|  8.39k|	    if (!isdigit((unsigned char)ch))
  ------------------
  |  Branch (111:10): [True: 284, False: 8.10k]
  ------------------
  112|    284|		break;
  113|  8.10k|	    ch -= '0';
  114|  8.10k|	    if (result > lastval || (result == lastval && ch > remainder)) {
  ------------------
  |  Branch (114:10): [True: 99, False: 8.01k]
  |  Branch (114:31): [True: 17, False: 7.99k]
  |  Branch (114:52): [True: 5, False: 12]
  ------------------
  115|       |		/* Skip remaining digits. */
  116|  1.07M|		do {
  117|  1.07M|		    ch = *cp++;
  118|  1.07M|		} while (isdigit((unsigned char)ch));
  ------------------
  |  Branch (118:12): [True: 1.07M, False: 104]
  ------------------
  119|    104|		errval = STN_TOOBIG;
  120|    104|		break;
  121|  8.00k|	    } else {
  122|  8.00k|		result *= 10;
  123|  8.00k|		result += ch;
  124|  8.00k|		errval = STN_VALID;
  125|  8.00k|	    }
  126|  8.10k|	}
  127|    388|	if (result < minval)
  ------------------
  |  Branch (127:6): [True: 7, False: 381]
  ------------------
  128|      7|	    errval = STN_TOOSMALL;
  129|    388|    }
  130|       |
  131|    443|done:
  132|    443|    switch (errval) {
  ------------------
  |  Branch (132:13): [True: 443, False: 0]
  ------------------
  133|     17|    case STN_INITIAL:
  ------------------
  |  Branch (133:5): [True: 17, False: 426]
  ------------------
  134|    295|    case STN_VALID:
  ------------------
  |  Branch (134:5): [True: 278, False: 165]
  ------------------
  135|    295|	if (errstrp != NULL)
  ------------------
  |  Branch (135:6): [True: 295, False: 0]
  ------------------
  136|    295|	    *errstrp = NULL;
  137|    295|	break;
  138|      0|    case STN_INVALID:
  ------------------
  |  Branch (138:5): [True: 0, False: 443]
  ------------------
  139|      0|	result = 0;
  140|      0|	errno = EINVAL;
  141|      0|	if (errstrp != NULL)
  ------------------
  |  Branch (141:6): [True: 0, False: 0]
  ------------------
  142|      0|	    *errstrp = N_("invalid value");
  ------------------
  |  |   58|      0|# define N_(String) gettext_noop(String)
  |  |  ------------------
  |  |  |  |   57|      0|# define gettext_noop(String) String
  |  |  ------------------
  ------------------
  143|      0|	break;
  144|     44|    case STN_TOOSMALL:
  ------------------
  |  Branch (144:5): [True: 44, False: 399]
  ------------------
  145|     44|	result = 0;
  146|     44|	errno = ERANGE;
  147|     44|	if (errstrp != NULL)
  ------------------
  |  Branch (147:6): [True: 44, False: 0]
  ------------------
  148|     44|	    *errstrp = N_("value too small");
  ------------------
  |  |   58|     44|# define N_(String) gettext_noop(String)
  |  |  ------------------
  |  |  |  |   57|     44|# define gettext_noop(String) String
  |  |  ------------------
  ------------------
  149|     44|	break;
  150|    104|    case STN_TOOBIG:
  ------------------
  |  Branch (150:5): [True: 104, False: 339]
  ------------------
  151|    104|	result = 0;
  152|    104|	errno = ERANGE;
  153|    104|	if (errstrp != NULL)
  ------------------
  |  Branch (153:6): [True: 104, False: 0]
  ------------------
  154|    104|	    *errstrp = N_("value too large");
  ------------------
  |  |   58|    104|# define N_(String) gettext_noop(String)
  |  |  ------------------
  |  |  |  |   57|    104|# define gettext_noop(String) String
  |  |  ------------------
  ------------------
  155|    104|	break;
  156|    443|    }
  157|    443|    if (endp != NULL) {
  ------------------
  |  Branch (157:9): [True: 443, False: 0]
  ------------------
  158|    443|	if (errval == STN_INITIAL || errval == STN_INVALID)
  ------------------
  |  Branch (158:6): [True: 17, False: 426]
  |  Branch (158:31): [True: 0, False: 426]
  ------------------
  159|     17|	    *endp = (char *)str;
  160|    426|	else
  161|    426|	    *endp = (char *)(cp - 1);
  162|    443|    }
  163|    443|    return result;
  164|    443|}
sudo_strtonum:
  172|    443|{
  173|    443|    const char *errstr;
  174|    443|    char *ep;
  175|    443|    long long ret;
  176|       |
  177|    443|    ret = sudo_strtonumx(str, minval, maxval, &ep, &errstr);
  178|       |    /* Check for empty string and terminating NUL. */
  179|    443|    if (str == ep || *ep != '\0') {
  ------------------
  |  Branch (179:9): [True: 21, False: 422]
  |  Branch (179:22): [True: 10, False: 412]
  ------------------
  180|     31|	errno = EINVAL;
  181|     31|	errstr = N_("invalid value");
  ------------------
  |  |   58|     31|# define N_(String) gettext_noop(String)
  |  |  ------------------
  |  |  |  |   57|     31|# define gettext_noop(String) String
  |  |  ------------------
  ------------------
  182|     31|	ret = 0;
  183|     31|    }
  184|    443|    if (errstrp != NULL)
  ------------------
  |  Branch (184:9): [True: 443, False: 0]
  ------------------
  185|    443|	*errstrp = errstr;
  186|    443|    return ret;
  187|    443|}

sudo_debug_printf2_v1:
 1149|     63|{
 1150|     63|}

