asn_parse_nlength:
  325|  51.3k|{
  326|  51.3k|    int len_len;
  327|       |
  328|  51.3k|    if (pkt_len < 1)
  ------------------
  |  Branch (328:9): [True: 0, False: 51.3k]
  ------------------
  329|      0|        return NULL;               /* always too short */
  330|       |
  331|  51.3k|    if (NULL == pkt || NULL == data_len)
  ------------------
  |  Branch (331:9): [True: 0, False: 51.3k]
  |  Branch (331:24): [True: 0, False: 51.3k]
  ------------------
  332|      0|        return NULL;
  333|       |
  334|  51.3k|    *data_len = 0;
  335|       |
  336|  51.3k|    if (*pkt & 0x80) {
  ------------------
  |  Branch (336:9): [True: 2.08k, False: 49.2k]
  ------------------
  337|       |        /*
  338|       |         * long length; first byte is length of length (after masking high bit)
  339|       |         */
  340|  2.08k|        len_len = (int) ((*pkt & ~0x80) + 1);
  341|  2.08k|        if (pkt_len < len_len)
  ------------------
  |  Branch (341:13): [True: 160, False: 1.92k]
  ------------------
  342|    160|            return NULL;           /* still too short for length and data */
  343|       |
  344|       |        /* now we know we have enough data to parse length */
  345|  1.92k|        if (NULL == asn_parse_length(pkt, data_len))
  ------------------
  |  Branch (345:13): [True: 320, False: 1.60k]
  ------------------
  346|    320|            return NULL;           /* propagate error from asn_parse_length */
  347|  49.2k|    } else {
  348|       |        /*
  349|       |         * short length; first byte is the length
  350|       |         */
  351|  49.2k|        len_len = 1;
  352|  49.2k|        *data_len = *pkt;
  353|  49.2k|    }
  354|       |
  355|  50.8k|    if ((*data_len + len_len) > pkt_len)
  ------------------
  |  Branch (355:9): [True: 950, False: 49.9k]
  ------------------
  356|    950|        return NULL;
  357|       |
  358|  49.9k|    return (pkt + len_len);
  359|  50.8k|}
asn_parse_int:
  559|  15.9k|{
  560|       |    /*
  561|       |     * ASN.1 integer ::= 0x02 asnlength byte {byte}*
  562|       |     */
  563|  15.9k|    static const char *errpre = "parse int";
  564|  15.9k|    register u_char *bufp = data;
  565|  15.9k|    u_long          asn_length;
  566|  15.9k|    int             i;
  567|  15.9k|    union {
  568|  15.9k|        long          l;
  569|  15.9k|        unsigned char b[sizeof(long)];
  570|  15.9k|    } value;
  571|       |
  572|  15.9k|    if (NULL == data || NULL == datalength || NULL == type || NULL == intp) {
  ------------------
  |  Branch (572:9): [True: 0, False: 15.9k]
  |  Branch (572:25): [True: 0, False: 15.9k]
  |  Branch (572:47): [True: 0, False: 15.9k]
  |  Branch (572:63): [True: 0, False: 15.9k]
  ------------------
  573|      0|        ERROR_MSG("parse int: NULL pointer");
  ------------------
  |  |  188|      0|#define ERROR_MSG(string)	snmp_set_detail(string)
  ------------------
  574|      0|        return NULL;
  575|      0|    }
  576|       |
  577|  15.9k|    if (intsize != sizeof(long)) {
  ------------------
  |  Branch (577:9): [True: 0, False: 15.9k]
  ------------------
  578|      0|        _asn_size_err(errpre, intsize, sizeof(long));
  579|      0|        return NULL;
  580|      0|    }
  581|       |
  582|       |    /** need at least 2 bytes to work with: type, length (which might be 0)  */
  583|  15.9k|    if (*datalength < 2) {
  ------------------
  |  Branch (583:9): [True: 72, False: 15.8k]
  ------------------
  584|     72|        _asn_short_err(errpre, *datalength, 2);
  585|     72|        return NULL;
  586|     72|    }
  587|       |
  588|  15.8k|    *type = *bufp++;
  589|  15.8k|    if (*type != ASN_INTEGER) {
  ------------------
  |  |   75|  15.8k|#define ASN_INTEGER	    0x02U
  ------------------
  |  Branch (589:9): [True: 21, False: 15.8k]
  ------------------
  590|     21|        _asn_type_err(errpre, *type);
  591|     21|        return NULL;
  592|     21|    }
  593|       |
  594|  15.8k|    bufp = asn_parse_nlength(bufp, *datalength - 1, &asn_length);
  595|  15.8k|    if (NULL == bufp) {
  ------------------
  |  Branch (595:9): [True: 171, False: 15.6k]
  ------------------
  596|    171|        _asn_short_err(errpre, *datalength - 1, asn_length);
  597|    171|        return NULL;
  598|    171|    }
  599|       |
  600|  15.6k|    if ((size_t) asn_length > intsize || (int) asn_length == 0) {
  ------------------
  |  Branch (600:9): [True: 22, False: 15.6k]
  |  Branch (600:42): [True: 8, False: 15.6k]
  ------------------
  601|     30|        _asn_length_err(errpre, (size_t) asn_length, intsize);
  602|     30|        return NULL;
  603|     30|    }
  604|       |
  605|  15.6k|    *datalength -= (int) asn_length + (bufp - data);
  606|       |
  607|  15.6k|    DEBUGDUMPSETUP("recv", data, bufp - data + asn_length);
  ------------------
  |  |   83|  15.6k|	do {if (_DBG_IF_) {__DBGDUMPSETUP(token,buf,len);} }while(0)
  |  |  ------------------
  |  |  |  |  144|  15.6k|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 15.6k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               	do {if (_DBG_IF_) {__DBGDUMPSETUP(token,buf,len);} }while(0)
  |  |  ------------------
  |  |  |  |  196|      0|        debugmsg("dumpx" token, "dumpx_%s:%*s", token, __DBGINDENT(), ""); \
  |  |  |  |  ------------------
  |  |  |  |  |  |  171|      0|#define __DBGINDENT()      debug_indent_get()
  |  |  |  |  ------------------
  |  |  |  |  197|      0|        __DBGMSGHEX(("dumpx_" token,buf,len)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |  169|      0|#define __DBGMSGHEX(x)     debugmsg_hex x
  |  |  |  |  ------------------
  |  |  |  |  198|      0|        if (debug_is_token_registered("dumpv" token) == SNMPERR_SUCCESS || \
  |  |  |  |  ------------------
  |  |  |  |  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (198:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  199|      0|            debug_is_token_registered("dumpv_" token) != SNMPERR_SUCCESS) { \
  |  |  |  |  ------------------
  |  |  |  |  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (199:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  200|      0|            debugmsg("dumpx_" token,"\n"); \
  |  |  |  |  201|      0|        } else { \
  |  |  |  |  202|      0|            debugmsg("dumpx_" token,"  "); \
  |  |  |  |  203|      0|        } \
  |  |  |  |  204|      0|        debugmsg("dumpv" token, "dumpv_%s:%*s", token, __DBGINDENT(), "");
  |  |  |  |  ------------------
  |  |  |  |  |  |  171|      0|#define __DBGINDENT()      debug_indent_get()
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (83:60): [Folded, False: 15.6k]
  |  |  ------------------
  ------------------
  608|       |
  609|  15.6k|    memset(&value.b, *bufp & 0x80 ? 0xff : 0, sizeof(value.b));
  ------------------
  |  Branch (609:22): [True: 1.03k, False: 14.5k]
  ------------------
  610|  15.6k|    if (NETSNMP_BIGENDIAN) {
  ------------------
  |  | 2425|  15.6k|#  define NETSNMP_BIGENDIAN 0
  |  |  ------------------
  |  |  |  Branch (2425:29): [Folded, False: 15.6k]
  |  |  ------------------
  ------------------
  611|      0|        for (i = sizeof(long) - asn_length; asn_length--; i++)
  ------------------
  |  Branch (611:45): [True: 0, False: 0]
  ------------------
  612|      0|            value.b[i] = *bufp++;
  613|  15.6k|    } else {
  614|  40.6k|        for (i = asn_length - 1; asn_length--; i--)
  ------------------
  |  Branch (614:34): [True: 25.0k, False: 15.6k]
  ------------------
  615|  25.0k|            value.b[i] = *bufp++;
  616|  15.6k|    }
  617|       |
  618|  15.6k|    CHECK_OVERFLOW_S(value.l, 1);
  ------------------
  |  |  214|  15.6k|#define CHECK_OVERFLOW_S(x,y) do {                                      \
  |  |  215|  15.6k|        if (x > INT32_MAX) {                                            \
  |  |  ------------------
  |  |  |  Branch (215:13): [True: 168, False: 15.4k]
  |  |  ------------------
  |  |  216|    168|            DEBUGMSG(("asn","truncating signed value %ld to 32 bits (%d)\n",(long)(x),y)); \
  |  |  ------------------
  |  |  |  |   61|    168|#define DEBUGMSG(x)        do {if (_DBG_IF_) {debugmsg x;} }while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  |  144|    168|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (144:29): [True: 0, False: 168]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (61:67): [Folded, False: 168]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  217|    168|            x &= 0xffffffff;                                            \
  |  |  218|  15.4k|        } else if (x < INT32_MIN) {                                     \
  |  |  ------------------
  |  |  |  Branch (218:20): [True: 125, False: 15.3k]
  |  |  ------------------
  |  |  219|    125|            DEBUGMSG(("asn","truncating signed value %ld to 32 bits (%d)\n",(long)(x),y)); \
  |  |  ------------------
  |  |  |  |   61|    125|#define DEBUGMSG(x)        do {if (_DBG_IF_) {debugmsg x;} }while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  |  144|    125|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (144:29): [True: 0, False: 125]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (61:67): [Folded, False: 125]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  220|    125|            x = 0 - (x & 0xffffffff);                                   \
  |  |  221|    125|        }                                                               \
  |  |  222|  15.6k|    } while(0)
  |  |  ------------------
  |  |  |  Branch (222:13): [Folded, False: 15.6k]
  |  |  ------------------
  ------------------
  619|       |
  620|  15.6k|    DEBUGMSG(("dumpv_recv", "  Integer:\t%ld (0x%.2lX)\n", value.l, value.l));
  ------------------
  |  |   61|  15.6k|#define DEBUGMSG(x)        do {if (_DBG_IF_) {debugmsg x;} }while(0)
  |  |  ------------------
  |  |  |  |  144|  15.6k|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 15.6k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (61:67): [Folded, False: 15.6k]
  |  |  ------------------
  ------------------
  621|       |
  622|  15.6k|    *intp = value.l;
  623|  15.6k|    return bufp;
  624|  15.6k|}
asn_parse_unsigned_int:
  652|    428|{
  653|       |    /*
  654|       |     * ASN.1 integer ::= 0x02 asnlength byte {byte}*
  655|       |     */
  656|    428|    static const char *errpre = "parse uint";
  657|    428|    register u_char *bufp = data;
  658|    428|    u_long          asn_length;
  659|    428|    register u_long value = 0;
  660|       |
  661|    428|    if (NULL == data || NULL == datalength || NULL == type || NULL == intp) {
  ------------------
  |  Branch (661:9): [True: 0, False: 428]
  |  Branch (661:25): [True: 0, False: 428]
  |  Branch (661:47): [True: 0, False: 428]
  |  Branch (661:63): [True: 0, False: 428]
  ------------------
  662|      0|        ERROR_MSG("parse uint: NULL pointer");
  ------------------
  |  |  188|      0|#define ERROR_MSG(string)	snmp_set_detail(string)
  ------------------
  663|      0|        return NULL;
  664|      0|    }
  665|       |
  666|    428|    if (intsize != sizeof(long)) {
  ------------------
  |  Branch (666:9): [True: 0, False: 428]
  ------------------
  667|      0|        _asn_size_err(errpre, intsize, sizeof(long));
  668|      0|        return NULL;
  669|      0|    }
  670|       |
  671|       |    /** need at least 2 bytes to work with: type, length (which might be 0)  */
  672|    428|    if (*datalength < 2) {
  ------------------
  |  Branch (672:9): [True: 2, False: 426]
  ------------------
  673|      2|        _asn_short_err(errpre, *datalength, 2);
  674|      2|        return NULL;
  675|      2|    }
  676|       |
  677|    426|    *type = *bufp++;
  678|    426|    if (*type != ASN_COUNTER && *type != ASN_GAUGE && *type != ASN_TIMETICKS
  ------------------
  |  |   89|    852|#define ASN_COUNTER	(ASN_APPLICATION | 1)
  |  |  ------------------
  |  |  |  |   91|    426|#define ASN_APPLICATION     0x40U
  |  |  ------------------
  ------------------
                  if (*type != ASN_COUNTER && *type != ASN_GAUGE && *type != ASN_TIMETICKS
  ------------------
  |  |   90|    800|#define ASN_GAUGE	(ASN_APPLICATION | 2)
  |  |  ------------------
  |  |  |  |   91|    374|#define ASN_APPLICATION     0x40U
  |  |  ------------------
  ------------------
                  if (*type != ASN_COUNTER && *type != ASN_GAUGE && *type != ASN_TIMETICKS
  ------------------
  |  |   92|    764|#define ASN_TIMETICKS   (ASN_APPLICATION | 3)
  |  |  ------------------
  |  |  |  |   91|    338|#define ASN_APPLICATION     0x40U
  |  |  ------------------
  ------------------
  |  Branch (678:9): [True: 374, False: 52]
  |  Branch (678:33): [True: 338, False: 36]
  |  Branch (678:55): [True: 235, False: 103]
  ------------------
  679|    235|            && *type != ASN_UINTEGER) {
  ------------------
  |  |  100|    235|#define ASN_UINTEGER    (ASN_APPLICATION | 7)   /* historic - don't use */
  |  |  ------------------
  |  |  |  |   91|    235|#define ASN_APPLICATION     0x40U
  |  |  ------------------
  ------------------
  |  Branch (679:16): [True: 22, False: 213]
  ------------------
  680|     22|        _asn_type_err(errpre, *type);
  681|     22|        return NULL;
  682|     22|    }
  683|       |
  684|    404|    bufp = asn_parse_nlength(bufp, *datalength - 1, &asn_length);
  685|    404|    if (NULL == bufp) {
  ------------------
  |  Branch (685:9): [True: 150, False: 254]
  ------------------
  686|    150|        _asn_short_err(errpre, *datalength - 1, asn_length);
  687|    150|        return NULL;
  688|    150|    }
  689|       |
  690|    254|    if ((asn_length > (intsize + 1)) || ((int) asn_length == 0) ||
  ------------------
  |  Branch (690:9): [True: 7, False: 247]
  |  Branch (690:41): [True: 9, False: 238]
  ------------------
  691|    238|        ((asn_length == intsize + 1) && *bufp != 0x00)) {
  ------------------
  |  Branch (691:10): [True: 56, False: 182]
  |  Branch (691:41): [True: 10, False: 46]
  ------------------
  692|     26|        _asn_length_err(errpre, (size_t) asn_length, intsize);
  693|     26|        return NULL;
  694|     26|    }
  695|    228|    *datalength -= (int) asn_length + (bufp - data);
  696|       |
  697|    228|    DEBUGDUMPSETUP("recv", data, bufp - data + asn_length);
  ------------------
  |  |   83|    228|	do {if (_DBG_IF_) {__DBGDUMPSETUP(token,buf,len);} }while(0)
  |  |  ------------------
  |  |  |  |  144|    228|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 228]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               	do {if (_DBG_IF_) {__DBGDUMPSETUP(token,buf,len);} }while(0)
  |  |  ------------------
  |  |  |  |  196|      0|        debugmsg("dumpx" token, "dumpx_%s:%*s", token, __DBGINDENT(), ""); \
  |  |  |  |  ------------------
  |  |  |  |  |  |  171|      0|#define __DBGINDENT()      debug_indent_get()
  |  |  |  |  ------------------
  |  |  |  |  197|      0|        __DBGMSGHEX(("dumpx_" token,buf,len)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |  169|      0|#define __DBGMSGHEX(x)     debugmsg_hex x
  |  |  |  |  ------------------
  |  |  |  |  198|      0|        if (debug_is_token_registered("dumpv" token) == SNMPERR_SUCCESS || \
  |  |  |  |  ------------------
  |  |  |  |  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (198:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  199|      0|            debug_is_token_registered("dumpv_" token) != SNMPERR_SUCCESS) { \
  |  |  |  |  ------------------
  |  |  |  |  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (199:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  200|      0|            debugmsg("dumpx_" token,"\n"); \
  |  |  |  |  201|      0|        } else { \
  |  |  |  |  202|      0|            debugmsg("dumpx_" token,"  "); \
  |  |  |  |  203|      0|        } \
  |  |  |  |  204|      0|        debugmsg("dumpv" token, "dumpv_%s:%*s", token, __DBGINDENT(), "");
  |  |  |  |  ------------------
  |  |  |  |  |  |  171|      0|#define __DBGINDENT()      debug_indent_get()
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (83:60): [Folded, False: 228]
  |  |  ------------------
  ------------------
  698|       |
  699|  1.13k|    while (asn_length--)
  ------------------
  |  Branch (699:12): [True: 902, False: 228]
  ------------------
  700|    902|        value = (value << 8) | *bufp++;
  701|       |
  702|    228|    CHECK_OVERFLOW_U(value,2);
  ------------------
  |  |  224|    228|#define CHECK_OVERFLOW_U(x,y) do {                                      \
  |  |  225|    228|        if (x > UINT32_MAX) {                                           \
  |  |  ------------------
  |  |  |  Branch (225:13): [True: 73, False: 155]
  |  |  ------------------
  |  |  226|     73|            x &= 0xffffffff;                                            \
  |  |  227|     73|            DEBUGMSG(("asn","truncating unsigned value to 32 bits (%d)\n",y)); \
  |  |  ------------------
  |  |  |  |   61|     73|#define DEBUGMSG(x)        do {if (_DBG_IF_) {debugmsg x;} }while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  |  144|     73|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (144:29): [True: 0, False: 73]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (61:67): [Folded, False: 73]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  228|     73|        }                                                               \
  |  |  229|    228|    } while(0)
  |  |  ------------------
  |  |  |  Branch (229:13): [Folded, False: 228]
  |  |  ------------------
  ------------------
  703|       |
  704|    228|    DEBUGMSG(("dumpv_recv", "  UInteger:\t%ld (0x%.2lX)\n", value, value));
  ------------------
  |  |   61|    228|#define DEBUGMSG(x)        do {if (_DBG_IF_) {debugmsg x;} }while(0)
  |  |  ------------------
  |  |  |  |  144|    228|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 228]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (61:67): [Folded, False: 228]
  |  |  ------------------
  ------------------
  705|       |
  706|    228|    *intp = value;
  707|    228|    return bufp;
  708|    254|}
asn_parse_string:
  912|  15.0k|{
  913|  15.0k|    static const char *errpre = "parse string";
  914|  15.0k|    u_char         *bufp = data;
  915|  15.0k|    u_long          asn_length;
  916|       |
  917|  15.0k|    if (NULL == data || NULL == datalength || NULL == type || NULL == str ||
  ------------------
  |  Branch (917:9): [True: 0, False: 15.0k]
  |  Branch (917:25): [True: 0, False: 15.0k]
  |  Branch (917:47): [True: 0, False: 15.0k]
  |  Branch (917:63): [True: 2.72k, False: 12.3k]
  ------------------
  918|  15.0k|        NULL == strlength) {
  ------------------
  |  Branch (918:9): [True: 0, False: 12.3k]
  ------------------
  919|  2.72k|        ERROR_MSG("parse string: NULL pointer");
  ------------------
  |  |  188|  2.72k|#define ERROR_MSG(string)	snmp_set_detail(string)
  ------------------
  920|  2.72k|        return NULL;
  921|  2.72k|    }
  922|       |
  923|       |    /** need at least 2 bytes to work with: type, length (which might be 0)  */
  924|  12.3k|    if (*datalength < 2) {
  ------------------
  |  Branch (924:9): [True: 166, False: 12.1k]
  ------------------
  925|    166|        _asn_short_err(errpre, *datalength, 2);
  926|    166|        return NULL;
  927|    166|    }
  928|       |
  929|  12.1k|    *type = *bufp++;
  930|  12.1k|    if (*type != ASN_OCTET_STR && *type != ASN_IPADDRESS && *type != ASN_OPAQUE
  ------------------
  |  |   78|  24.3k|#define ASN_OCTET_STR	    0x04U
  ------------------
                  if (*type != ASN_OCTET_STR && *type != ASN_IPADDRESS && *type != ASN_OPAQUE
  ------------------
  |  |   88|  13.3k|#define ASN_IPADDRESS   (ASN_APPLICATION | 0)
  |  |  ------------------
  |  |  |  |   91|  1.15k|#define ASN_APPLICATION     0x40U
  |  |  ------------------
  ------------------
                  if (*type != ASN_OCTET_STR && *type != ASN_IPADDRESS && *type != ASN_OPAQUE
  ------------------
  |  |   93|  12.6k|#define ASN_OPAQUE	(ASN_APPLICATION | 4)   /* changed so no conflict with other includes */
  |  |  ------------------
  |  |  |  |   91|    456|#define ASN_APPLICATION     0x40U
  |  |  ------------------
  ------------------
  |  Branch (930:9): [True: 1.15k, False: 11.0k]
  |  Branch (930:35): [True: 456, False: 695]
  |  Branch (930:61): [True: 159, False: 297]
  ------------------
  931|    159|            && *type != ASN_NSAP) {
  ------------------
  |  |   98|    159|#define ASN_NSAP	(ASN_APPLICATION | 5)   /* historic - don't use */
  |  |  ------------------
  |  |  |  |   91|    159|#define ASN_APPLICATION     0x40U
  |  |  ------------------
  ------------------
  |  Branch (931:16): [True: 108, False: 51]
  ------------------
  932|    108|        _asn_type_err(errpre, *type);
  933|    108|        return NULL;
  934|    108|    }
  935|       |
  936|  12.0k|    bufp = asn_parse_nlength(bufp, *datalength - 1, &asn_length);
  937|  12.0k|    if (NULL == bufp) {
  ------------------
  |  Branch (937:9): [True: 178, False: 11.8k]
  ------------------
  938|    178|        _asn_short_err(errpre, *datalength - 1, asn_length);
  939|    178|        return NULL;
  940|    178|    }
  941|       |
  942|  11.8k|    if (asn_length > *strlength) {
  ------------------
  |  Branch (942:9): [True: 34, False: 11.8k]
  ------------------
  943|     34|        _asn_length_err(errpre, (size_t) asn_length, *strlength);
  944|     34|        return NULL;
  945|     34|    }
  946|       |
  947|  11.8k|    DEBUGDUMPSETUP("recv", data, bufp - data + asn_length);
  ------------------
  |  |   83|  11.8k|	do {if (_DBG_IF_) {__DBGDUMPSETUP(token,buf,len);} }while(0)
  |  |  ------------------
  |  |  |  |  144|  11.8k|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 11.8k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               	do {if (_DBG_IF_) {__DBGDUMPSETUP(token,buf,len);} }while(0)
  |  |  ------------------
  |  |  |  |  196|      0|        debugmsg("dumpx" token, "dumpx_%s:%*s", token, __DBGINDENT(), ""); \
  |  |  |  |  ------------------
  |  |  |  |  |  |  171|      0|#define __DBGINDENT()      debug_indent_get()
  |  |  |  |  ------------------
  |  |  |  |  197|      0|        __DBGMSGHEX(("dumpx_" token,buf,len)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |  169|      0|#define __DBGMSGHEX(x)     debugmsg_hex x
  |  |  |  |  ------------------
  |  |  |  |  198|      0|        if (debug_is_token_registered("dumpv" token) == SNMPERR_SUCCESS || \
  |  |  |  |  ------------------
  |  |  |  |  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (198:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  199|      0|            debug_is_token_registered("dumpv_" token) != SNMPERR_SUCCESS) { \
  |  |  |  |  ------------------
  |  |  |  |  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (199:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  200|      0|            debugmsg("dumpx_" token,"\n"); \
  |  |  |  |  201|      0|        } else { \
  |  |  |  |  202|      0|            debugmsg("dumpx_" token,"  "); \
  |  |  |  |  203|      0|        } \
  |  |  |  |  204|      0|        debugmsg("dumpv" token, "dumpv_%s:%*s", token, __DBGINDENT(), "");
  |  |  |  |  ------------------
  |  |  |  |  |  |  171|      0|#define __DBGINDENT()      debug_indent_get()
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (83:60): [Folded, False: 11.8k]
  |  |  ------------------
  ------------------
  948|       |
  949|  11.8k|    memmove(str, bufp, asn_length);
  950|  11.8k|    if (*strlength > asn_length)
  ------------------
  |  Branch (950:9): [True: 11.5k, False: 252]
  ------------------
  951|  11.5k|        str[asn_length] = 0;
  952|  11.8k|    *strlength = asn_length;
  953|  11.8k|    *datalength -= asn_length + (bufp - data);
  954|       |
  955|  11.8k|    DEBUGIF("dumpv_recv") {
  ------------------
  |  |  145|  11.8k|#define DEBUGIF(x)         if (_DBG_IF_ && debug_is_token_registered(x) == SNMPERR_SUCCESS)
  |  |  ------------------
  |  |  |  |  144|  23.6k|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 11.8k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGIF(x)         if (_DBG_IF_ && debug_is_token_registered(x) == SNMPERR_SUCCESS)
  |  |  ------------------
  |  |  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  ------------------
  |  |  |  Branch (145:44): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  956|      0|        u_char         *buf = (u_char *) malloc(1 + asn_length);
  957|      0|        size_t          l = (buf != NULL) ? (1 + asn_length) : 0, ol = 0;
  ------------------
  |  Branch (957:29): [True: 0, False: 0]
  ------------------
  958|       |
  959|      0|        if (sprint_realloc_asciistring
  ------------------
  |  Branch (959:13): [True: 0, False: 0]
  ------------------
  960|      0|            (&buf, &l, &ol, 1, str, asn_length)) {
  961|      0|            DEBUGMSG(("dumpv_recv", "  String:\t%s\n", buf));
  ------------------
  |  |   61|      0|#define DEBUGMSG(x)        do {if (_DBG_IF_) {debugmsg x;} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (61:67): [Folded, False: 0]
  |  |  ------------------
  ------------------
  962|      0|        } else {
  963|      0|            if (buf == NULL) {
  ------------------
  |  Branch (963:17): [True: 0, False: 0]
  ------------------
  964|      0|                DEBUGMSG(("dumpv_recv", "  String:\t[TRUNCATED]\n"));
  ------------------
  |  |   61|      0|#define DEBUGMSG(x)        do {if (_DBG_IF_) {debugmsg x;} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (61:67): [Folded, False: 0]
  |  |  ------------------
  ------------------
  965|      0|            } else {
  966|      0|                DEBUGMSG(("dumpv_recv", "  String:\t%s [TRUNCATED]\n",
  ------------------
  |  |   61|      0|#define DEBUGMSG(x)        do {if (_DBG_IF_) {debugmsg x;} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (61:67): [Folded, False: 0]
  |  |  ------------------
  ------------------
  967|      0|                          buf));
  968|      0|            }
  969|      0|        }
  970|      0|        if (buf != NULL) {
  ------------------
  |  Branch (970:13): [True: 0, False: 0]
  ------------------
  971|      0|            free(buf);
  972|      0|        }
  973|      0|    }
  974|       |
  975|  11.8k|    return bufp + asn_length;
  976|  11.8k|}
asn_parse_header:
 1073|  20.6k|{
 1074|  20.6k|    register u_char *bufp;
 1075|  20.6k|    u_long          asn_length = 0;
 1076|  20.6k|    const char      *errpre = "parse header";
 1077|       |
 1078|  20.6k|    if (!data || !datalength || !type) {
  ------------------
  |  Branch (1078:9): [True: 0, False: 20.6k]
  |  Branch (1078:18): [True: 0, False: 20.6k]
  |  Branch (1078:33): [True: 0, False: 20.6k]
  ------------------
 1079|      0|        ERROR_MSG("parse header: NULL pointer");
  ------------------
  |  |  188|      0|#define ERROR_MSG(string)	snmp_set_detail(string)
  ------------------
 1080|      0|        return NULL;
 1081|      0|    }
 1082|       |
 1083|       |    /** need at least 2 bytes to work with: type, length (which might be 0) */
 1084|  20.6k|    if (*datalength < 2) {
  ------------------
  |  Branch (1084:9): [True: 327, False: 20.3k]
  ------------------
 1085|    327|        _asn_short_err(errpre, *datalength, 2);
 1086|    327|        return NULL;
 1087|    327|    }
 1088|       |
 1089|  20.3k|    bufp = data;
 1090|       |    /*
 1091|       |     * this only works on data types < 30, i.e. no extension octets 
 1092|       |     */
 1093|  20.3k|    if (IS_EXTENSION_ID(*bufp)) {
  ------------------
  |  |  103|  20.3k|#define IS_EXTENSION_ID(byte)	(((byte) & ASN_EXTENSION_ID) == ASN_EXTENSION_ID)
  |  |  ------------------
  |  |  |  |   99|  20.3k|#define ASN_EXTENSION_ID    0x1FU
  |  |  ------------------
  |  |               #define IS_EXTENSION_ID(byte)	(((byte) & ASN_EXTENSION_ID) == ASN_EXTENSION_ID)
  |  |  ------------------
  |  |  |  |   99|  20.3k|#define ASN_EXTENSION_ID    0x1FU
  |  |  ------------------
  |  |  |  Branch (103:31): [True: 36, False: 20.3k]
  |  |  ------------------
  ------------------
 1094|     36|        ERROR_MSG("can't process ID >= 30");
  ------------------
  |  |  188|     36|#define ERROR_MSG(string)	snmp_set_detail(string)
  ------------------
 1095|     36|        return NULL;
 1096|     36|    }
 1097|  20.3k|    *type = *bufp++;
 1098|       |
 1099|  20.3k|    bufp = asn_parse_nlength(bufp, *datalength - 1, &asn_length);
 1100|  20.3k|    if (NULL == bufp) {
  ------------------
  |  Branch (1100:9): [True: 752, False: 19.5k]
  ------------------
 1101|    752|        _asn_short_err(errpre, *datalength - 1, asn_length);
 1102|    752|        return NULL;
 1103|    752|    }
 1104|       |
 1105|       |#ifdef DUMP_PRINT_HEADERS
 1106|       |    DEBUGDUMPSETUP("recv", data, (bufp - data));
 1107|       |    DEBUGMSG(("dumpv_recv", "  Header: 0x%.2X, len = %d (0x%X)\n", *data,
 1108|       |              asn_length, asn_length));
 1109|       |#else
 1110|       |    /*
 1111|       |     * DEBUGMSGHEXTLI(("recv",data,(bufp-data)));
 1112|       |     * DEBUGMSG(("dumpH_recv","\n"));
 1113|       |     */
 1114|  19.5k|#endif
 1115|       |
 1116|  19.5k|#ifdef NETSNMP_WITH_OPAQUE_SPECIAL_TYPES
 1117|       |
 1118|  19.5k|    if ((asn_length > 2) && (*type == ASN_OPAQUE) && (*bufp == ASN_OPAQUE_TAG1)) {
  ------------------
  |  |   93|  14.8k|#define ASN_OPAQUE	(ASN_APPLICATION | 4)   /* changed so no conflict with other includes */
  |  |  ------------------
  |  |  |  |   91|  14.8k|#define ASN_APPLICATION     0x40U
  |  |  ------------------
  ------------------
                  if ((asn_length > 2) && (*type == ASN_OPAQUE) && (*bufp == ASN_OPAQUE_TAG1)) {
  ------------------
  |  |  131|    275|#define ASN_OPAQUE_TAG1 (ASN_CONTEXT | ASN_EXTENSION_ID)
  |  |  ------------------
  |  |  |  |   92|    275|#define ASN_CONTEXT	    0x80U
  |  |  ------------------
  |  |               #define ASN_OPAQUE_TAG1 (ASN_CONTEXT | ASN_EXTENSION_ID)
  |  |  ------------------
  |  |  |  |   99|    275|#define ASN_EXTENSION_ID    0x1FU
  |  |  ------------------
  ------------------
  |  Branch (1118:9): [True: 14.8k, False: 4.75k]
  |  Branch (1118:29): [True: 275, False: 14.5k]
  |  Branch (1118:54): [True: 230, False: 45]
  ------------------
 1119|       |
 1120|       |        /*
 1121|       |         * check if 64-but counter 
 1122|       |         */
 1123|    230|        switch (*(bufp + 1)) {
 1124|     29|        case ASN_OPAQUE_COUNTER64:
  ------------------
  |  |  156|     29|#define ASN_OPAQUE_COUNTER64 (ASN_OPAQUE_TAG2 + ASN_APP_COUNTER64)
  |  |  ------------------
  |  |  |  |  136|     29|#define ASN_OPAQUE_TAG2 0x30U
  |  |  ------------------
  |  |               #define ASN_OPAQUE_COUNTER64 (ASN_OPAQUE_TAG2 + ASN_APP_COUNTER64)
  |  |  ------------------
  |  |  |  |  146|     29|#define ASN_APP_COUNTER64 (ASN_APPLICATION | 6)
  |  |  |  |  ------------------
  |  |  |  |  |  |   91|     29|#define ASN_APPLICATION     0x40U
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (1124:9): [True: 29, False: 201]
  ------------------
 1125|     73|        case ASN_OPAQUE_U64:
  ------------------
  |  |  192|     73|#define ASN_OPAQUE_U64 (ASN_OPAQUE_TAG2 + ASN_APP_U64)
  |  |  ------------------
  |  |  |  |  136|     73|#define ASN_OPAQUE_TAG2 0x30U
  |  |  ------------------
  |  |               #define ASN_OPAQUE_U64 (ASN_OPAQUE_TAG2 + ASN_APP_U64)
  |  |  ------------------
  |  |  |  |  150|     73|#define ASN_APP_U64 (ASN_APPLICATION | 11)
  |  |  |  |  ------------------
  |  |  |  |  |  |   91|     73|#define ASN_APPLICATION     0x40U
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (1125:9): [True: 44, False: 186]
  ------------------
 1126|    102|        case ASN_OPAQUE_FLOAT:
  ------------------
  |  |  165|    102|#define ASN_OPAQUE_FLOAT (ASN_OPAQUE_TAG2 + ASN_APP_FLOAT)
  |  |  ------------------
  |  |  |  |  136|    102|#define ASN_OPAQUE_TAG2 0x30U
  |  |  ------------------
  |  |               #define ASN_OPAQUE_FLOAT (ASN_OPAQUE_TAG2 + ASN_APP_FLOAT)
  |  |  ------------------
  |  |  |  |  147|    102|#define ASN_APP_FLOAT (ASN_APPLICATION | 8)
  |  |  |  |  ------------------
  |  |  |  |  |  |   91|    102|#define ASN_APPLICATION     0x40U
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (1126:9): [True: 29, False: 201]
  ------------------
 1127|    141|        case ASN_OPAQUE_DOUBLE:
  ------------------
  |  |  174|    141|#define ASN_OPAQUE_DOUBLE (ASN_OPAQUE_TAG2 + ASN_APP_DOUBLE)
  |  |  ------------------
  |  |  |  |  136|    141|#define ASN_OPAQUE_TAG2 0x30U
  |  |  ------------------
  |  |               #define ASN_OPAQUE_DOUBLE (ASN_OPAQUE_TAG2 + ASN_APP_DOUBLE)
  |  |  ------------------
  |  |  |  |  148|    141|#define ASN_APP_DOUBLE (ASN_APPLICATION | 9)
  |  |  |  |  ------------------
  |  |  |  |  |  |   91|    141|#define ASN_APPLICATION     0x40U
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (1127:9): [True: 39, False: 191]
  ------------------
 1128|    210|        case ASN_OPAQUE_I64:
  ------------------
  |  |  183|    210|#define ASN_OPAQUE_I64 (ASN_OPAQUE_TAG2 + ASN_APP_I64)
  |  |  ------------------
  |  |  |  |  136|    210|#define ASN_OPAQUE_TAG2 0x30U
  |  |  ------------------
  |  |               #define ASN_OPAQUE_I64 (ASN_OPAQUE_TAG2 + ASN_APP_I64)
  |  |  ------------------
  |  |  |  |  149|    210|#define ASN_APP_I64 (ASN_APPLICATION | 10)
  |  |  |  |  ------------------
  |  |  |  |  |  |   91|    210|#define ASN_APPLICATION     0x40U
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (1128:9): [True: 69, False: 161]
  ------------------
 1129|    210|            *type = *(bufp + 1);
 1130|    210|            break;
 1131|       |
 1132|     20|        default:
  ------------------
  |  Branch (1132:9): [True: 20, False: 210]
  ------------------
 1133|       |            /*
 1134|       |             * just an Opaque 
 1135|       |             */
 1136|     20|            *datalength = (int) asn_length;
 1137|     20|            return bufp;
 1138|    230|        }
 1139|       |        /*
 1140|       |         * value is encoded as special format 
 1141|       |         */
 1142|    210|        *datalength = (int) asn_length;
 1143|    210|        bufp = asn_parse_nlength(bufp+2, *datalength - 2, &asn_length);
 1144|    210|        if (NULL == bufp) {
  ------------------
  |  Branch (1144:13): [True: 38, False: 172]
  ------------------
 1145|     38|            _asn_short_err("parse opaque header", *datalength - 2, asn_length);
 1146|     38|            return NULL;
 1147|     38|        }
 1148|    210|    }
 1149|  19.5k|#endif                          /* NETSNMP_WITH_OPAQUE_SPECIAL_TYPES */
 1150|       |
 1151|  19.5k|    *datalength = (int) asn_length;
 1152|       |
 1153|  19.5k|    return bufp;
 1154|  19.5k|}
asn_parse_sequence:
 1173|  16.8k|{                               /* error message prefix */
 1174|  16.8k|    data = asn_parse_header(data, datalength, type);
 1175|  16.8k|    if (data && (*type != expected_type)) {
  ------------------
  |  Branch (1175:9): [True: 15.7k, False: 1.12k]
  |  Branch (1175:17): [True: 602, False: 15.1k]
  ------------------
 1176|    602|        char            ebuf[128];
 1177|    602|        snprintf(ebuf, sizeof(ebuf),
 1178|    602|                 "%s header type %02X: s/b %02X", estr,
 1179|    602|                (u_char) * type, (u_char) expected_type);
 1180|    602|        ERROR_MSG(ebuf);
  ------------------
  |  |  188|    602|#define ERROR_MSG(string)	snmp_set_detail(string)
  ------------------
 1181|    602|        return NULL;
 1182|    602|    }
 1183|  16.2k|    return data;
 1184|  16.8k|}
asn_parse_length:
 1295|  1.92k|{
 1296|  1.92k|    static const char *errpre = "parse length";
 1297|  1.92k|    char            ebuf[128];
 1298|  1.92k|    register u_char lengthbyte;
 1299|       |
 1300|  1.92k|    if (!data || !length) {
  ------------------
  |  Branch (1300:9): [True: 0, False: 1.92k]
  |  Branch (1300:18): [True: 0, False: 1.92k]
  ------------------
 1301|      0|        ERROR_MSG("parse length: NULL pointer");
  ------------------
  |  |  188|      0|#define ERROR_MSG(string)	snmp_set_detail(string)
  ------------------
 1302|      0|        return NULL;
 1303|      0|    }
 1304|  1.92k|    lengthbyte = *data;
 1305|       |
 1306|  1.92k|    if (lengthbyte & ASN_LONG_LEN) {
  ------------------
  |  |   98|  1.92k|#define ASN_LONG_LEN	    0x80U
  ------------------
  |  Branch (1306:9): [True: 1.92k, False: 0]
  ------------------
 1307|  1.92k|        lengthbyte &= ~ASN_LONG_LEN;    /* turn MSb off */
  ------------------
  |  |   98|  1.92k|#define ASN_LONG_LEN	    0x80U
  ------------------
 1308|  1.92k|        if (lengthbyte == 0) {
  ------------------
  |  Branch (1308:13): [True: 69, False: 1.85k]
  ------------------
 1309|     69|            snprintf(ebuf, sizeof(ebuf),
 1310|     69|                     "%s: indefinite length not supported", errpre);
 1311|     69|            ERROR_MSG(ebuf);
  ------------------
  |  |  188|     69|#define ERROR_MSG(string)	snmp_set_detail(string)
  ------------------
 1312|     69|            return NULL;
 1313|     69|        }
 1314|  1.85k|        if (lengthbyte > sizeof(long)) {
  ------------------
  |  Branch (1314:13): [True: 131, False: 1.72k]
  ------------------
 1315|    131|            snprintf(ebuf, sizeof(ebuf),
 1316|    131|                    "%s: data length %d > %lu not supported", errpre,
 1317|    131|                    lengthbyte, (unsigned long)sizeof(long));
 1318|    131|            ERROR_MSG(ebuf);
  ------------------
  |  |  188|    131|#define ERROR_MSG(string)	snmp_set_detail(string)
  ------------------
 1319|    131|            return NULL;
 1320|    131|        }
 1321|  1.72k|        data++;
 1322|  1.72k|        *length = 0;            /* protect against short lengths */
 1323|  8.44k|        while (lengthbyte--) {
  ------------------
  |  Branch (1323:16): [True: 6.72k, False: 1.72k]
  ------------------
 1324|  6.72k|            *length <<= 8;
 1325|  6.72k|            *length |= *data++;
 1326|  6.72k|        }
 1327|  1.72k|        if ((long) *length < 0) {
  ------------------
  |  Branch (1327:13): [True: 120, False: 1.60k]
  ------------------
 1328|    120|            snprintf(ebuf, sizeof(ebuf),
 1329|    120|                     "%s: negative data length %ld\n", errpre,
 1330|    120|                     (long) *length);
 1331|    120|            ERROR_MSG(ebuf);
  ------------------
  |  |  188|    120|#define ERROR_MSG(string)	snmp_set_detail(string)
  ------------------
 1332|    120|            return NULL;
 1333|    120|        }
 1334|  1.60k|        return data;
 1335|  1.72k|    } else {                    /* short asnlength */
 1336|      0|        *length = (long) lengthbyte;
 1337|      0|        return data + 1;
 1338|      0|    }
 1339|  1.92k|}
asn_parse_objid:
 1437|  2.01k|{
 1438|  2.01k|    static const char *errpre = "parse objid";
 1439|       |    /*
 1440|       |     * ASN.1 objid ::= 0x06 asnlength subidentifier {subidentifier}*
 1441|       |     * subidentifier ::= {leadingbyte}* lastbyte
 1442|       |     * leadingbyte ::= 1 7bitvalue
 1443|       |     * lastbyte ::= 0 7bitvalue
 1444|       |     */
 1445|  2.01k|    register u_char *bufp = data;
 1446|  2.01k|    register oid   *oidp = objid + 1;
 1447|  2.01k|    register u_long subidentifier;
 1448|  2.01k|    register long   length;
 1449|  2.01k|    u_long          asn_length;
 1450|  2.01k|    size_t          original_length = *objidlength;
 1451|       |
 1452|  2.01k|    if (NULL == data || NULL == datalength || NULL == type || NULL == objid) {
  ------------------
  |  Branch (1452:9): [True: 0, False: 2.01k]
  |  Branch (1452:25): [True: 0, False: 2.01k]
  |  Branch (1452:47): [True: 0, False: 2.01k]
  |  Branch (1452:63): [True: 0, False: 2.01k]
  ------------------
 1453|      0|        ERROR_MSG("parse objid: NULL pointer");
  ------------------
  |  |  188|      0|#define ERROR_MSG(string)	snmp_set_detail(string)
  ------------------
 1454|      0|        return NULL;
 1455|      0|    }
 1456|       |
 1457|       |    /** need at least 2 bytes to work with: type, length (which might be 0)  */
 1458|  2.01k|    if (*datalength < 2) {
  ------------------
  |  Branch (1458:9): [True: 13, False: 2.00k]
  ------------------
 1459|     13|        _asn_short_err(errpre, *datalength, 2);
 1460|     13|        return NULL;
 1461|     13|    }
 1462|       |
 1463|  2.00k|    *type = *bufp++;
 1464|  2.00k|    if (*type != ASN_OBJECT_ID) {
  ------------------
  |  |   81|  2.00k|#define ASN_OBJECT_ID	    0x06U
  ------------------
  |  Branch (1464:9): [True: 29, False: 1.97k]
  ------------------
 1465|     29|        _asn_type_err(errpre, *type);
 1466|     29|        return NULL;
 1467|     29|    }
 1468|  1.97k|    bufp = asn_parse_nlength(bufp, *datalength - 1, &asn_length);
 1469|  1.97k|    if (NULL == bufp) {
  ------------------
  |  Branch (1469:9): [True: 141, False: 1.83k]
  ------------------
 1470|    141|        _asn_short_err(errpre, *datalength - 1, asn_length);
 1471|    141|        return NULL;
 1472|    141|    }
 1473|       |
 1474|  1.83k|    *datalength -= (int) asn_length + (bufp - data);
 1475|       |
 1476|  1.83k|    DEBUGDUMPSETUP("recv", data, bufp - data + asn_length);
  ------------------
  |  |   83|  1.83k|	do {if (_DBG_IF_) {__DBGDUMPSETUP(token,buf,len);} }while(0)
  |  |  ------------------
  |  |  |  |  144|  1.83k|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 1.83k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               	do {if (_DBG_IF_) {__DBGDUMPSETUP(token,buf,len);} }while(0)
  |  |  ------------------
  |  |  |  |  196|      0|        debugmsg("dumpx" token, "dumpx_%s:%*s", token, __DBGINDENT(), ""); \
  |  |  |  |  ------------------
  |  |  |  |  |  |  171|      0|#define __DBGINDENT()      debug_indent_get()
  |  |  |  |  ------------------
  |  |  |  |  197|      0|        __DBGMSGHEX(("dumpx_" token,buf,len)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |  169|      0|#define __DBGMSGHEX(x)     debugmsg_hex x
  |  |  |  |  ------------------
  |  |  |  |  198|      0|        if (debug_is_token_registered("dumpv" token) == SNMPERR_SUCCESS || \
  |  |  |  |  ------------------
  |  |  |  |  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (198:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  199|      0|            debug_is_token_registered("dumpv_" token) != SNMPERR_SUCCESS) { \
  |  |  |  |  ------------------
  |  |  |  |  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (199:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  200|      0|            debugmsg("dumpx_" token,"\n"); \
  |  |  |  |  201|      0|        } else { \
  |  |  |  |  202|      0|            debugmsg("dumpx_" token,"  "); \
  |  |  |  |  203|      0|        } \
  |  |  |  |  204|      0|        debugmsg("dumpv" token, "dumpv_%s:%*s", token, __DBGINDENT(), "");
  |  |  |  |  ------------------
  |  |  |  |  |  |  171|      0|#define __DBGINDENT()      debug_indent_get()
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (83:60): [Folded, False: 1.83k]
  |  |  ------------------
  ------------------
 1477|       |
 1478|       |    /*
 1479|       |     * Handle invalid object identifier encodings of the form 06 00 robustly 
 1480|       |     */
 1481|  1.83k|    if (asn_length == 0)
  ------------------
  |  Branch (1481:9): [True: 1.03k, False: 802]
  ------------------
 1482|  1.03k|        objid[0] = objid[1] = 0;
 1483|       |
 1484|  1.83k|    length = asn_length;
 1485|  1.83k|    (*objidlength)--;           /* account for expansion of first byte */
 1486|       |
 1487|  8.71k|    while (length > 0 && (*objidlength)-- > 0) {
  ------------------
  |  Branch (1487:12): [True: 6.95k, False: 1.76k]
  |  Branch (1487:26): [True: 6.93k, False: 18]
  ------------------
 1488|  6.93k|        subidentifier = 0;
 1489|  9.31k|        do {                    /* shift and add in low order 7 bits */
 1490|  9.31k|            if (subidentifier > (MAX_SUBID >> 7)) {
  ------------------
  |  |   18|  9.31k|#define MAX_SUBID   0xFFFFFFFFUL
  ------------------
  |  Branch (1490:17): [True: 42, False: 9.27k]
  ------------------
 1491|     42|                ERROR_MSG("subidentifier too large / overflow");
  ------------------
  |  |  188|     42|#define ERROR_MSG(string)	snmp_set_detail(string)
  ------------------
 1492|     42|                return NULL;
 1493|     42|            }
 1494|  9.27k|            subidentifier =
 1495|  9.27k|                (subidentifier << 7) + (*(u_char *) bufp & ~ASN_BIT8);
  ------------------
  |  |  100|  9.27k|#define ASN_BIT8	    0x80U
  ------------------
 1496|  9.27k|            length--;
 1497|  9.27k|        } while ((*(u_char *) bufp++ & ASN_BIT8) && (length > 0));        /* last byte has high bit clear */
  ------------------
  |  |  100|  9.27k|#define ASN_BIT8	    0x80U
  ------------------
  |  Branch (1497:18): [True: 2.38k, False: 6.88k]
  |  Branch (1497:53): [True: 2.38k, False: 7]
  ------------------
 1498|       |
 1499|  6.89k|	if (length == 0) {
  ------------------
  |  Branch (1499:6): [True: 742, False: 6.14k]
  ------------------
 1500|    742|            u_char *last_byte = bufp - 1;
 1501|    742|            if (*last_byte & ASN_BIT8) {
  ------------------
  |  |  100|    742|#define ASN_BIT8	    0x80U
  ------------------
  |  Branch (1501:17): [True: 7, False: 735]
  ------------------
 1502|       |                /* last byte has high bit set -> wrong BER encoded OID */
 1503|      7|                ERROR_MSG("subidentifier syntax error");
  ------------------
  |  |  188|      7|#define ERROR_MSG(string)	snmp_set_detail(string)
  ------------------
 1504|      7|                return NULL;
 1505|      7|            }
 1506|    742|        }
 1507|  6.88k|        if (subidentifier > MAX_SUBID) {
  ------------------
  |  |   18|  6.88k|#define MAX_SUBID   0xFFFFFFFFUL
  ------------------
  |  Branch (1507:13): [True: 0, False: 6.88k]
  ------------------
 1508|      0|            ERROR_MSG("subidentifier too large");
  ------------------
  |  |  188|      0|#define ERROR_MSG(string)	snmp_set_detail(string)
  ------------------
 1509|      0|            return NULL;
 1510|      0|        }
 1511|  6.88k|        *oidp++ = (oid) subidentifier;
 1512|  6.88k|    }
 1513|       |
 1514|  1.78k|    if (length || oidp < objid + 1) {
  ------------------
  |  Branch (1514:9): [True: 18, False: 1.76k]
  |  Branch (1514:19): [True: 0, False: 1.76k]
  ------------------
 1515|     18|        ERROR_MSG("OID length exceeds buffer size");
  ------------------
  |  |  188|     18|#define ERROR_MSG(string)	snmp_set_detail(string)
  ------------------
 1516|     18|        *objidlength = original_length;
 1517|     18|        return NULL;
 1518|     18|    }
 1519|       |
 1520|       |    /*
 1521|       |     * The first two subidentifiers are encoded into the first component
 1522|       |     * with the value (X * 40) + Y, where:
 1523|       |     *  X is the value of the first subidentifier.
 1524|       |     *  Y is the value of the second subidentifier.
 1525|       |     */
 1526|  1.76k|    subidentifier = oidp - objid >= 2 ? objid[1] : 0;
  ------------------
  |  Branch (1526:21): [True: 735, False: 1.03k]
  ------------------
 1527|  1.76k|    if (subidentifier == 0x2B) {
  ------------------
  |  Branch (1527:9): [True: 217, False: 1.55k]
  ------------------
 1528|    217|        objid[0] = 1;
 1529|    217|        objid[1] = 3;
 1530|  1.55k|    } else {
 1531|  1.55k|        if (subidentifier < 40) {
  ------------------
  |  Branch (1531:13): [True: 1.25k, False: 294]
  ------------------
 1532|  1.25k|            objid[0] = 0;
 1533|  1.25k|            objid[1] = subidentifier;
 1534|  1.25k|        } else if (subidentifier < 80) {
  ------------------
  |  Branch (1534:20): [True: 148, False: 146]
  ------------------
 1535|    148|            objid[0] = 1;
 1536|    148|            objid[1] = subidentifier - 40;
 1537|    148|        } else {
 1538|    146|            objid[0] = 2;
 1539|    146|            objid[1] = subidentifier - 80;
 1540|    146|        }
 1541|  1.55k|    }
 1542|       |
 1543|  1.76k|    *objidlength = (int) (oidp - objid);
 1544|       |
 1545|  1.76k|    DEBUGMSG(("dumpv_recv", "  ObjID: "));
  ------------------
  |  |   61|  1.76k|#define DEBUGMSG(x)        do {if (_DBG_IF_) {debugmsg x;} }while(0)
  |  |  ------------------
  |  |  |  |  144|  1.76k|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 1.76k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (61:67): [Folded, False: 1.76k]
  |  |  ------------------
  ------------------
 1546|  1.76k|    DEBUGMSGOID(("dumpv_recv", objid, *objidlength));
  ------------------
  |  |   67|  1.76k|#define DEBUGMSGOID(x)     do {if (_DBG_IF_) {__DBGMSGOID(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|  1.76k|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 1.76k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGOID(x)     do {if (_DBG_IF_) {__DBGMSGOID(x);} }while(0)
  |  |  ------------------
  |  |  |  |  165|      0|#define __DBGMSGOID(x)     debugmsg_oid x
  |  |  ------------------
  |  |  |  Branch (67:71): [Folded, False: 1.76k]
  |  |  ------------------
  ------------------
 1547|  1.76k|    DEBUGMSG(("dumpv_recv", "\n"));
  ------------------
  |  |   61|  1.76k|#define DEBUGMSG(x)        do {if (_DBG_IF_) {debugmsg x;} }while(0)
  |  |  ------------------
  |  |  |  |  144|  1.76k|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 1.76k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (61:67): [Folded, False: 1.76k]
  |  |  ------------------
  ------------------
 1548|  1.76k|    return bufp;
 1549|  1.78k|}
asn_parse_bitstring:
 1819|     64|{
 1820|       |    /*
 1821|       |     * bitstring ::= 0x03 asnlength unused {byte}*
 1822|       |     */
 1823|     64|    static const char *errpre = "parse bitstring";
 1824|     64|    register u_char *bufp = data;
 1825|     64|    u_long          asn_length;
 1826|       |
 1827|     64|    if (NULL == data || NULL == datalength || NULL == type ||
  ------------------
  |  Branch (1827:9): [True: 0, False: 64]
  |  Branch (1827:25): [True: 0, False: 64]
  |  Branch (1827:47): [True: 0, False: 64]
  ------------------
 1828|     64|        NULL == str || NULL == strlength) {
  ------------------
  |  Branch (1828:9): [True: 0, False: 64]
  |  Branch (1828:24): [True: 0, False: 64]
  ------------------
 1829|      0|        ERROR_MSG("parse bitstring: NULL pointer");
  ------------------
  |  |  188|      0|#define ERROR_MSG(string)	snmp_set_detail(string)
  ------------------
 1830|      0|        return NULL;
 1831|      0|    }
 1832|       |
 1833|       |    /** need at least 2 bytes to work with: type, length (which might be 0)  */
 1834|     64|    if (*datalength < 2) {
  ------------------
  |  Branch (1834:9): [True: 0, False: 64]
  ------------------
 1835|      0|        _asn_short_err(errpre, *datalength, 2);
 1836|      0|        return NULL;
 1837|      0|    }
 1838|       |
 1839|     64|    *type = *bufp++;
 1840|     64|    if (*type != ASN_BIT_STR) {
  ------------------
  |  |   77|     64|#define ASN_BIT_STR	    0x03U
  ------------------
  |  Branch (1840:9): [True: 0, False: 64]
  ------------------
 1841|      0|        _asn_type_err(errpre, *type);
 1842|      0|        return NULL;
 1843|      0|    }
 1844|       |
 1845|     64|    bufp = asn_parse_nlength(bufp, *datalength - 1, &asn_length);
 1846|     64|    if (NULL == bufp) {
  ------------------
  |  Branch (1846:9): [True: 0, False: 64]
  ------------------
 1847|      0|        _asn_short_err(errpre, *datalength - 1, asn_length);
 1848|      0|        return NULL;
 1849|      0|    }
 1850|       |
 1851|     64|    if ((size_t) asn_length > *strlength) {
  ------------------
  |  Branch (1851:9): [True: 0, False: 64]
  ------------------
 1852|      0|        _asn_length_err(errpre, (size_t) asn_length, *strlength);
 1853|      0|        return NULL;
 1854|      0|    }
 1855|     64|    if (_asn_bitstring_check(errpre, asn_length, *bufp))
  ------------------
  |  Branch (1855:9): [True: 8, False: 56]
  ------------------
 1856|      8|        return NULL;
 1857|       |
 1858|     56|    DEBUGDUMPSETUP("recv", data, bufp - data);
  ------------------
  |  |   83|     56|	do {if (_DBG_IF_) {__DBGDUMPSETUP(token,buf,len);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     56|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 56]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               	do {if (_DBG_IF_) {__DBGDUMPSETUP(token,buf,len);} }while(0)
  |  |  ------------------
  |  |  |  |  196|      0|        debugmsg("dumpx" token, "dumpx_%s:%*s", token, __DBGINDENT(), ""); \
  |  |  |  |  ------------------
  |  |  |  |  |  |  171|      0|#define __DBGINDENT()      debug_indent_get()
  |  |  |  |  ------------------
  |  |  |  |  197|      0|        __DBGMSGHEX(("dumpx_" token,buf,len)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |  169|      0|#define __DBGMSGHEX(x)     debugmsg_hex x
  |  |  |  |  ------------------
  |  |  |  |  198|      0|        if (debug_is_token_registered("dumpv" token) == SNMPERR_SUCCESS || \
  |  |  |  |  ------------------
  |  |  |  |  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (198:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  199|      0|            debug_is_token_registered("dumpv_" token) != SNMPERR_SUCCESS) { \
  |  |  |  |  ------------------
  |  |  |  |  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (199:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  200|      0|            debugmsg("dumpx_" token,"\n"); \
  |  |  |  |  201|      0|        } else { \
  |  |  |  |  202|      0|            debugmsg("dumpx_" token,"  "); \
  |  |  |  |  203|      0|        } \
  |  |  |  |  204|      0|        debugmsg("dumpv" token, "dumpv_%s:%*s", token, __DBGINDENT(), "");
  |  |  |  |  ------------------
  |  |  |  |  |  |  171|      0|#define __DBGINDENT()      debug_indent_get()
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (83:60): [Folded, False: 56]
  |  |  ------------------
  ------------------
 1859|     56|    DEBUGMSG(("dumpv_recv", "  Bitstring: "));
  ------------------
  |  |   61|     56|#define DEBUGMSG(x)        do {if (_DBG_IF_) {debugmsg x;} }while(0)
  |  |  ------------------
  |  |  |  |  144|     56|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 56]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (61:67): [Folded, False: 56]
  |  |  ------------------
  ------------------
 1860|     56|    DEBUGMSGHEX(("dumpv_recv", data, asn_length));
  ------------------
  |  |   71|     56|#define DEBUGMSGHEX(x)     do {if (_DBG_IF_) {__DBGMSGHEX(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     56|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 56]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGHEX(x)     do {if (_DBG_IF_) {__DBGMSGHEX(x);} }while(0)
  |  |  ------------------
  |  |  |  |  169|      0|#define __DBGMSGHEX(x)     debugmsg_hex x
  |  |  ------------------
  |  |  |  Branch (71:71): [Folded, False: 56]
  |  |  ------------------
  ------------------
 1861|     56|    DEBUGMSG(("dumpv_recv", "\n"));
  ------------------
  |  |   61|     56|#define DEBUGMSG(x)        do {if (_DBG_IF_) {debugmsg x;} }while(0)
  |  |  ------------------
  |  |  |  |  144|     56|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 56]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (61:67): [Folded, False: 56]
  |  |  ------------------
  ------------------
 1862|       |
 1863|     56|    memmove(str, bufp, asn_length);
 1864|     56|    *strlength = (int) asn_length;
 1865|     56|    *datalength -= (int) asn_length + (bufp - data);
 1866|     56|    return bufp + asn_length;
 1867|     64|}
asn_parse_unsigned_int64:
 1951|    244|{
 1952|       |    /*
 1953|       |     * ASN.1 integer ::= 0x02 asnlength byte {byte}*
 1954|       |     */
 1955|    244|    static const char *errpre = "parse uint64";
 1956|    244|    const int       uint64sizelimit = (4 * 2) + 1;
 1957|    244|    register u_char *bufp = data;
 1958|    244|    u_char         *endp;
 1959|    244|    u_long          asn_length;
 1960|    244|    register u_long low = 0, high = 0;
 1961|       |
 1962|    244|    if (countersize != sizeof(struct counter64)) {
  ------------------
  |  Branch (1962:9): [True: 0, False: 244]
  ------------------
 1963|      0|        _asn_size_err(errpre, countersize, sizeof(struct counter64));
 1964|      0|        return NULL;
 1965|      0|    }
 1966|       |
 1967|    244|    if (NULL == data || NULL == datalength || NULL == type || NULL == cp) {
  ------------------
  |  Branch (1967:9): [True: 0, False: 244]
  |  Branch (1967:25): [True: 0, False: 244]
  |  Branch (1967:47): [True: 0, False: 244]
  |  Branch (1967:63): [True: 0, False: 244]
  ------------------
 1968|      0|        ERROR_MSG("parse uint64: NULL pointer");
  ------------------
  |  |  188|      0|#define ERROR_MSG(string)	snmp_set_detail(string)
  ------------------
 1969|      0|        return NULL;
 1970|      0|    }
 1971|       |
 1972|       |    /** need at least 2 bytes to work with: type, length (which might be 0)  */
 1973|    244|    if (*datalength < 2) {
  ------------------
  |  Branch (1973:9): [True: 0, False: 244]
  ------------------
 1974|      0|        _asn_short_err(errpre, *datalength, 2);
 1975|      0|        return NULL;
 1976|      0|    }
 1977|       |
 1978|    244|    *type = *bufp++;
 1979|    244|    if (*type != ASN_COUNTER64
  ------------------
  |  |   99|    488|#define ASN_COUNTER64   (ASN_APPLICATION | 6)
  |  |  ------------------
  |  |  |  |   91|    244|#define ASN_APPLICATION     0x40U
  |  |  ------------------
  ------------------
  |  Branch (1979:9): [True: 55, False: 189]
  ------------------
 1980|     55|#ifdef NETSNMP_WITH_OPAQUE_SPECIAL_TYPES
 1981|     55|            && *type != ASN_OPAQUE
  ------------------
  |  |   93|     55|#define ASN_OPAQUE	(ASN_APPLICATION | 4)   /* changed so no conflict with other includes */
  |  |  ------------------
  |  |  |  |   91|     55|#define ASN_APPLICATION     0x40U
  |  |  ------------------
  ------------------
  |  Branch (1981:16): [True: 2, False: 53]
  ------------------
 1982|    244|#endif
 1983|    244|            ) {
 1984|      2|        _asn_type_err(errpre, *type);
 1985|      2|        return NULL;
 1986|      2|    }
 1987|    242|    bufp = asn_parse_nlength(bufp, *datalength - 1, &asn_length);
 1988|    242|    if (NULL == bufp) {
  ------------------
  |  Branch (1988:9): [True: 0, False: 242]
  ------------------
 1989|      0|        _asn_short_err(errpre, *datalength - 1, asn_length);
 1990|      0|        return NULL;
 1991|      0|    }
 1992|    242|    endp = bufp + asn_length;
 1993|       |
 1994|    242|    DEBUGDUMPSETUP("recv", data, bufp - data + asn_length);
  ------------------
  |  |   83|    242|	do {if (_DBG_IF_) {__DBGDUMPSETUP(token,buf,len);} }while(0)
  |  |  ------------------
  |  |  |  |  144|    242|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 242]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               	do {if (_DBG_IF_) {__DBGDUMPSETUP(token,buf,len);} }while(0)
  |  |  ------------------
  |  |  |  |  196|      0|        debugmsg("dumpx" token, "dumpx_%s:%*s", token, __DBGINDENT(), ""); \
  |  |  |  |  ------------------
  |  |  |  |  |  |  171|      0|#define __DBGINDENT()      debug_indent_get()
  |  |  |  |  ------------------
  |  |  |  |  197|      0|        __DBGMSGHEX(("dumpx_" token,buf,len)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |  169|      0|#define __DBGMSGHEX(x)     debugmsg_hex x
  |  |  |  |  ------------------
  |  |  |  |  198|      0|        if (debug_is_token_registered("dumpv" token) == SNMPERR_SUCCESS || \
  |  |  |  |  ------------------
  |  |  |  |  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (198:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  199|      0|            debug_is_token_registered("dumpv_" token) != SNMPERR_SUCCESS) { \
  |  |  |  |  ------------------
  |  |  |  |  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (199:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  200|      0|            debugmsg("dumpx_" token,"\n"); \
  |  |  |  |  201|      0|        } else { \
  |  |  |  |  202|      0|            debugmsg("dumpx_" token,"  "); \
  |  |  |  |  203|      0|        } \
  |  |  |  |  204|      0|        debugmsg("dumpv" token, "dumpv_%s:%*s", token, __DBGINDENT(), "");
  |  |  |  |  ------------------
  |  |  |  |  |  |  171|      0|#define __DBGINDENT()      debug_indent_get()
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (83:60): [Folded, False: 242]
  |  |  ------------------
  ------------------
 1995|    242|#ifdef NETSNMP_WITH_OPAQUE_SPECIAL_TYPES
 1996|       |    /** need at least 2 bytes: ASN_OPAQUE_TAG1 and ASN_OPAQUE_<type> */
 1997|    242|    if ((*type == ASN_OPAQUE) && (asn_length < 2)) {
  ------------------
  |  |   93|    242|#define ASN_OPAQUE	(ASN_APPLICATION | 4)   /* changed so no conflict with other includes */
  |  |  ------------------
  |  |  |  |   91|    242|#define ASN_APPLICATION     0x40U
  |  |  ------------------
  ------------------
  |  Branch (1997:9): [True: 53, False: 189]
  |  Branch (1997:34): [True: 0, False: 53]
  ------------------
 1998|      0|        _asn_short_err(errpre, asn_length, 2);
 1999|      0|        return NULL;
 2000|      0|    }
 2001|       |
 2002|       |    /*
 2003|       |     * 64 bit counters as opaque 
 2004|       |     */
 2005|    242|    if ((*type == ASN_OPAQUE) &&
  ------------------
  |  |   93|    242|#define ASN_OPAQUE	(ASN_APPLICATION | 4)   /* changed so no conflict with other includes */
  |  |  ------------------
  |  |  |  |   91|    242|#define ASN_APPLICATION     0x40U
  |  |  ------------------
  ------------------
  |  Branch (2005:9): [True: 53, False: 189]
  ------------------
 2006|     53|        (asn_length <= ASN_OPAQUE_COUNTER64_MX_BER_LEN) &&
  ------------------
  |  |  160|     53|#define ASN_OPAQUE_COUNTER64_MX_BER_LEN 12
  ------------------
  |  Branch (2006:9): [True: 49, False: 4]
  ------------------
 2007|     49|        (*bufp == ASN_OPAQUE_TAG1) &&
  ------------------
  |  |  131|     49|#define ASN_OPAQUE_TAG1 (ASN_CONTEXT | ASN_EXTENSION_ID)
  |  |  ------------------
  |  |  |  |   92|     49|#define ASN_CONTEXT	    0x80U
  |  |  ------------------
  |  |               #define ASN_OPAQUE_TAG1 (ASN_CONTEXT | ASN_EXTENSION_ID)
  |  |  ------------------
  |  |  |  |   99|     49|#define ASN_EXTENSION_ID    0x1FU
  |  |  ------------------
  ------------------
  |  Branch (2007:9): [True: 49, False: 0]
  ------------------
 2008|     49|        ((*(bufp + 1) == ASN_OPAQUE_COUNTER64) ||
  ------------------
  |  |  156|     49|#define ASN_OPAQUE_COUNTER64 (ASN_OPAQUE_TAG2 + ASN_APP_COUNTER64)
  |  |  ------------------
  |  |  |  |  136|     49|#define ASN_OPAQUE_TAG2 0x30U
  |  |  ------------------
  |  |               #define ASN_OPAQUE_COUNTER64 (ASN_OPAQUE_TAG2 + ASN_APP_COUNTER64)
  |  |  ------------------
  |  |  |  |  146|     49|#define ASN_APP_COUNTER64 (ASN_APPLICATION | 6)
  |  |  |  |  ------------------
  |  |  |  |  |  |   91|     49|#define ASN_APPLICATION     0x40U
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (2008:10): [True: 22, False: 27]
  ------------------
 2009|     49|         (*(bufp + 1) == ASN_OPAQUE_U64))) {
  ------------------
  |  |  192|     27|#define ASN_OPAQUE_U64 (ASN_OPAQUE_TAG2 + ASN_APP_U64)
  |  |  ------------------
  |  |  |  |  136|     27|#define ASN_OPAQUE_TAG2 0x30U
  |  |  ------------------
  |  |               #define ASN_OPAQUE_U64 (ASN_OPAQUE_TAG2 + ASN_APP_U64)
  |  |  ------------------
  |  |  |  |  150|     27|#define ASN_APP_U64 (ASN_APPLICATION | 11)
  |  |  |  |  ------------------
  |  |  |  |  |  |   91|     27|#define ASN_APPLICATION     0x40U
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (2009:10): [True: 27, False: 0]
  ------------------
 2010|     49|        size_t          outer_length = asn_length - 2;
 2011|       |
 2012|       |        /*
 2013|       |         * change type to Counter64 or U64 
 2014|       |         */
 2015|     49|        *type = *(bufp + 1);
 2016|       |        /*
 2017|       |         * value is encoded as special format 
 2018|       |         */
 2019|     49|        bufp = asn_parse_nlength(bufp + 2, outer_length, &asn_length);
 2020|     49|        if (NULL == bufp) {
  ------------------
  |  Branch (2020:13): [True: 0, False: 49]
  ------------------
 2021|      0|            _asn_short_err("parse opaque uint64", outer_length, asn_length);
 2022|      0|            return NULL;
 2023|      0|        }
 2024|     49|    }
 2025|    242|#endif                          /* NETSNMP_WITH_OPAQUE_SPECIAL_TYPES */
 2026|    242|    if (((int) asn_length > uint64sizelimit) ||
  ------------------
  |  Branch (2026:9): [True: 9, False: 233]
  ------------------
 2027|    233|        (((int) asn_length == uint64sizelimit) && *bufp != 0x00)) {
  ------------------
  |  Branch (2027:10): [True: 19, False: 214]
  |  Branch (2027:51): [True: 8, False: 11]
  ------------------
 2028|     17|        _asn_length_err(errpre, (size_t) asn_length, uint64sizelimit);
 2029|     17|        return NULL;
 2030|     17|    }
 2031|    225|    *datalength -= endp - data;
 2032|    764|    while (asn_length--) {
  ------------------
  |  Branch (2032:12): [True: 539, False: 225]
  ------------------
 2033|    539|        high = ((0x00FFFFFF & high) << 8) | ((low & 0xFF000000U) >> 24);
 2034|    539|        low = ((low & 0x00FFFFFF) << 8) | *bufp++;
 2035|    539|    }
 2036|    225|    bufp = endp;
 2037|       |
 2038|    225|    CHECK_OVERFLOW_U(high,6);
  ------------------
  |  |  224|    225|#define CHECK_OVERFLOW_U(x,y) do {                                      \
  |  |  225|    225|        if (x > UINT32_MAX) {                                           \
  |  |  ------------------
  |  |  |  Branch (225:13): [True: 0, False: 225]
  |  |  ------------------
  |  |  226|      0|            x &= 0xffffffff;                                            \
  |  |  227|      0|            DEBUGMSG(("asn","truncating unsigned value to 32 bits (%d)\n",y)); \
  |  |  ------------------
  |  |  |  |   61|      0|#define DEBUGMSG(x)        do {if (_DBG_IF_) {debugmsg x;} }while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (61:67): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  228|      0|        }                                                               \
  |  |  229|    225|    } while(0)
  |  |  ------------------
  |  |  |  Branch (229:13): [Folded, False: 225]
  |  |  ------------------
  ------------------
 2039|    225|    CHECK_OVERFLOW_U(low,6);
  ------------------
  |  |  224|    225|#define CHECK_OVERFLOW_U(x,y) do {                                      \
  |  |  225|    225|        if (x > UINT32_MAX) {                                           \
  |  |  ------------------
  |  |  |  Branch (225:13): [True: 0, False: 225]
  |  |  ------------------
  |  |  226|      0|            x &= 0xffffffff;                                            \
  |  |  227|      0|            DEBUGMSG(("asn","truncating unsigned value to 32 bits (%d)\n",y)); \
  |  |  ------------------
  |  |  |  |   61|      0|#define DEBUGMSG(x)        do {if (_DBG_IF_) {debugmsg x;} }while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (61:67): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  228|      0|        }                                                               \
  |  |  229|    225|    } while(0)
  |  |  ------------------
  |  |  |  Branch (229:13): [Folded, False: 225]
  |  |  ------------------
  ------------------
 2040|       |
 2041|    225|    cp->low = low;
 2042|    225|    cp->high = high;
 2043|       |
 2044|    225|    DEBUGIF("dumpv_recv") {
  ------------------
  |  |  145|    225|#define DEBUGIF(x)         if (_DBG_IF_ && debug_is_token_registered(x) == SNMPERR_SUCCESS)
  |  |  ------------------
  |  |  |  |  144|    450|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 225]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGIF(x)         if (_DBG_IF_ && debug_is_token_registered(x) == SNMPERR_SUCCESS)
  |  |  ------------------
  |  |  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  ------------------
  |  |  |  Branch (145:44): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 2045|      0|        char            i64buf[I64CHARSZ + 1];
 2046|      0|        printU64(i64buf, cp);
 2047|      0|        DEBUGMSG(("dumpv_recv", "Counter64: %s\n", i64buf));
  ------------------
  |  |   61|      0|#define DEBUGMSG(x)        do {if (_DBG_IF_) {debugmsg x;} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (61:67): [Folded, False: 0]
  |  |  ------------------
  ------------------
 2048|      0|    }
 2049|       |
 2050|    225|    return bufp;
 2051|    242|}
asn_parse_signed_int64:
 2228|     69|{
 2229|     69|    static const char *errpre = "parse int64";
 2230|     69|    const int       int64sizelimit = (4 * 2) + 1;
 2231|     69|    char            ebuf[128];
 2232|     69|    register u_char *bufp = data;
 2233|     69|    u_char         *endp;
 2234|     69|    u_long          asn_length;
 2235|     69|    register u_int  low = 0, high = 0;
 2236|       |
 2237|     69|    if (countersize != sizeof(struct counter64)) {
  ------------------
  |  Branch (2237:9): [True: 0, False: 69]
  ------------------
 2238|      0|        _asn_size_err(errpre, countersize, sizeof(struct counter64));
 2239|      0|        return NULL;
 2240|      0|    }
 2241|       |
 2242|     69|    if (NULL == data || NULL == datalength || NULL == type || NULL == cp) {
  ------------------
  |  Branch (2242:9): [True: 0, False: 69]
  |  Branch (2242:25): [True: 0, False: 69]
  |  Branch (2242:47): [True: 0, False: 69]
  |  Branch (2242:63): [True: 0, False: 69]
  ------------------
 2243|      0|        ERROR_MSG("parse int64: NULL pointer");
  ------------------
  |  |  188|      0|#define ERROR_MSG(string)	snmp_set_detail(string)
  ------------------
 2244|      0|        return NULL;
 2245|      0|    }
 2246|       |
 2247|       |    /** need at least 2 bytes to work with: type, length (which might be 0) */
 2248|     69|    if (*datalength < 2) {
  ------------------
  |  Branch (2248:9): [True: 0, False: 69]
  ------------------
 2249|      0|        _asn_short_err(errpre, *datalength, 2);
 2250|      0|        return NULL;
 2251|      0|    }
 2252|       |
 2253|     69|    *type = *bufp++;
 2254|     69|    bufp = asn_parse_nlength(bufp, *datalength - 1, &asn_length);
 2255|     69|    if (NULL == bufp) {
  ------------------
  |  Branch (2255:9): [True: 0, False: 69]
  ------------------
 2256|      0|        _asn_short_err(errpre, *datalength - 1, asn_length);
 2257|      0|        return NULL;
 2258|      0|    }
 2259|     69|    endp = bufp + asn_length;
 2260|       |
 2261|       |    /** need at least 2 bytes: ASN_OPAQUE_TAG1 and ASN_OPAQUE_I64 */
 2262|     69|    if (asn_length < 2) {
  ------------------
  |  Branch (2262:9): [True: 4, False: 65]
  ------------------
 2263|      4|        _asn_short_err(errpre, asn_length, 2);
 2264|      4|        return NULL;
 2265|      4|    }
 2266|       |
 2267|     65|    DEBUGDUMPSETUP("recv", data, bufp - data + asn_length);
  ------------------
  |  |   83|     65|	do {if (_DBG_IF_) {__DBGDUMPSETUP(token,buf,len);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     65|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 65]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               	do {if (_DBG_IF_) {__DBGDUMPSETUP(token,buf,len);} }while(0)
  |  |  ------------------
  |  |  |  |  196|      0|        debugmsg("dumpx" token, "dumpx_%s:%*s", token, __DBGINDENT(), ""); \
  |  |  |  |  ------------------
  |  |  |  |  |  |  171|      0|#define __DBGINDENT()      debug_indent_get()
  |  |  |  |  ------------------
  |  |  |  |  197|      0|        __DBGMSGHEX(("dumpx_" token,buf,len)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |  169|      0|#define __DBGMSGHEX(x)     debugmsg_hex x
  |  |  |  |  ------------------
  |  |  |  |  198|      0|        if (debug_is_token_registered("dumpv" token) == SNMPERR_SUCCESS || \
  |  |  |  |  ------------------
  |  |  |  |  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (198:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  199|      0|            debug_is_token_registered("dumpv_" token) != SNMPERR_SUCCESS) { \
  |  |  |  |  ------------------
  |  |  |  |  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (199:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  200|      0|            debugmsg("dumpx_" token,"\n"); \
  |  |  |  |  201|      0|        } else { \
  |  |  |  |  202|      0|            debugmsg("dumpx_" token,"  "); \
  |  |  |  |  203|      0|        } \
  |  |  |  |  204|      0|        debugmsg("dumpv" token, "dumpv_%s:%*s", token, __DBGINDENT(), "");
  |  |  |  |  ------------------
  |  |  |  |  |  |  171|      0|#define __DBGINDENT()      debug_indent_get()
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (83:60): [Folded, False: 65]
  |  |  ------------------
  ------------------
 2268|     65|    if ((*type == ASN_OPAQUE) &&
  ------------------
  |  |   93|     65|#define ASN_OPAQUE	(ASN_APPLICATION | 4)   /* changed so no conflict with other includes */
  |  |  ------------------
  |  |  |  |   91|     65|#define ASN_APPLICATION     0x40U
  |  |  ------------------
  ------------------
  |  Branch (2268:9): [True: 58, False: 7]
  ------------------
 2269|     58|        (asn_length <= ASN_OPAQUE_COUNTER64_MX_BER_LEN) &&
  ------------------
  |  |  160|     58|#define ASN_OPAQUE_COUNTER64_MX_BER_LEN 12
  ------------------
  |  Branch (2269:9): [True: 55, False: 3]
  ------------------
 2270|     55|        (*bufp == ASN_OPAQUE_TAG1) && (*(bufp + 1) == ASN_OPAQUE_I64)) {
  ------------------
  |  |  131|     55|#define ASN_OPAQUE_TAG1 (ASN_CONTEXT | ASN_EXTENSION_ID)
  |  |  ------------------
  |  |  |  |   92|     55|#define ASN_CONTEXT	    0x80U
  |  |  ------------------
  |  |               #define ASN_OPAQUE_TAG1 (ASN_CONTEXT | ASN_EXTENSION_ID)
  |  |  ------------------
  |  |  |  |   99|     55|#define ASN_EXTENSION_ID    0x1FU
  |  |  ------------------
  ------------------
                      (*bufp == ASN_OPAQUE_TAG1) && (*(bufp + 1) == ASN_OPAQUE_I64)) {
  ------------------
  |  |  183|     55|#define ASN_OPAQUE_I64 (ASN_OPAQUE_TAG2 + ASN_APP_I64)
  |  |  ------------------
  |  |  |  |  136|     55|#define ASN_OPAQUE_TAG2 0x30U
  |  |  ------------------
  |  |               #define ASN_OPAQUE_I64 (ASN_OPAQUE_TAG2 + ASN_APP_I64)
  |  |  ------------------
  |  |  |  |  149|     55|#define ASN_APP_I64 (ASN_APPLICATION | 10)
  |  |  |  |  ------------------
  |  |  |  |  |  |   91|     55|#define ASN_APPLICATION     0x40U
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (2270:9): [True: 55, False: 0]
  |  Branch (2270:39): [True: 55, False: 0]
  ------------------
 2271|     55|        size_t          outer_length = asn_length - 2;
 2272|       |
 2273|       |        /*
 2274|       |         * change type to Int64 
 2275|       |         */
 2276|     55|        *type = *(bufp + 1);
 2277|       |        /*
 2278|       |         * value is encoded as special format 
 2279|       |         */
 2280|     55|        bufp = asn_parse_nlength(bufp + 2, outer_length, &asn_length);
 2281|     55|        if (NULL == bufp) {
  ------------------
  |  Branch (2281:13): [True: 0, False: 55]
  ------------------
 2282|      0|            _asn_short_err("parse opaque int64", outer_length, asn_length);
 2283|      0|            return NULL;
 2284|      0|        }
 2285|     55|    }
 2286|       |    /*
 2287|       |     * this should always have been true until snmp gets int64 PDU types 
 2288|       |     */
 2289|     10|    else {
 2290|     10|        snprintf(ebuf, sizeof(ebuf),
 2291|     10|                "%s: wrong type: %d, len %d, buf bytes (%02X,%02X)",
 2292|     10|                errpre, *type, (int) asn_length, *bufp, *(bufp + 1));
 2293|     10|        ERROR_MSG(ebuf);
  ------------------
  |  |  188|     10|#define ERROR_MSG(string)	snmp_set_detail(string)
  ------------------
 2294|     10|        return NULL;
 2295|     10|    }
 2296|     55|    if (((int) asn_length > int64sizelimit) ||
  ------------------
  |  Branch (2296:9): [True: 0, False: 55]
  ------------------
 2297|     55|        (((int) asn_length == int64sizelimit) && *bufp != 0x00)) {
  ------------------
  |  Branch (2297:10): [True: 7, False: 48]
  |  Branch (2297:50): [True: 1, False: 6]
  ------------------
 2298|      1|        _asn_length_err(errpre, (size_t) asn_length, int64sizelimit);
 2299|      1|        return NULL;
 2300|      1|    }
 2301|     54|    *datalength -= endp - data;
 2302|     54|    if ((asn_length > 0) && (*bufp & 0x80)) {
  ------------------
  |  Branch (2302:9): [True: 36, False: 18]
  |  Branch (2302:29): [True: 16, False: 20]
  ------------------
 2303|     16|        low = 0xFFFFFFFFU;   /* first byte bit 1 means start the data with 1s */
 2304|     16|        high = 0xFFFFFFFFU;
 2305|     16|    }
 2306|       |
 2307|    181|    for ( ; asn_length; asn_length--) {
  ------------------
  |  Branch (2307:13): [True: 127, False: 54]
  ------------------
 2308|    127|        high = ((0x00FFFFFF & high) << 8) | ((low & 0xFF000000U) >> 24);
 2309|    127|        low = ((low & 0x00FFFFFF) << 8) | *bufp++;
 2310|    127|    }
 2311|     54|    bufp = endp;
 2312|       |
 2313|     54|    CHECK_OVERFLOW_U(high,8);
  ------------------
  |  |  224|     54|#define CHECK_OVERFLOW_U(x,y) do {                                      \
  |  |  225|     54|        if (x > UINT32_MAX) {                                           \
  |  |  ------------------
  |  |  |  Branch (225:13): [True: 0, False: 54]
  |  |  ------------------
  |  |  226|      0|            x &= 0xffffffff;                                            \
  |  |  227|      0|            DEBUGMSG(("asn","truncating unsigned value to 32 bits (%d)\n",y)); \
  |  |  ------------------
  |  |  |  |   61|      0|#define DEBUGMSG(x)        do {if (_DBG_IF_) {debugmsg x;} }while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (61:67): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  228|      0|        }                                                               \
  |  |  229|     54|    } while(0)
  |  |  ------------------
  |  |  |  Branch (229:13): [Folded, False: 54]
  |  |  ------------------
  ------------------
 2314|     54|    CHECK_OVERFLOW_U(low,8);
  ------------------
  |  |  224|     54|#define CHECK_OVERFLOW_U(x,y) do {                                      \
  |  |  225|     54|        if (x > UINT32_MAX) {                                           \
  |  |  ------------------
  |  |  |  Branch (225:13): [True: 0, False: 54]
  |  |  ------------------
  |  |  226|      0|            x &= 0xffffffff;                                            \
  |  |  227|      0|            DEBUGMSG(("asn","truncating unsigned value to 32 bits (%d)\n",y)); \
  |  |  ------------------
  |  |  |  |   61|      0|#define DEBUGMSG(x)        do {if (_DBG_IF_) {debugmsg x;} }while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (61:67): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  228|      0|        }                                                               \
  |  |  229|     54|    } while(0)
  |  |  ------------------
  |  |  |  Branch (229:13): [Folded, False: 54]
  |  |  ------------------
  ------------------
 2315|       |
 2316|     54|    cp->low = low;
 2317|     54|    cp->high = high;
 2318|       |
 2319|     54|    DEBUGIF("dumpv_recv") {
  ------------------
  |  |  145|     54|#define DEBUGIF(x)         if (_DBG_IF_ && debug_is_token_registered(x) == SNMPERR_SUCCESS)
  |  |  ------------------
  |  |  |  |  144|    108|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 54]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGIF(x)         if (_DBG_IF_ && debug_is_token_registered(x) == SNMPERR_SUCCESS)
  |  |  ------------------
  |  |  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  ------------------
  |  |  |  Branch (145:44): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 2320|      0|        char            i64buf[I64CHARSZ + 1];
 2321|      0|        printI64(i64buf, cp);
 2322|      0|        DEBUGMSG(("dumpv_recv", "Integer64: %s\n", i64buf));
  ------------------
  |  |   61|      0|#define DEBUGMSG(x)        do {if (_DBG_IF_) {debugmsg x;} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (61:67): [Folded, False: 0]
  |  |  ------------------
  ------------------
 2323|      0|    }
 2324|       |
 2325|     54|    return bufp;
 2326|     55|}
asn_parse_float:
 2449|     50|{
 2450|     50|    static const char *errpre = "parse float";
 2451|     50|    register u_char *bufp = data;
 2452|     50|    u_long          asn_length;
 2453|     50|    union {
 2454|     50|        float           floatVal;
 2455|     50|        long            longVal;
 2456|     50|        u_char          c[sizeof(float)];
 2457|     50|    } fu;
 2458|       |
 2459|     50|    if (floatsize != sizeof(float)) {
  ------------------
  |  Branch (2459:9): [True: 0, False: 50]
  ------------------
 2460|      0|        _asn_size_err("parse float", floatsize, sizeof(float));
 2461|      0|        return NULL;
 2462|      0|    }
 2463|       |
 2464|     50|    if (NULL == data || NULL == datalength || NULL == type || NULL == floatp) {
  ------------------
  |  Branch (2464:9): [True: 0, False: 50]
  |  Branch (2464:25): [True: 0, False: 50]
  |  Branch (2464:47): [True: 0, False: 50]
  |  Branch (2464:63): [True: 0, False: 50]
  ------------------
 2465|      0|        ERROR_MSG("parse float: NULL pointer");
  ------------------
  |  |  188|      0|#define ERROR_MSG(string)	snmp_set_detail(string)
  ------------------
 2466|      0|        return NULL;
 2467|      0|    }
 2468|       |
 2469|       |    /** need at least 2 bytes to work with: type, length (which might be 0)  */
 2470|     50|    if (*datalength < 2) {
  ------------------
  |  Branch (2470:9): [True: 0, False: 50]
  ------------------
 2471|      0|        _asn_short_err(errpre, *datalength, 2);
 2472|      0|        return NULL;
 2473|      0|    }
 2474|       |
 2475|     50|    *type = *bufp++;
 2476|     50|    bufp = asn_parse_nlength(bufp, *datalength - 1, &asn_length);
 2477|     50|    if (NULL == bufp) {
  ------------------
  |  Branch (2477:9): [True: 0, False: 50]
  ------------------
 2478|      0|        _asn_short_err(errpre, *datalength - 1, asn_length);
 2479|      0|        return NULL;
 2480|      0|    }
 2481|       |
 2482|     50|    DEBUGDUMPSETUP("recv", data, bufp - data + asn_length);
  ------------------
  |  |   83|     50|	do {if (_DBG_IF_) {__DBGDUMPSETUP(token,buf,len);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     50|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 50]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               	do {if (_DBG_IF_) {__DBGDUMPSETUP(token,buf,len);} }while(0)
  |  |  ------------------
  |  |  |  |  196|      0|        debugmsg("dumpx" token, "dumpx_%s:%*s", token, __DBGINDENT(), ""); \
  |  |  |  |  ------------------
  |  |  |  |  |  |  171|      0|#define __DBGINDENT()      debug_indent_get()
  |  |  |  |  ------------------
  |  |  |  |  197|      0|        __DBGMSGHEX(("dumpx_" token,buf,len)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |  169|      0|#define __DBGMSGHEX(x)     debugmsg_hex x
  |  |  |  |  ------------------
  |  |  |  |  198|      0|        if (debug_is_token_registered("dumpv" token) == SNMPERR_SUCCESS || \
  |  |  |  |  ------------------
  |  |  |  |  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (198:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  199|      0|            debug_is_token_registered("dumpv_" token) != SNMPERR_SUCCESS) { \
  |  |  |  |  ------------------
  |  |  |  |  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (199:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  200|      0|            debugmsg("dumpx_" token,"\n"); \
  |  |  |  |  201|      0|        } else { \
  |  |  |  |  202|      0|            debugmsg("dumpx_" token,"  "); \
  |  |  |  |  203|      0|        } \
  |  |  |  |  204|      0|        debugmsg("dumpv" token, "dumpv_%s:%*s", token, __DBGINDENT(), "");
  |  |  |  |  ------------------
  |  |  |  |  |  |  171|      0|#define __DBGINDENT()      debug_indent_get()
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (83:60): [Folded, False: 50]
  |  |  ------------------
  ------------------
 2483|       |    /*
 2484|       |     * the float is encoded as an opaque 
 2485|       |     */
 2486|     50|    if ((*type == ASN_OPAQUE) &&
  ------------------
  |  |   93|     50|#define ASN_OPAQUE	(ASN_APPLICATION | 4)   /* changed so no conflict with other includes */
  |  |  ------------------
  |  |  |  |   91|     50|#define ASN_APPLICATION     0x40U
  |  |  ------------------
  ------------------
  |  Branch (2486:9): [True: 21, False: 29]
  ------------------
 2487|     21|        (asn_length == ASN_OPAQUE_FLOAT_BER_LEN) &&
  ------------------
  |  |  169|     21|#define ASN_OPAQUE_FLOAT_BER_LEN 7
  ------------------
  |  Branch (2487:9): [True: 13, False: 8]
  ------------------
 2488|     13|        (*bufp == ASN_OPAQUE_TAG1) && (*(bufp + 1) == ASN_OPAQUE_FLOAT)) {
  ------------------
  |  |  131|     13|#define ASN_OPAQUE_TAG1 (ASN_CONTEXT | ASN_EXTENSION_ID)
  |  |  ------------------
  |  |  |  |   92|     13|#define ASN_CONTEXT	    0x80U
  |  |  ------------------
  |  |               #define ASN_OPAQUE_TAG1 (ASN_CONTEXT | ASN_EXTENSION_ID)
  |  |  ------------------
  |  |  |  |   99|     13|#define ASN_EXTENSION_ID    0x1FU
  |  |  ------------------
  ------------------
                      (*bufp == ASN_OPAQUE_TAG1) && (*(bufp + 1) == ASN_OPAQUE_FLOAT)) {
  ------------------
  |  |  165|     13|#define ASN_OPAQUE_FLOAT (ASN_OPAQUE_TAG2 + ASN_APP_FLOAT)
  |  |  ------------------
  |  |  |  |  136|     13|#define ASN_OPAQUE_TAG2 0x30U
  |  |  ------------------
  |  |               #define ASN_OPAQUE_FLOAT (ASN_OPAQUE_TAG2 + ASN_APP_FLOAT)
  |  |  ------------------
  |  |  |  |  147|     13|#define ASN_APP_FLOAT (ASN_APPLICATION | 8)
  |  |  |  |  ------------------
  |  |  |  |  |  |   91|     13|#define ASN_APPLICATION     0x40U
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (2488:9): [True: 13, False: 0]
  |  Branch (2488:39): [True: 13, False: 0]
  ------------------
 2489|     13|        size_t          outer_length = asn_length - 2;
 2490|       |
 2491|       |        /*
 2492|       |         * value is encoded as special format 
 2493|       |         */
 2494|     13|        bufp = asn_parse_nlength(bufp + 2, outer_length, &asn_length);
 2495|     13|        if (NULL == bufp) {
  ------------------
  |  Branch (2495:13): [True: 0, False: 13]
  ------------------
 2496|      0|            _asn_short_err("parse opaque float", outer_length, asn_length);
 2497|      0|            return NULL;
 2498|      0|        }
 2499|       |        /*
 2500|       |         * change type to Float 
 2501|       |         */
 2502|     13|        *type = ASN_OPAQUE_FLOAT;
  ------------------
  |  |  165|     13|#define ASN_OPAQUE_FLOAT (ASN_OPAQUE_TAG2 + ASN_APP_FLOAT)
  |  |  ------------------
  |  |  |  |  136|     13|#define ASN_OPAQUE_TAG2 0x30U
  |  |  ------------------
  |  |               #define ASN_OPAQUE_FLOAT (ASN_OPAQUE_TAG2 + ASN_APP_FLOAT)
  |  |  ------------------
  |  |  |  |  147|     13|#define ASN_APP_FLOAT (ASN_APPLICATION | 8)
  |  |  |  |  ------------------
  |  |  |  |  |  |   91|     13|#define ASN_APPLICATION     0x40U
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2503|     13|    }
 2504|       |
 2505|     50|    if (*type != ASN_OPAQUE_FLOAT) {
  ------------------
  |  |  165|     50|#define ASN_OPAQUE_FLOAT (ASN_OPAQUE_TAG2 + ASN_APP_FLOAT)
  |  |  ------------------
  |  |  |  |  136|     50|#define ASN_OPAQUE_TAG2 0x30U
  |  |  ------------------
  |  |               #define ASN_OPAQUE_FLOAT (ASN_OPAQUE_TAG2 + ASN_APP_FLOAT)
  |  |  ------------------
  |  |  |  |  147|     50|#define ASN_APP_FLOAT (ASN_APPLICATION | 8)
  |  |  |  |  ------------------
  |  |  |  |  |  |   91|     50|#define ASN_APPLICATION     0x40U
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (2505:9): [True: 8, False: 42]
  ------------------
 2506|      8|        _asn_type_err(errpre, *type);
 2507|      8|        return NULL;
 2508|      8|    }
 2509|       |
 2510|     42|    if (asn_length != sizeof(float)) {
  ------------------
  |  Branch (2510:9): [True: 10, False: 32]
  ------------------
 2511|     10|        _asn_size_err("parse seq float", asn_length, sizeof(float));
 2512|     10|        return NULL;
 2513|     10|    }
 2514|       |
 2515|     32|    *datalength -= (int) asn_length + (bufp - data);
 2516|     32|    memcpy(&fu.c[0], bufp, asn_length);
 2517|     32|    bufp += asn_length;
 2518|       |
 2519|       |    /*
 2520|       |     * correct for endian differences 
 2521|       |     */
 2522|     32|    fu.longVal = ntohl(fu.longVal);
 2523|       |
 2524|     32|    *floatp = fu.floatVal;
 2525|       |
 2526|     32|    DEBUGMSG(("dumpv_recv", "Opaque float: %f\n", *floatp));
  ------------------
  |  |   61|     32|#define DEBUGMSG(x)        do {if (_DBG_IF_) {debugmsg x;} }while(0)
  |  |  ------------------
  |  |  |  |  144|     32|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 32]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (61:67): [Folded, False: 32]
  |  |  ------------------
  ------------------
 2527|     32|    return bufp;
 2528|     42|}
asn_parse_double:
 2633|     57|{
 2634|     57|    static const char *errpre = "parse double";
 2635|     57|    register u_char *bufp = data;
 2636|     57|    u_long          asn_length;
 2637|     57|    long            tmp;
 2638|     57|    union {
 2639|     57|        double          doubleVal;
 2640|     57|        int             intVal[2];
 2641|     57|        u_char          c[sizeof(double)];
 2642|     57|    } fu;
 2643|       |
 2644|       |
 2645|     57|    if (doublesize != sizeof(double)) {
  ------------------
  |  Branch (2645:9): [True: 0, False: 57]
  ------------------
 2646|      0|        _asn_size_err("parse double", doublesize, sizeof(double));
 2647|      0|        return NULL;
 2648|      0|    }
 2649|       |
 2650|     57|    if (NULL == data || NULL == datalength || NULL == type || NULL == doublep) {
  ------------------
  |  Branch (2650:9): [True: 0, False: 57]
  |  Branch (2650:25): [True: 0, False: 57]
  |  Branch (2650:47): [True: 0, False: 57]
  |  Branch (2650:63): [True: 0, False: 57]
  ------------------
 2651|      0|        ERROR_MSG("parse double: NULL pointer");
  ------------------
  |  |  188|      0|#define ERROR_MSG(string)	snmp_set_detail(string)
  ------------------
 2652|      0|        return NULL;
 2653|      0|    }
 2654|       |
 2655|       |    /** need at least 2 bytes to work with: type, length (which might be 0)  */
 2656|     57|    if (*datalength < 2) {
  ------------------
  |  Branch (2656:9): [True: 0, False: 57]
  ------------------
 2657|      0|        _asn_short_err(errpre, *datalength, 2);
 2658|      0|        return NULL;
 2659|      0|    }
 2660|       |
 2661|     57|    *type = *bufp++;
 2662|     57|    bufp = asn_parse_nlength(bufp, *datalength - 1, &asn_length);
 2663|     57|    if (NULL == bufp) {
  ------------------
  |  Branch (2663:9): [True: 0, False: 57]
  ------------------
 2664|      0|        _asn_short_err(errpre, *datalength - 1, asn_length);
 2665|      0|        return NULL;
 2666|      0|    }
 2667|       |
 2668|     57|    DEBUGDUMPSETUP("recv", data, bufp - data + asn_length);
  ------------------
  |  |   83|     57|	do {if (_DBG_IF_) {__DBGDUMPSETUP(token,buf,len);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     57|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 57]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               	do {if (_DBG_IF_) {__DBGDUMPSETUP(token,buf,len);} }while(0)
  |  |  ------------------
  |  |  |  |  196|      0|        debugmsg("dumpx" token, "dumpx_%s:%*s", token, __DBGINDENT(), ""); \
  |  |  |  |  ------------------
  |  |  |  |  |  |  171|      0|#define __DBGINDENT()      debug_indent_get()
  |  |  |  |  ------------------
  |  |  |  |  197|      0|        __DBGMSGHEX(("dumpx_" token,buf,len)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |  169|      0|#define __DBGMSGHEX(x)     debugmsg_hex x
  |  |  |  |  ------------------
  |  |  |  |  198|      0|        if (debug_is_token_registered("dumpv" token) == SNMPERR_SUCCESS || \
  |  |  |  |  ------------------
  |  |  |  |  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (198:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  199|      0|            debug_is_token_registered("dumpv_" token) != SNMPERR_SUCCESS) { \
  |  |  |  |  ------------------
  |  |  |  |  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (199:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  200|      0|            debugmsg("dumpx_" token,"\n"); \
  |  |  |  |  201|      0|        } else { \
  |  |  |  |  202|      0|            debugmsg("dumpx_" token,"  "); \
  |  |  |  |  203|      0|        } \
  |  |  |  |  204|      0|        debugmsg("dumpv" token, "dumpv_%s:%*s", token, __DBGINDENT(), "");
  |  |  |  |  ------------------
  |  |  |  |  |  |  171|      0|#define __DBGINDENT()      debug_indent_get()
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (83:60): [Folded, False: 57]
  |  |  ------------------
  ------------------
 2669|       |    /*
 2670|       |     * the double is encoded as an opaque 
 2671|       |     */
 2672|       |    /** need at least 2 bytes: ASN_OPAQUE_TAG1 and ASN_OPAQUE_DOUBLE */
 2673|     57|    if ((*type == ASN_OPAQUE) && (asn_length < 2)) {
  ------------------
  |  |   93|     57|#define ASN_OPAQUE	(ASN_APPLICATION | 4)   /* changed so no conflict with other includes */
  |  |  ------------------
  |  |  |  |   91|     57|#define ASN_APPLICATION     0x40U
  |  |  ------------------
  ------------------
  |  Branch (2673:9): [True: 27, False: 30]
  |  Branch (2673:34): [True: 0, False: 27]
  ------------------
 2674|      0|        _asn_short_err(errpre, asn_length, 2);
 2675|      0|        return NULL;
 2676|      0|    }
 2677|     57|    if ((*type == ASN_OPAQUE) &&
  ------------------
  |  |   93|     57|#define ASN_OPAQUE	(ASN_APPLICATION | 4)   /* changed so no conflict with other includes */
  |  |  ------------------
  |  |  |  |   91|     57|#define ASN_APPLICATION     0x40U
  |  |  ------------------
  ------------------
  |  Branch (2677:9): [True: 27, False: 30]
  ------------------
 2678|     27|        (asn_length == ASN_OPAQUE_DOUBLE_BER_LEN) &&
  ------------------
  |  |  178|     27|#define ASN_OPAQUE_DOUBLE_BER_LEN 11
  ------------------
  |  Branch (2678:9): [True: 14, False: 13]
  ------------------
 2679|     14|        (*bufp == ASN_OPAQUE_TAG1) && (*(bufp + 1) == ASN_OPAQUE_DOUBLE)) {
  ------------------
  |  |  131|     14|#define ASN_OPAQUE_TAG1 (ASN_CONTEXT | ASN_EXTENSION_ID)
  |  |  ------------------
  |  |  |  |   92|     14|#define ASN_CONTEXT	    0x80U
  |  |  ------------------
  |  |               #define ASN_OPAQUE_TAG1 (ASN_CONTEXT | ASN_EXTENSION_ID)
  |  |  ------------------
  |  |  |  |   99|     14|#define ASN_EXTENSION_ID    0x1FU
  |  |  ------------------
  ------------------
                      (*bufp == ASN_OPAQUE_TAG1) && (*(bufp + 1) == ASN_OPAQUE_DOUBLE)) {
  ------------------
  |  |  174|     14|#define ASN_OPAQUE_DOUBLE (ASN_OPAQUE_TAG2 + ASN_APP_DOUBLE)
  |  |  ------------------
  |  |  |  |  136|     14|#define ASN_OPAQUE_TAG2 0x30U
  |  |  ------------------
  |  |               #define ASN_OPAQUE_DOUBLE (ASN_OPAQUE_TAG2 + ASN_APP_DOUBLE)
  |  |  ------------------
  |  |  |  |  148|     14|#define ASN_APP_DOUBLE (ASN_APPLICATION | 9)
  |  |  |  |  ------------------
  |  |  |  |  |  |   91|     14|#define ASN_APPLICATION     0x40U
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (2679:9): [True: 14, False: 0]
  |  Branch (2679:39): [True: 14, False: 0]
  ------------------
 2680|     14|        size_t          outer_length = asn_length - 2;
 2681|       |
 2682|       |        /*
 2683|       |         * value is encoded as special format 
 2684|       |         */
 2685|     14|        bufp = asn_parse_nlength(bufp + 2, outer_length, &asn_length);
 2686|     14|        if (NULL == bufp) {
  ------------------
  |  Branch (2686:13): [True: 0, False: 14]
  ------------------
 2687|      0|            _asn_short_err("parse opaque double", outer_length, asn_length);
 2688|      0|            return NULL;
 2689|      0|        }
 2690|       |
 2691|       |        /*
 2692|       |         * change type to Double 
 2693|       |         */
 2694|     14|        *type = ASN_OPAQUE_DOUBLE;
  ------------------
  |  |  174|     14|#define ASN_OPAQUE_DOUBLE (ASN_OPAQUE_TAG2 + ASN_APP_DOUBLE)
  |  |  ------------------
  |  |  |  |  136|     14|#define ASN_OPAQUE_TAG2 0x30U
  |  |  ------------------
  |  |               #define ASN_OPAQUE_DOUBLE (ASN_OPAQUE_TAG2 + ASN_APP_DOUBLE)
  |  |  ------------------
  |  |  |  |  148|     14|#define ASN_APP_DOUBLE (ASN_APPLICATION | 9)
  |  |  |  |  ------------------
  |  |  |  |  |  |   91|     14|#define ASN_APPLICATION     0x40U
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2695|     14|    }
 2696|       |
 2697|     57|    if (*type != ASN_OPAQUE_DOUBLE) {
  ------------------
  |  |  174|     57|#define ASN_OPAQUE_DOUBLE (ASN_OPAQUE_TAG2 + ASN_APP_DOUBLE)
  |  |  ------------------
  |  |  |  |  136|     57|#define ASN_OPAQUE_TAG2 0x30U
  |  |  ------------------
  |  |               #define ASN_OPAQUE_DOUBLE (ASN_OPAQUE_TAG2 + ASN_APP_DOUBLE)
  |  |  ------------------
  |  |  |  |  148|     57|#define ASN_APP_DOUBLE (ASN_APPLICATION | 9)
  |  |  |  |  ------------------
  |  |  |  |  |  |   91|     57|#define ASN_APPLICATION     0x40U
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (2697:9): [True: 13, False: 44]
  ------------------
 2698|     13|        _asn_type_err(errpre, *type);
 2699|     13|        return NULL;
 2700|     13|    }
 2701|       |
 2702|     44|    if (asn_length != sizeof(double)) {
  ------------------
  |  Branch (2702:9): [True: 16, False: 28]
  ------------------
 2703|     16|        _asn_size_err("parse seq double", asn_length, sizeof(double));
 2704|     16|        return NULL;
 2705|     16|    }
 2706|     28|    *datalength -= (int) asn_length + (bufp - data);
 2707|     28|    memcpy(&fu.c[0], bufp, asn_length);
 2708|     28|    bufp += asn_length;
 2709|       |
 2710|       |    /*
 2711|       |     * correct for endian differences 
 2712|       |     */
 2713|       |
 2714|     28|    tmp = ntohl(fu.intVal[0]);
 2715|     28|    fu.intVal[0] = ntohl(fu.intVal[1]);
 2716|     28|    fu.intVal[1] = tmp;
 2717|       |
 2718|     28|    *doublep = fu.doubleVal;
 2719|     28|    DEBUGMSG(("dumpv_recv", "  Opaque Double:\t%f\n", *doublep));
  ------------------
  |  |   61|     28|#define DEBUGMSG(x)        do {if (_DBG_IF_) {debugmsg x;} }while(0)
  |  |  ------------------
  |  |  |  |  144|     28|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 28]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (61:67): [Folded, False: 28]
  |  |  ------------------
  ------------------
 2720|       |
 2721|     28|    return bufp;
 2722|     44|}
asn1.c:_asn_size_err:
  242|     26|{
  243|     26|    char            ebuf[128];
  244|       |
  245|     26|    snprintf(ebuf, sizeof(ebuf),
  246|     26|            "%s size %lu: s/b %lu", str,
  247|     26|	    (unsigned long)wrongsize, (unsigned long)rightsize);
  248|     26|    ERROR_MSG(ebuf);
  ------------------
  |  |  188|     26|#define ERROR_MSG(string)	snmp_set_detail(string)
  ------------------
  249|     26|}
asn1.c:_asn_short_err:
  299|  2.01k|{
  300|  2.01k|    char            ebuf[128];
  301|       |
  302|  2.01k|    snprintf(ebuf, sizeof(ebuf), "%s length %lu too short: need %lu", str,
  303|  2.01k|	    (unsigned long)wrongsize, (unsigned long)rightsize);
  304|  2.01k|    ERROR_MSG(ebuf);
  ------------------
  |  |  188|  2.01k|#define ERROR_MSG(string)	snmp_set_detail(string)
  ------------------
  305|  2.01k|}
asn1.c:_asn_type_err:
  261|    203|{
  262|    203|    char            ebuf[128];
  263|       |
  264|    203|    snprintf(ebuf, sizeof(ebuf), "%s type %d", str, wrongtype);
  265|    203|    ebuf[ sizeof(ebuf)-1 ] = 0;
  266|    203|    ERROR_MSG(ebuf);
  ------------------
  |  |  188|    203|#define ERROR_MSG(string)	snmp_set_detail(string)
  ------------------
  267|    203|}
asn1.c:_asn_length_err:
  280|    108|{
  281|    108|    char            ebuf[128];
  282|       |
  283|    108|    snprintf(ebuf, sizeof(ebuf),
  284|    108|            "%s length %lu too large: exceeds %lu", str,
  285|    108|	    (unsigned long)wrongsize, (unsigned long)rightsize);
  286|    108|    ERROR_MSG(ebuf);
  ------------------
  |  |  188|    108|#define ERROR_MSG(string)	snmp_set_detail(string)
  ------------------
  287|    108|}
asn1.c:_asn_bitstring_check:
  515|     64|{
  516|     64|    char            ebuf[128];
  517|       |
  518|     64|    if (asn_length < 1) {
  ------------------
  |  Branch (518:9): [True: 8, False: 56]
  ------------------
  519|      8|        snprintf(ebuf, sizeof(ebuf),
  520|      8|                "%s: length %d too small", str, (int) asn_length);
  521|      8|        ERROR_MSG(ebuf);
  ------------------
  |  |  188|      8|#define ERROR_MSG(string)	snmp_set_detail(string)
  ------------------
  522|      8|        return 1;
  523|      8|    }
  524|       |    /*
  525|       |     * if (datum > 7){
  526|       |     * sprintf(ebuf,"%s: datum %d >7: too large", str, (int)(datum));
  527|       |     * ERROR_MSG(ebuf);
  528|       |     * return 1;
  529|       |     * }
  530|       |     */
  531|     56|    return 0;
  532|     64|}

init_callbacks:
  198|      4|{
  199|       |    /*
  200|       |     * (poses a problem if you put init_callbacks() inside of
  201|       |     * init_snmp() and then want the app to register a callback before
  202|       |     * init_snmp() is called in the first place.  -- Wes 
  203|       |     */
  204|      4|    if (0 == _callback_need_init)
  ------------------
  |  Branch (204:9): [True: 2, False: 2]
  ------------------
  205|      2|        return;
  206|       |    
  207|      2|    _callback_need_init = 0;
  208|       |    
  209|      2|    memset(thecallbacks, 0, sizeof(thecallbacks)); 
  210|      2|#ifdef LOCK_PER_CALLBACK_SUBID
  211|      2|    memset(_locks, 0, sizeof(_locks));
  212|       |#else
  213|       |    _lock = 0;
  214|       |#endif
  215|       |    
  216|      2|    DEBUGMSGTL(("callback", "initialized\n"));
  ------------------
  |  |   66|      2|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      2|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 2]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 2]
  |  |  ------------------
  ------------------
  217|      2|}
snmp_register_callback:
  258|     22|{
  259|     22|    return netsnmp_register_callback( major, minor, new_callback, arg,
  260|     22|                                      NETSNMP_CALLBACK_DEFAULT_PRIORITY);
  ------------------
  |  |   40|     22|#define NETSNMP_CALLBACK_DEFAULT_PRIORITY       0
  ------------------
  261|     22|}
netsnmp_register_callback:
  280|     22|{
  281|     22|    struct snmp_gen_callback *newscp = NULL, *scp = NULL;
  282|       |
  283|     22|    if (major < 0 || major >= MAX_CALLBACK_IDS ||
  ------------------
  |  |   12|     44|#define MAX_CALLBACK_IDS    2
  ------------------
  |  Branch (283:9): [True: 0, False: 22]
  |  Branch (283:22): [True: 0, False: 22]
  ------------------
  284|     22|        minor < 0 || minor >= MAX_CALLBACK_SUBIDS) {
  ------------------
  |  |   13|     22|#define MAX_CALLBACK_SUBIDS 18
  ------------------
  |  Branch (284:9): [True: 0, False: 22]
  |  Branch (284:22): [True: 0, False: 22]
  ------------------
  285|      0|        return SNMPERR_GENERR;
  ------------------
  |  |  185|      0|#define SNMPERR_GENERR			(-1)
  ------------------
  286|      0|    }
  287|       |
  288|     22|    if (_callback_need_init)
  ------------------
  |  Branch (288:9): [True: 2, False: 20]
  ------------------
  289|      2|        init_callbacks();
  290|       |
  291|     22|    _callback_lock(major,minor, "netsnmp_register_callback", 1);
  292|       |    
  293|     22|    if ((newscp = SNMP_MALLOC_STRUCT(snmp_gen_callback)) == NULL) {
  ------------------
  |  |   69|     22|#define SNMP_MALLOC_STRUCT(s)   (struct s *) calloc(1, sizeof(struct s))
  ------------------
  |  Branch (293:9): [True: 0, False: 22]
  ------------------
  294|      0|        _callback_unlock(major,minor);
  295|      0|        return SNMPERR_GENERR;
  ------------------
  |  |  185|      0|#define SNMPERR_GENERR			(-1)
  ------------------
  296|     22|    } else {
  297|     22|        struct snmp_gen_callback **prevNext = &(thecallbacks[major][minor]);
  298|       |
  299|     22|        newscp->priority = priority;
  300|     22|        newscp->sc_client_arg = arg;
  301|     22|        newscp->sc_callback = new_callback;
  302|     22|        newscp->next = NULL;
  303|       |
  304|     40|        for (scp = thecallbacks[major][minor]; scp != NULL;
  ------------------
  |  Branch (304:48): [True: 18, False: 22]
  ------------------
  305|     22|             scp = scp->next) {
  306|     18|            if (newscp->priority < scp->priority) {
  ------------------
  |  Branch (306:17): [True: 0, False: 18]
  ------------------
  307|      0|                newscp->next = scp;
  308|      0|                break;
  309|      0|            }
  310|     18|            prevNext = &(scp->next);
  311|     18|        }
  312|       |
  313|     22|        *prevNext = newscp;
  314|       |
  315|     22|        DEBUGMSGTL(("callback", "registered (%d,%d) at %p with priority %d\n",
  ------------------
  |  |   66|     22|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     22|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 22]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 22]
  |  |  ------------------
  ------------------
  316|     22|                    major, minor, newscp, priority));
  317|     22|        _callback_unlock(major,minor);
  318|     22|        return SNMPERR_SUCCESS;
  ------------------
  |  |  184|     22|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
  319|     22|    }
  320|     22|}
snmp_call_callbacks:
  341|    291|{
  342|    291|    struct snmp_gen_callback *scp;
  343|    291|    unsigned int    count = 0;
  344|       |    
  345|    291|    if (major < 0 || major >= MAX_CALLBACK_IDS ||
  ------------------
  |  |   12|    582|#define MAX_CALLBACK_IDS    2
  ------------------
  |  Branch (345:9): [True: 0, False: 291]
  |  Branch (345:22): [True: 0, False: 291]
  ------------------
  346|    291|        minor < 0 || minor >= MAX_CALLBACK_SUBIDS) {
  ------------------
  |  |   13|    291|#define MAX_CALLBACK_SUBIDS 18
  ------------------
  |  Branch (346:9): [True: 0, False: 291]
  |  Branch (346:22): [True: 0, False: 291]
  ------------------
  347|      0|        return SNMPERR_GENERR;
  ------------------
  |  |  185|      0|#define SNMPERR_GENERR			(-1)
  ------------------
  348|      0|    }
  349|       |    
  350|    291|    if (_callback_need_init)
  ------------------
  |  Branch (350:9): [True: 0, False: 291]
  ------------------
  351|      0|        init_callbacks();
  352|       |
  353|    291|#ifdef LOCK_PER_CALLBACK_SUBID
  354|    291|    _callback_lock(major,minor,"snmp_call_callbacks", 1);
  355|       |#else
  356|       |    /*
  357|       |     * Notes:
  358|       |     * - this gets hit the first time a trap is sent after a new trap
  359|       |     *   destination has been added (session init cb during send trap cb)
  360|       |     */
  361|       |    _callback_lock(major,minor, NULL, 0);
  362|       |#endif
  363|       |
  364|    291|    DEBUGMSGTL(("callback", "START calling callbacks for maj=%d min=%d\n",
  ------------------
  |  |   66|    291|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|    291|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 291]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 291]
  |  |  ------------------
  ------------------
  365|    291|                major, minor));
  366|       |
  367|       |    /*
  368|       |     * for each registered callback of type major and minor 
  369|       |     */
  370|    303|    for (scp = thecallbacks[major][minor]; scp != NULL; scp = scp->next) {
  ------------------
  |  Branch (370:44): [True: 12, False: 291]
  ------------------
  371|       |
  372|       |        /*
  373|       |         * skip unregistered callbacks
  374|       |         */
  375|     12|        if(NULL == scp->sc_callback)
  ------------------
  |  Branch (375:12): [True: 0, False: 12]
  ------------------
  376|      0|            continue;
  377|       |
  378|     12|        DEBUGMSGTL(("callback", "calling a callback for maj=%d min=%d\n",
  ------------------
  |  |   66|     12|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     12|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 12]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 12]
  |  |  ------------------
  ------------------
  379|     12|                    major, minor));
  380|       |
  381|       |        /*
  382|       |         * call them 
  383|       |         */
  384|     12|        (*(scp->sc_callback)) (major, minor, caller_arg,
  385|     12|                               scp->sc_client_arg);
  386|     12|        count++;
  387|     12|    }
  388|       |
  389|    291|    DEBUGMSGTL(("callback",
  ------------------
  |  |   66|    291|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|    291|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 291]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 291]
  |  |  ------------------
  ------------------
  390|    291|                "END calling callbacks for maj=%d min=%d (%d called)\n",
  391|    291|                major, minor, count));
  392|       |
  393|    291|    _callback_unlock(major,minor);
  394|    291|    return SNMPERR_SUCCESS;
  ------------------
  |  |  184|    291|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
  395|    291|}
callback.c:_callback_lock:
  119|    313|{
  120|    313|    int lock_holded=0;
  121|    313|    NETSNMP_SELECT_TIMEVAL lock_time;
  ------------------
  |  | 1777|    313|#define NETSNMP_SELECT_TIMEVAL struct timeval
  ------------------
  122|       |
  123|       |#ifdef NETSNMP_PARANOID_LEVEL_HIGH
  124|       |    if (major < 0 || major >= MAX_CALLBACK_IDS ||
  125|       |        minor < 0 || minor >= MAX_CALLBACK_SUBIDS) {
  126|       |        netsnmp_assert("bad callback id");
  127|       |        return 1;
  128|       |    }
  129|       |#endif
  130|       |    
  131|    313|#ifdef CALLBACK_NAME_LOGGING
  132|    313|    DEBUGMSGTL(("9:callback:lock", "locked (%s,%s)\n",
  ------------------
  |  |   66|    313|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|    313|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 313]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (164:52): [True: 0, False: 0]
  |  |  |  |  |  Branch (164:52): [True: 0, False: 0]
  |  |  |  |  |  Branch (164:64): [True: 0, False: 0]
  |  |  |  |  |  Branch (164:64): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 313]
  |  |  ------------------
  ------------------
  133|    313|                types[major], (SNMP_CALLBACK_LIBRARY == major) ?
  134|    313|                SNMP_STRORNULL(lib[minor]) : "null"));
  135|    313|#endif
  136|    313|    while (CALLBACK_LOCK_COUNT(major,minor) >= 1 && ++lock_holded < 100) {
  ------------------
  |  |  109|    313|#define CALLBACK_LOCK_COUNT(maj,min) _locks[maj][min]
  ------------------
  |  Branch (136:12): [True: 0, False: 313]
  |  Branch (136:53): [True: 0, False: 0]
  ------------------
  137|      0|	lock_time.tv_sec = 0;
  138|      0|	lock_time.tv_usec = 1000;
  139|      0|	select(0, NULL, NULL, NULL, &lock_time);
  140|      0|    }
  141|       |
  142|    313|    if(lock_holded >= 100) {
  ------------------
  |  Branch (142:8): [True: 0, False: 313]
  ------------------
  143|      0|        if (NULL != warn)
  ------------------
  |  Branch (143:13): [True: 0, False: 0]
  ------------------
  144|      0|            snmp_log(LOG_WARNING,
  145|      0|                     "lock in _callback_lock sleeps more than 100 milliseconds in %s\n", warn);
  146|      0|        if (do_assert)
  ------------------
  |  Branch (146:13): [True: 0, False: 0]
  ------------------
  147|      0|            netsnmp_assert(lock_holded < 100);
  ------------------
  |  |   47|      0|#      define netsnmp_assert(x)  do { \
  |  |   48|      0|              if ( x ) \
  |  |  ------------------
  |  |  |  Branch (48:20): [True: 0, False: 0]
  |  |  ------------------
  |  |   49|      0|                 ; \
  |  |   50|      0|              else \
  |  |   51|      0|                 snmp_log(LOG_ERR, \
  |  |   52|      0|                          "netsnmp_assert %s failed %s:%d" NETSNMP_FUNC_FMT, \
  |  |  ------------------
  |  |  |  |   40|      0|#          define NETSNMP_FUNC_FMT " %s()\n"
  |  |  ------------------
  |  |   53|      0|                          __STRING(x),__FILE__,__LINE__, \
  |  |   54|      0|                          NETSNMP_FUNC_PARAM); \
  |  |  ------------------
  |  |  |  |   41|      0|#          define NETSNMP_FUNC_PARAM NETSNMP_FUNCTION
  |  |  |  |  ------------------
  |  |  |  |  |  | 1727|      0|#define NETSNMP_FUNCTION __func__
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   55|      0|           }while(0)
  |  |  ------------------
  |  |  |  Branch (55:19): [Folded, False: 0]
  |  |  ------------------
  ------------------
  148|       |        
  149|      0|        return 1;
  150|      0|    }
  151|       |
  152|    313|    CALLBACK_LOCK(major,minor);
  ------------------
  |  |  107|    313|#define CALLBACK_LOCK(maj,min) ++_locks[maj][min]
  ------------------
  153|    313|    return 0;
  154|    313|}
callback.c:_callback_unlock:
  158|    313|{
  159|       |#ifdef NETSNMP_PARANOID_LEVEL_HIGH
  160|       |    if (major < 0 || major >= MAX_CALLBACK_IDS ||
  161|       |        minor < 0 || minor >= MAX_CALLBACK_SUBIDS) {
  162|       |        netsnmp_assert("bad callback id");
  163|       |        return;
  164|       |    }
  165|       |#endif
  166|       |    
  167|    313|    CALLBACK_UNLOCK(major,minor);
  ------------------
  |  |  108|    313|#define CALLBACK_UNLOCK(maj,min) --_locks[maj][min]
  ------------------
  168|       |
  169|    313|    if (CALLBACK_LOCK_COUNT(major,minor) == 0) {
  ------------------
  |  |  109|    313|#define CALLBACK_LOCK_COUNT(maj,min) _locks[maj][min]
  ------------------
  |  Branch (169:9): [True: 313, False: 0]
  ------------------
  170|    313|        struct snmp_gen_callback *scp, **prevNext;
  171|    313|        scp = thecallbacks[major][minor];
  172|    313|        prevNext = &(thecallbacks[major][minor]);
  173|    365|        while (scp != NULL) {
  ------------------
  |  Branch (173:16): [True: 52, False: 313]
  ------------------
  174|     52|            if (scp->sc_callback == NULL) {
  ------------------
  |  Branch (174:17): [True: 0, False: 52]
  ------------------
  175|      0|                *prevNext = scp->next;
  176|      0|                SNMP_FREE(scp);
  ------------------
  |  |   62|      0|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 0, False: 0]
  |  |  |  Branch (62:66): [Folded, False: 0]
  |  |  ------------------
  ------------------
  177|      0|                scp = *prevNext;
  178|     52|            } else {
  179|     52|                prevNext = &(scp->next);
  180|     52|                scp = scp->next;
  181|     52|            }
  182|     52|        }
  183|    313|    }
  184|       |
  185|    313|#ifdef CALLBACK_NAME_LOGGING
  186|    313|    DEBUGMSGTL(("9:callback:lock", "unlocked (%s,%s)\n",
  ------------------
  |  |   66|    313|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|    313|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 313]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (164:52): [True: 0, False: 0]
  |  |  |  |  |  Branch (164:52): [True: 0, False: 0]
  |  |  |  |  |  Branch (164:64): [True: 0, False: 0]
  |  |  |  |  |  Branch (164:64): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 313]
  |  |  ------------------
  ------------------
  187|    313|                types[major], (SNMP_CALLBACK_LIBRARY == major) ?
  188|    313|                SNMP_STRORNULL(lib[minor]) : "null"));
  189|    313|#endif
  190|    313|}

_netsnmp_release_trustcerts:
  175|      2|{
  176|      2|    if (NULL != _trusted_certs) {
  ------------------
  |  Branch (176:9): [True: 2, False: 0]
  ------------------
  177|      2|        CONTAINER_FREE_ALL(_trusted_certs, NULL);
  178|      2|        CONTAINER_FREE(_trusted_certs);
  179|       |        _trusted_certs = NULL;
  180|      2|    }
  181|      2|}
_setup_trusted_certs:
  185|      2|{
  186|      2|    _trusted_certs = netsnmp_container_find("trusted_certs:fifo");
  187|      2|    if (NULL == _trusted_certs) {
  ------------------
  |  Branch (187:9): [True: 0, False: 2]
  ------------------
  188|      0|        snmp_log(LOG_ERR, "could not create container for trusted certs\n");
  189|      0|        netsnmp_certs_shutdown();
  190|      0|        return;
  191|      0|    }
  192|      2|    _trusted_certs->container_name = strdup("trusted certificates");
  193|      2|    _trusted_certs->compare = netsnmp_str_compare;
  194|      2|}
netsnmp_certs_init:
  209|      2|{
  210|      2|    const char *trustCert_help = TRUSTCERT_CONFIG_TOKEN
  ------------------
  |  |  140|      2|#define TRUSTCERT_CONFIG_TOKEN "trustCert"
  ------------------
  211|      2|        " FINGERPRINT|FILENAME";
  212|       |
  213|      2|    register_config_handler("snmp", TRUSTCERT_CONFIG_TOKEN,
  ------------------
  |  |  140|      2|#define TRUSTCERT_CONFIG_TOKEN "trustCert"
  ------------------
  214|      2|                            _parse_trustcert, _netsnmp_release_trustcerts,
  215|      2|                            trustCert_help);
  216|      2|    _setup_containers();
  217|       |
  218|       |    /** add certificate type mapping */
  219|      2|    se_add_pair_to_slist("cert_types", strdup("pem"), NS_CERT_TYPE_PEM);
  220|      2|    se_add_pair_to_slist("cert_types", strdup("crt"), NS_CERT_TYPE_DER);
  221|      2|    se_add_pair_to_slist("cert_types", strdup("cer"), NS_CERT_TYPE_DER);
  222|      2|    se_add_pair_to_slist("cert_types", strdup("cert"), NS_CERT_TYPE_DER);
  223|      2|    se_add_pair_to_slist("cert_types", strdup("der"), NS_CERT_TYPE_DER);
  224|      2|    se_add_pair_to_slist("cert_types", strdup("key"), NS_CERT_TYPE_KEY);
  225|      2|    se_add_pair_to_slist("cert_types", strdup("private"), NS_CERT_TYPE_KEY);
  226|       |
  227|       |    /** hash algs */
  228|      2|    se_add_pair_to_slist("cert_hash_alg", strdup("sha1"), NS_HASH_SHA1);
  ------------------
  |  |   85|      2|#define NS_HASH_SHA1        2
  ------------------
  229|      2|    se_add_pair_to_slist("cert_hash_alg", strdup("md5"), NS_HASH_MD5);
  ------------------
  |  |   84|      2|#define NS_HASH_MD5         1
  ------------------
  230|      2|    se_add_pair_to_slist("cert_hash_alg", strdup("sha224"), NS_HASH_SHA224);
  ------------------
  |  |   86|      2|#define NS_HASH_SHA224      3
  ------------------
  231|      2|    se_add_pair_to_slist("cert_hash_alg", strdup("sha256"), NS_HASH_SHA256);
  ------------------
  |  |   87|      2|#define NS_HASH_SHA256      4
  ------------------
  232|      2|    se_add_pair_to_slist("cert_hash_alg", strdup("sha384"), NS_HASH_SHA384);
  ------------------
  |  |   88|      2|#define NS_HASH_SHA384      5
  ------------------
  233|      2|    se_add_pair_to_slist("cert_hash_alg", strdup("sha512"), NS_HASH_SHA512);
  ------------------
  |  |   89|      2|#define NS_HASH_SHA512      6
  ------------------
  234|       |
  235|       |    /** map types */
  236|      2|    se_add_pair_to_slist("cert_map_type", strdup("cn"),
  237|      2|                         TSNM_tlstmCertCommonName);
  ------------------
  |  |  129|      2|#define TSNM_tlstmCertCommonName                6
  ------------------
  238|      2|    se_add_pair_to_slist("cert_map_type", strdup("ip"),
  239|      2|                         TSNM_tlstmCertSANIpAddress);
  ------------------
  |  |  127|      2|#define TSNM_tlstmCertSANIpAddress              4
  ------------------
  240|      2|    se_add_pair_to_slist("cert_map_type", strdup("rfc822"),
  241|      2|                         TSNM_tlstmCertSANRFC822Name);
  ------------------
  |  |  125|      2|#define TSNM_tlstmCertSANRFC822Name             2
  ------------------
  242|      2|    se_add_pair_to_slist("cert_map_type", strdup("dns"),
  243|      2|                         TSNM_tlstmCertSANDNSName);
  ------------------
  |  |  126|      2|#define TSNM_tlstmCertSANDNSName                3
  ------------------
  244|      2|    se_add_pair_to_slist("cert_map_type", strdup("any"), TSNM_tlstmCertSANAny);
  ------------------
  |  |  128|      2|#define TSNM_tlstmCertSANAny                    5
  ------------------
  245|      2|    se_add_pair_to_slist("cert_map_type", strdup("sn"),
  246|      2|                         TSNM_tlstmCertSpecified);
  ------------------
  |  |  124|      2|#define TSNM_tlstmCertSpecified                 1
  ------------------
  247|       |
  248|      2|}
netsnmp_certs_load:
  271|      2|{
  272|      2|    netsnmp_iterator  *itr;
  273|      2|    netsnmp_key        *key;
  274|      2|    netsnmp_cert       *cert;
  275|       |
  276|      2|    DEBUGMSGT(("cert:util:init","init\n"));
  ------------------
  |  |   62|      2|#define DEBUGMSGT(x)       do {if (_DBG_IF_) {__DBGMSGT(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      2|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 2]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGT(x)       do {if (_DBG_IF_) {__DBGMSGT(x);} }while(0)
  |  |  ------------------
  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  ------------------
  |  |  |  Branch (62:69): [Folded, False: 2]
  |  |  ------------------
  ------------------
  277|       |
  278|      2|    if (NULL == _certs) {
  ------------------
  |  Branch (278:9): [True: 0, False: 2]
  ------------------
  279|      0|        snmp_log(LOG_ERR, "cant load certs without container\n");
  280|      0|        return;
  281|      0|    }
  282|       |
  283|      2|    if (CONTAINER_SIZE(_certs) != 0) {
  ------------------
  |  |  403|      2|#define CONTAINER_SIZE(x)           (x)->get_size(x)
  ------------------
  |  Branch (283:9): [True: 0, False: 2]
  ------------------
  284|      0|        DEBUGMSGT(("cert:util:init", "ignoring duplicate init\n"));
  ------------------
  |  |   62|      0|#define DEBUGMSGT(x)       do {if (_DBG_IF_) {__DBGMSGT(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGT(x)       do {if (_DBG_IF_) {__DBGMSGT(x);} }while(0)
  |  |  ------------------
  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  ------------------
  |  |  |  Branch (62:69): [Folded, False: 0]
  |  |  ------------------
  ------------------
  285|      0|        return;
  286|      0|    }
  287|       |
  288|      2|    netsnmp_init_openssl();
  289|       |
  290|       |    /** scan config dirs for certs */
  291|      2|    _cert_indexes_load();
  292|       |
  293|       |    /** match up keys w/certs */
  294|      2|    itr = CONTAINER_ITERATOR(_keys);
  ------------------
  |  |  404|      2|#define CONTAINER_ITERATOR(x)       (x)->get_iterator(x)
  ------------------
  295|      2|    if (NULL == itr) {
  ------------------
  |  Branch (295:9): [True: 0, False: 2]
  ------------------
  296|      0|        snmp_log(LOG_ERR, "could not get iterator for keys\n");
  297|      0|        netsnmp_certs_shutdown();
  298|      0|        return;
  299|      0|    }
  300|      2|    key = ITERATOR_FIRST(itr);
  ------------------
  |  |  546|      2|#define ITERATOR_FIRST(x)  x->first(x)
  ------------------
  301|      2|    for( ; key; key = ITERATOR_NEXT(itr))
  ------------------
  |  |  547|      0|#define ITERATOR_NEXT(x)   x->next(x)
  ------------------
  |  Branch (301:12): [True: 0, False: 2]
  ------------------
  302|      0|        _find_partner(NULL, key);
  303|      2|    ITERATOR_RELEASE(itr);
  ------------------
  |  |  550|      2|#define ITERATOR_RELEASE(x) do { x->release(x); x = NULL; } while(0)
  |  |  ------------------
  |  |  |  Branch (550:67): [Folded, False: 2]
  |  |  ------------------
  ------------------
  304|       |
  305|      2|    DEBUGIF("cert:dump") {
  ------------------
  |  |  145|      2|#define DEBUGIF(x)         if (_DBG_IF_ && debug_is_token_registered(x) == SNMPERR_SUCCESS)
  |  |  ------------------
  |  |  |  |  144|      4|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 2]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGIF(x)         if (_DBG_IF_ && debug_is_token_registered(x) == SNMPERR_SUCCESS)
  |  |  ------------------
  |  |  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  ------------------
  |  |  |  Branch (145:44): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  306|      0|        itr = CONTAINER_ITERATOR(_certs);
  ------------------
  |  |  404|      0|#define CONTAINER_ITERATOR(x)       (x)->get_iterator(x)
  ------------------
  307|      0|        if (NULL == itr) {
  ------------------
  |  Branch (307:13): [True: 0, False: 0]
  ------------------
  308|      0|            snmp_log(LOG_ERR, "could not get iterator for certs\n");
  309|      0|            netsnmp_certs_shutdown();
  310|      0|            return;
  311|      0|        }
  312|      0|        cert = ITERATOR_FIRST(itr);
  ------------------
  |  |  546|      0|#define ITERATOR_FIRST(x)  x->first(x)
  ------------------
  313|      0|        for( ; cert; cert = ITERATOR_NEXT(itr)) {
  ------------------
  |  |  547|      0|#define ITERATOR_NEXT(x)   x->next(x)
  ------------------
  |  Branch (313:16): [True: 0, False: 0]
  ------------------
  314|      0|            netsnmp_cert_load_x509(cert);
  315|      0|        }
  316|      0|        ITERATOR_RELEASE(itr);
  ------------------
  |  |  550|      0|#define ITERATOR_RELEASE(x) do { x->release(x); x = NULL; } while(0)
  |  |  ------------------
  |  |  |  Branch (550:67): [Folded, False: 0]
  |  |  ------------------
  ------------------
  317|      0|        DEBUGMSGT(("cert:dump",
  ------------------
  |  |   62|      0|#define DEBUGMSGT(x)       do {if (_DBG_IF_) {__DBGMSGT(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGT(x)       do {if (_DBG_IF_) {__DBGMSGT(x);} }while(0)
  |  |  ------------------
  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  ------------------
  |  |  |  Branch (62:69): [Folded, False: 0]
  |  |  ------------------
  ------------------
  318|      0|                   "-------------------- Certificates -----------------\n"));
  319|      0|        netsnmp_cert_dump_all();
  320|      0|        DEBUGMSGT(("cert:dump",
  ------------------
  |  |   62|      0|#define DEBUGMSGT(x)       do {if (_DBG_IF_) {__DBGMSGT(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGT(x)       do {if (_DBG_IF_) {__DBGMSGT(x);} }while(0)
  |  |  ------------------
  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  ------------------
  |  |  |  Branch (62:69): [Folded, False: 0]
  |  |  ------------------
  ------------------
  321|      0|                   "------------------------ End ----------------------\n"));
  322|      0|    }
  323|      2|}
cert_util.c:_setup_containers:
  353|      2|{
  354|      2|    netsnmp_container *additional_keys;
  355|       |
  356|      2|    int rc;
  357|       |
  358|      2|    _certs = _get_cert_container("netsnmp certificates");
  359|      2|    if (NULL == _certs)
  ------------------
  |  Branch (359:9): [True: 0, False: 2]
  ------------------
  360|      0|        return;
  361|       |
  362|       |    /** additional keys: common name */
  363|      2|    additional_keys = netsnmp_container_find("certs_cn:binary_array");
  364|      2|    if (NULL == additional_keys) {
  ------------------
  |  Branch (364:9): [True: 0, False: 2]
  ------------------
  365|      0|        snmp_log(LOG_ERR, "could not create CN container for certificates\n");
  366|      0|        netsnmp_certs_shutdown();
  367|      0|        return;
  368|      0|    }
  369|      2|    additional_keys->container_name = strdup("certs_cn");
  370|      2|    additional_keys->free_item = NULL;
  371|      2|    additional_keys->compare = _cert_cn_compare;
  372|      2|    CONTAINER_SET_OPTIONS(additional_keys, CONTAINER_KEY_ALLOW_DUPLICATES, rc);
  ------------------
  |  |  375|      2|#define CONTAINER_SET_OPTIONS(x,o,rc)  do {                             \
  |  |  376|      2|        if (NULL==(x)->options)                                         \
  |  |  ------------------
  |  |  |  Branch (376:13): [True: 0, False: 2]
  |  |  ------------------
  |  |  377|      2|            rc = -1;                                                    \
  |  |  378|      2|        else {                                                          \
  |  |  379|      2|            rc = (x)->options(x, 1, o);                                 \
  |  |  380|      2|            if (rc != -1 )                                              \
  |  |  ------------------
  |  |  |  Branch (380:17): [True: 2, False: 0]
  |  |  ------------------
  |  |  381|      2|                (x)->flags |= o;                                        \
  |  |  382|      2|        }                                                               \
  |  |  383|      2|    } while(0)
  |  |  ------------------
  |  |  |  Branch (383:13): [Folded, False: 2]
  |  |  ------------------
  ------------------
  373|      2|    netsnmp_container_add_index(_certs, additional_keys);
  374|       |
  375|       |    /** additional keys: subject name */
  376|      2|    additional_keys = netsnmp_container_find("certs_sn:binary_array");
  377|      2|    if (NULL == additional_keys) {
  ------------------
  |  Branch (377:9): [True: 0, False: 2]
  ------------------
  378|      0|        snmp_log(LOG_ERR, "could not create SN container for certificates\n");
  379|      0|        netsnmp_certs_shutdown();
  380|      0|        return;
  381|      0|    }
  382|      2|    additional_keys->container_name = strdup("certs_sn");
  383|      2|    additional_keys->free_item = NULL;
  384|      2|    additional_keys->compare = _cert_sn_compare;
  385|      2|    additional_keys->ncompare = _cert_sn_ncompare;
  386|      2|    CONTAINER_SET_OPTIONS(additional_keys, CONTAINER_KEY_ALLOW_DUPLICATES, rc);
  ------------------
  |  |  375|      2|#define CONTAINER_SET_OPTIONS(x,o,rc)  do {                             \
  |  |  376|      2|        if (NULL==(x)->options)                                         \
  |  |  ------------------
  |  |  |  Branch (376:13): [True: 0, False: 2]
  |  |  ------------------
  |  |  377|      2|            rc = -1;                                                    \
  |  |  378|      2|        else {                                                          \
  |  |  379|      2|            rc = (x)->options(x, 1, o);                                 \
  |  |  380|      2|            if (rc != -1 )                                              \
  |  |  ------------------
  |  |  |  Branch (380:17): [True: 2, False: 0]
  |  |  ------------------
  |  |  381|      2|                (x)->flags |= o;                                        \
  |  |  382|      2|        }                                                               \
  |  |  383|      2|    } while(0)
  |  |  ------------------
  |  |  |  Branch (383:13): [Folded, False: 2]
  |  |  ------------------
  ------------------
  387|      2|    netsnmp_container_add_index(_certs, additional_keys);
  388|       |
  389|       |    /** additional keys: file name */
  390|      2|    additional_keys = netsnmp_container_find("certs_fn:binary_array");
  391|      2|    if (NULL == additional_keys) {
  ------------------
  |  Branch (391:9): [True: 0, False: 2]
  ------------------
  392|      0|        snmp_log(LOG_ERR, "could not create FN container for certificates\n");
  393|      0|        netsnmp_certs_shutdown();
  394|      0|        return;
  395|      0|    }
  396|      2|    additional_keys->container_name = strdup("certs_fn");
  397|      2|    additional_keys->free_item = NULL;
  398|      2|    additional_keys->compare = _cert_fn_compare;
  399|      2|    additional_keys->ncompare = _cert_fn_ncompare;
  400|      2|    CONTAINER_SET_OPTIONS(additional_keys, CONTAINER_KEY_ALLOW_DUPLICATES, rc);
  ------------------
  |  |  375|      2|#define CONTAINER_SET_OPTIONS(x,o,rc)  do {                             \
  |  |  376|      2|        if (NULL==(x)->options)                                         \
  |  |  ------------------
  |  |  |  Branch (376:13): [True: 0, False: 2]
  |  |  ------------------
  |  |  377|      2|            rc = -1;                                                    \
  |  |  378|      2|        else {                                                          \
  |  |  379|      2|            rc = (x)->options(x, 1, o);                                 \
  |  |  380|      2|            if (rc != -1 )                                              \
  |  |  ------------------
  |  |  |  Branch (380:17): [True: 2, False: 0]
  |  |  ------------------
  |  |  381|      2|                (x)->flags |= o;                                        \
  |  |  382|      2|        }                                                               \
  |  |  383|      2|    } while(0)
  |  |  ------------------
  |  |  |  Branch (383:13): [Folded, False: 2]
  |  |  ------------------
  ------------------
  401|      2|    netsnmp_container_add_index(_certs, additional_keys);
  402|       |
  403|      2|    _keys = netsnmp_container_find("cert_keys:binary_array");
  404|      2|    if (NULL == _keys) {
  ------------------
  |  Branch (404:9): [True: 0, False: 2]
  ------------------
  405|      0|        snmp_log(LOG_ERR, "could not create container for certificate keys\n");
  406|      0|        netsnmp_certs_shutdown();
  407|      0|        return;
  408|      0|    }
  409|      2|    _keys->container_name = strdup("netsnmp certificate keys");
  410|      2|    _keys->free_item = _key_free;
  411|      2|    _keys->compare = _cert_fn_compare;
  412|       |
  413|      2|    _setup_trusted_certs();
  414|      2|}
cert_util.c:_get_cert_container:
  332|      2|{
  333|      2|    netsnmp_container *c;
  334|       |
  335|      2|    int rc;
  336|       |
  337|      2|    c = netsnmp_container_find("certs:binary_array");
  338|      2|    if (NULL == c) {
  ------------------
  |  Branch (338:9): [True: 0, False: 2]
  ------------------
  339|      0|        snmp_log(LOG_ERR, "could not create container for %s\n", use);
  340|      0|        return NULL;
  341|      0|    }
  342|      2|    c->container_name = strdup(use);
  343|      2|    c->free_item = _cert_free;
  344|      2|    c->compare = _cert_compare;
  345|       |
  346|      2|    CONTAINER_SET_OPTIONS(c, CONTAINER_KEY_ALLOW_DUPLICATES, rc);
  ------------------
  |  |  375|      2|#define CONTAINER_SET_OPTIONS(x,o,rc)  do {                             \
  |  |  376|      2|        if (NULL==(x)->options)                                         \
  |  |  ------------------
  |  |  |  Branch (376:13): [True: 0, False: 2]
  |  |  ------------------
  |  |  377|      2|            rc = -1;                                                    \
  |  |  378|      2|        else {                                                          \
  |  |  379|      2|            rc = (x)->options(x, 1, o);                                 \
  |  |  380|      2|            if (rc != -1 )                                              \
  |  |  ------------------
  |  |  |  Branch (380:17): [True: 2, False: 0]
  |  |  ------------------
  |  |  381|      2|                (x)->flags |= o;                                        \
  |  |  382|      2|        }                                                               \
  |  |  383|      2|    } while(0)
  |  |  ------------------
  |  |  |  Branch (383:13): [Folded, False: 2]
  |  |  ------------------
  ------------------
  347|       |
  348|      2|    return c;
  349|      2|}
cert_util.c:_cert_indexes_load:
 1723|      2|{
 1724|      2|    const char     *confpath;
 1725|      2|    char           *confpath_copy, *dir, *st = NULL;
 1726|      2|    char            certdir[SNMP_MAXPATH];
 1727|      2|    const char     *subdirs[] = { NULL, "ca-certs", "certs", "private", NULL };
 1728|      2|    int             i = 0;
 1729|       |
 1730|       |    /*
 1731|       |     * load indexes from persistent dir
 1732|       |     */
 1733|      2|    _certindexes_load();
 1734|       |
 1735|       |    /*
 1736|       |     * duplicate path building from read_config_files_of_type() in
 1737|       |     * read_config.c. That is, use SNMPCONFPATH environment variable if
 1738|       |     * it is defined, otherwise use configuration directory.
 1739|       |     */
 1740|      2|    confpath = netsnmp_getenv("SNMPCONFPATH");
 1741|      2|    if (NULL == confpath)
  ------------------
  |  Branch (1741:9): [True: 2, False: 0]
  ------------------
 1742|      2|        confpath = get_configuration_directory();
 1743|       |
 1744|      2|    subdirs[0] = netsnmp_ds_get_string(NETSNMP_DS_LIBRARY_ID,
  ------------------
  |  |   48|      2|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
 1745|      2|                                       NETSNMP_DS_LIB_CERT_EXTRA_SUBDIR);
  ------------------
  |  |  177|      2|#define NETSNMP_DS_LIB_CERT_EXTRA_SUBDIR 26
  ------------------
 1746|      2|    confpath_copy = strdup(confpath);
 1747|      2|    if (!confpath_copy)
  ------------------
  |  Branch (1747:9): [True: 0, False: 2]
  ------------------
 1748|      0|        return;
 1749|      2|    for ( dir = strtok_r(confpath_copy, ENV_SEPARATOR, &st);
  ------------------
  |  |   67|      2|#define ENV_SEPARATOR ":"
  ------------------
 1750|     10|          dir; dir = strtok_r(NULL, ENV_SEPARATOR, &st)) {
  ------------------
  |  |   67|      8|#define ENV_SEPARATOR ":"
  ------------------
  |  Branch (1750:11): [True: 8, False: 2]
  ------------------
 1751|       |
 1752|      8|        i = (NULL == subdirs[0]) ? 1 : 0;
  ------------------
  |  Branch (1752:13): [True: 8, False: 0]
  ------------------
 1753|     32|        for ( ; subdirs[i] ; ++i ) {
  ------------------
  |  Branch (1753:17): [True: 24, False: 8]
  ------------------
 1754|       |            /** check tls subdir */
 1755|     24|            snprintf(certdir, sizeof(certdir), "%s/tls/%s", dir, subdirs[i]);
 1756|     24|            _add_certdir(certdir);
 1757|     24|        } /* for subdirs */
 1758|      8|    } /* for conf path dirs */
 1759|       |    SNMP_FREE(confpath_copy);
  ------------------
  |  |   62|      2|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 2, False: 0]
  |  |  |  Branch (62:66): [Folded, False: 2]
  |  |  ------------------
  ------------------
 1760|      2|}
cert_util.c:_certindexes_load:
  779|      2|{
  780|      2|    DIR *dir;
  781|      2|    struct dirent *file;
  782|      2|    FILE *fp;
  783|      2|    char filename[SNMP_MAXPATH], line[300];
  784|      2|    int  i;
  785|      2|    char *cp, *pos;
  786|       |
  787|       |    /*
  788|       |     * Open the CERT index directory, or create it (empty)
  789|       |     */
  790|      2|    snprintf(filename, sizeof(filename), "%s/cert_indexes",
  791|      2|             get_persistent_directory());
  792|      2|    dir = opendir( filename );
  793|      2|    if ( dir == NULL ) {
  ------------------
  |  Branch (793:10): [True: 0, False: 2]
  ------------------
  794|      0|        DEBUGMSGT(("cert:index:load",
  ------------------
  |  |   62|      0|#define DEBUGMSGT(x)       do {if (_DBG_IF_) {__DBGMSGT(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGT(x)       do {if (_DBG_IF_) {__DBGMSGT(x);} }while(0)
  |  |  ------------------
  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  ------------------
  |  |  |  Branch (62:69): [Folded, False: 0]
  |  |  ------------------
  ------------------
  795|      0|                   "creating new cert_indexes directory\n"));
  796|      0|        mkdirhier( filename, NETSNMP_AGENT_DIRECTORY_MODE, 0);
  ------------------
  |  | 2037|      0|#define NETSNMP_AGENT_DIRECTORY_MODE 0700
  ------------------
  797|      0|        return;
  798|      0|    }
  799|       |
  800|       |    /*
  801|       |     * Create a list of which directory each file refers to
  802|       |     */
  803|      6|    while ((file = readdir( dir ))) {
  ------------------
  |  Branch (803:12): [True: 4, False: 2]
  ------------------
  804|      4|        if ( !isdigit(0xFF & file->d_name[0]))
  ------------------
  |  Branch (804:14): [True: 4, False: 0]
  ------------------
  805|      4|            continue;
  806|      0|        i = atoi( file->d_name );
  807|       |
  808|      0|        snprintf(filename, sizeof(filename), "%s/cert_indexes/%d",
  809|      0|                 get_persistent_directory(), i );
  810|      0|        fp = fopen( filename, "r" );
  811|      0|        if ( !fp ) {
  ------------------
  |  Branch (811:14): [True: 0, False: 0]
  ------------------
  812|      0|            DEBUGMSGT(("cert:index:load", "error opening index (%d)\n", i));
  ------------------
  |  |   62|      0|#define DEBUGMSGT(x)       do {if (_DBG_IF_) {__DBGMSGT(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGT(x)       do {if (_DBG_IF_) {__DBGMSGT(x);} }while(0)
  |  |  ------------------
  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  ------------------
  |  |  |  Branch (62:69): [Folded, False: 0]
  |  |  ------------------
  ------------------
  813|      0|            continue;
  814|      0|        }
  815|      0|        cp = fgets( line, sizeof(line), fp );
  816|      0|        if ( cp )
  ------------------
  |  Branch (816:14): [True: 0, False: 0]
  ------------------
  817|      0|            line[strcspn(line, "\r\n")] = '\0';
  818|      0|        if ( cp && strncmp(line, "DIR ", 4) == 0 ) {
  ------------------
  |  Branch (818:14): [True: 0, False: 0]
  |  Branch (818:20): [True: 0, False: 0]
  ------------------
  819|      0|            pos = strrchr(line + 4, ' ');
  820|      0|            if (pos)
  ------------------
  |  Branch (820:17): [True: 0, False: 0]
  ------------------
  821|      0|                *pos = '\0';
  822|      0|            DEBUGMSGT(("9:cert:index:load","adding (%d) %s\n", i, line));
  ------------------
  |  |   62|      0|#define DEBUGMSGT(x)       do {if (_DBG_IF_) {__DBGMSGT(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGT(x)       do {if (_DBG_IF_) {__DBGMSGT(x);} }while(0)
  |  |  ------------------
  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  ------------------
  |  |  |  Branch (62:69): [Folded, False: 0]
  |  |  ------------------
  ------------------
  823|      0|            (void)_certindex_add( line+4, i );  /* Skip 'DIR ' */
  824|      0|        } else {
  825|      0|            DEBUGMSGT(("cert:index:load", "Empty index (%d)\n", i));
  ------------------
  |  |   62|      0|#define DEBUGMSGT(x)       do {if (_DBG_IF_) {__DBGMSGT(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGT(x)       do {if (_DBG_IF_) {__DBGMSGT(x);} }while(0)
  |  |  ------------------
  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  ------------------
  |  |  |  Branch (62:69): [Folded, False: 0]
  |  |  ------------------
  ------------------
  826|      0|        }
  827|      0|        fclose( fp );
  828|      0|    }
  829|      2|    closedir( dir );
  830|      2|}
cert_util.c:_add_certdir:
 1632|     24|{
 1633|     24|    FILE           *index;
 1634|     24|    char           *file;
 1635|     24|    int             count = 0;
 1636|     24|    netsnmp_container *cert_container;
 1637|     24|    netsnmp_iterator  *it;
 1638|     24|    struct stat     statbuf;
 1639|       |
 1640|     24|    netsnmp_assert(NULL != dirname);
  ------------------
  |  |   47|     24|#      define netsnmp_assert(x)  do { \
  |  |   48|     24|              if ( x ) \
  |  |  ------------------
  |  |  |  Branch (48:20): [True: 24, False: 0]
  |  |  ------------------
  |  |   49|     24|                 ; \
  |  |   50|     24|              else \
  |  |   51|     24|                 snmp_log(LOG_ERR, \
  |  |   52|      0|                          "netsnmp_assert %s failed %s:%d" NETSNMP_FUNC_FMT, \
  |  |  ------------------
  |  |  |  |   40|      0|#          define NETSNMP_FUNC_FMT " %s()\n"
  |  |  ------------------
  |  |   53|      0|                          __STRING(x),__FILE__,__LINE__, \
  |  |   54|      0|                          NETSNMP_FUNC_PARAM); \
  |  |  ------------------
  |  |  |  |   41|      0|#          define NETSNMP_FUNC_PARAM NETSNMP_FUNCTION
  |  |  |  |  ------------------
  |  |  |  |  |  | 1727|      0|#define NETSNMP_FUNCTION __func__
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   55|     24|           }while(0)
  |  |  ------------------
  |  |  |  Branch (55:19): [Folded, False: 24]
  |  |  ------------------
  ------------------
 1641|       |
 1642|     24|    DEBUGMSGT(("9:cert:dir:add", " config dir: %s\n", dirname ));
  ------------------
  |  |   62|     24|#define DEBUGMSGT(x)       do {if (_DBG_IF_) {__DBGMSGT(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     24|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 24]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGT(x)       do {if (_DBG_IF_) {__DBGMSGT(x);} }while(0)
  |  |  ------------------
  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  ------------------
  |  |  |  Branch (62:69): [Folded, False: 24]
  |  |  ------------------
  ------------------
 1643|       |
 1644|     24|    if (stat(dirname, &statbuf) != 0) {
  ------------------
  |  Branch (1644:9): [True: 24, False: 0]
  ------------------
 1645|     24|        DEBUGMSGT(("9:cert:dir:add", " dir not present: %s\n",
  ------------------
  |  |   62|     24|#define DEBUGMSGT(x)       do {if (_DBG_IF_) {__DBGMSGT(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     24|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 24]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGT(x)       do {if (_DBG_IF_) {__DBGMSGT(x);} }while(0)
  |  |  ------------------
  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  ------------------
  |  |  |  Branch (62:69): [Folded, False: 24]
  |  |  ------------------
  ------------------
 1646|     24|                   dirname ));
 1647|     24|        return -1;
 1648|     24|    }
 1649|      0|#ifdef S_ISDIR
 1650|      0|    if (!S_ISDIR(statbuf.st_mode)) {
  ------------------
  |  Branch (1650:9): [True: 0, False: 0]
  ------------------
 1651|      0|        DEBUGMSGT(("9:cert:dir:add", " not a dir: %s\n", dirname ));
  ------------------
  |  |   62|      0|#define DEBUGMSGT(x)       do {if (_DBG_IF_) {__DBGMSGT(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGT(x)       do {if (_DBG_IF_) {__DBGMSGT(x);} }while(0)
  |  |  ------------------
  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  ------------------
  |  |  |  Branch (62:69): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1652|      0|        return -1;
 1653|      0|    }
 1654|      0|#endif
 1655|       |
 1656|      0|    DEBUGMSGT(("cert:index:dir", "Scanning directory %s\n", dirname));
  ------------------
  |  |   62|      0|#define DEBUGMSGT(x)       do {if (_DBG_IF_) {__DBGMSGT(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGT(x)       do {if (_DBG_IF_) {__DBGMSGT(x);} }while(0)
  |  |  ------------------
  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  ------------------
  |  |  |  Branch (62:69): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1657|       |
 1658|       |    /*
 1659|       |     * look for existing index
 1660|       |     */
 1661|      0|    count = _cert_read_index(dirname, &statbuf);
 1662|      0|    if (count >= 0)
  ------------------
  |  Branch (1662:9): [True: 0, False: 0]
  ------------------
 1663|      0|        return count;
 1664|       |
 1665|      0|    index = _certindex_new( dirname );
 1666|      0|    if (NULL == index) {
  ------------------
  |  Branch (1666:9): [True: 0, False: 0]
  ------------------
 1667|      0|        DEBUGMSGT(("9:cert:index:dir",
  ------------------
  |  |   62|      0|#define DEBUGMSGT(x)       do {if (_DBG_IF_) {__DBGMSGT(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGT(x)       do {if (_DBG_IF_) {__DBGMSGT(x);} }while(0)
  |  |  ------------------
  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  ------------------
  |  |  |  Branch (62:69): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1668|      0|                    "error opening index for cert directory\n"));
 1669|      0|        DEBUGMSGTL(("cert:index", "could not open certificate index file\n"));
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1670|      0|    }
 1671|       |
 1672|       |    /*
 1673|       |     * index was missing, out of date or bad. rescan directory.
 1674|       |     */
 1675|      0|    cert_container =
 1676|      0|        netsnmp_directory_container_read_some(NULL, dirname,
 1677|      0|                                              _cert_cert_filter, NULL,
 1678|      0|                                              NETSNMP_DIR_RELATIVE_PATH |
  ------------------
  |  |   48|      0|#define NETSNMP_DIR_RELATIVE_PATH                     0x0002
  ------------------
 1679|      0|                                              NETSNMP_DIR_EMPTY_OK |
  ------------------
  |  |   51|      0|#define NETSNMP_DIR_EMPTY_OK                          0x0008
  ------------------
 1680|      0|                                              NETSNMP_DIR_ALLOW_DUPLICATES);
  ------------------
  |  |   57|      0|#define NETSNMP_DIR_ALLOW_DUPLICATES                  0x0040
  ------------------
 1681|      0|    if (NULL == cert_container) {
  ------------------
  |  Branch (1681:9): [True: 0, False: 0]
  ------------------
 1682|      0|        DEBUGMSGT(("cert:index:dir",
  ------------------
  |  |   62|      0|#define DEBUGMSGT(x)       do {if (_DBG_IF_) {__DBGMSGT(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGT(x)       do {if (_DBG_IF_) {__DBGMSGT(x);} }while(0)
  |  |  ------------------
  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  ------------------
  |  |  |  Branch (62:69): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1683|      0|                    "error creating container for cert files\n"));
 1684|      0|        goto err_index;
 1685|      0|    }
 1686|       |
 1687|       |    /*
 1688|       |     * iterate through the found files and add them to index
 1689|       |     */
 1690|      0|    it = CONTAINER_ITERATOR(cert_container);
  ------------------
  |  |  404|      0|#define CONTAINER_ITERATOR(x)       (x)->get_iterator(x)
  ------------------
 1691|      0|    if (NULL == it) {
  ------------------
  |  Branch (1691:9): [True: 0, False: 0]
  ------------------
 1692|      0|        DEBUGMSGT(("cert:index:dir",
  ------------------
  |  |   62|      0|#define DEBUGMSGT(x)       do {if (_DBG_IF_) {__DBGMSGT(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGT(x)       do {if (_DBG_IF_) {__DBGMSGT(x);} }while(0)
  |  |  ------------------
  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  ------------------
  |  |  |  Branch (62:69): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1693|      0|                    "error creating iterator for cert files\n"));
 1694|      0|        goto err_container;
 1695|      0|    }
 1696|       |
 1697|      0|    for (file = ITERATOR_FIRST(it); file; file = ITERATOR_NEXT(it)) {
  ------------------
  |  |  546|      0|#define ITERATOR_FIRST(x)  x->first(x)
  ------------------
                  for (file = ITERATOR_FIRST(it); file; file = ITERATOR_NEXT(it)) {
  ------------------
  |  |  547|      0|#define ITERATOR_NEXT(x)   x->next(x)
  ------------------
  |  Branch (1697:37): [True: 0, False: 0]
  ------------------
 1698|      0|        DEBUGMSGT(("cert:index:dir", "adding %s to index\n", file));
  ------------------
  |  |   62|      0|#define DEBUGMSGT(x)       do {if (_DBG_IF_) {__DBGMSGT(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGT(x)       do {if (_DBG_IF_) {__DBGMSGT(x);} }while(0)
  |  |  ------------------
  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  ------------------
  |  |  |  Branch (62:69): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1699|      0|        if ( 0 == _add_certfile( dirname, file, index ))
  ------------------
  |  Branch (1699:14): [True: 0, False: 0]
  ------------------
 1700|      0|            count++;
 1701|      0|        else
 1702|      0|            DEBUGMSGT(("cert:index:dir", "error adding %s to index\n",
  ------------------
  |  |   62|      0|#define DEBUGMSGT(x)       do {if (_DBG_IF_) {__DBGMSGT(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGT(x)       do {if (_DBG_IF_) {__DBGMSGT(x);} }while(0)
  |  |  ------------------
  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  ------------------
  |  |  |  Branch (62:69): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1703|      0|                        file));
 1704|      0|    }
 1705|       |
 1706|       |    /*
 1707|       |     * clean up and return
 1708|       |     */
 1709|      0|    ITERATOR_RELEASE(it);
  ------------------
  |  |  550|      0|#define ITERATOR_RELEASE(x) do { x->release(x); x = NULL; } while(0)
  |  |  ------------------
  |  |  |  Branch (550:67): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1710|       |
 1711|      0|  err_container:
 1712|      0|    netsnmp_directory_container_free(cert_container);
 1713|       |
 1714|      0|  err_index:
 1715|      0|    if (index)
  ------------------
  |  Branch (1715:9): [True: 0, False: 0]
  ------------------
 1716|      0|        fclose(index);
 1717|       |
 1718|      0|    return count;
 1719|      0|}

netsnmp_container_init_list:
   82|      2|{
   83|      2|    if (NULL != containers)
  ------------------
  |  Branch (83:9): [True: 0, False: 2]
  ------------------
   84|      0|        return;
   85|       |
   86|       |    /*
   87|       |     * create a binary array container to hold container
   88|       |     * factories
   89|       |     */
   90|      2|    containers = netsnmp_container_get_binary_array();
   91|      2|    containers->compare = netsnmp_compare_cstring;
   92|      2|    containers->container_name = strdup("container list");
   93|       |
   94|       |    /*
   95|       |     * register containers
   96|       |     */
   97|      2|    netsnmp_container_binary_array_init();
   98|      2|#ifndef NETSNMP_FEATURE_REMOVE_CONTAINER_LINKED_LIST
   99|      2|    netsnmp_container_ssll_init();
  100|      2|#endif /* NETSNMP_FEATURE_REMOVE_CONTAINER_LINKED_LIST */
  101|      2|#ifndef NETSNMP_FEATURE_REMOVE_CONTAINER_NULL
  102|      2|    netsnmp_container_null_init();
  103|      2|#endif /* NETSNMP_FEATURE_REMOVE_CONTAINER_NULL */
  104|       |
  105|       |    /*
  106|       |     * default aliases for some containers
  107|       |     */
  108|      2|    netsnmp_container_register("table_container",
  109|      2|                               netsnmp_container_get_factory("binary_array"));
  110|       |
  111|      2|#ifndef NETSNMP_FEATURE_REMOVE_CONTAINER_LINKED_LIST
  112|      2|    netsnmp_container_register("linked_list",
  113|      2|                               netsnmp_container_get_factory("sorted_singly_linked_list"));
  114|      2|    netsnmp_container_register("ssll_container",
  115|      2|                               netsnmp_container_get_factory("sorted_singly_linked_list"));
  116|      2|#endif /* NETSNMP_FEATURE_REMOVE_CONTAINER_LINKED_LIST */
  117|       |
  118|      2|    netsnmp_container_register_with_compare
  119|      2|        ("cstring", netsnmp_container_get_factory("binary_array"),
  120|      2|         netsnmp_compare_direct_cstring);
  121|       |
  122|      2|    netsnmp_container_register_with_compare
  123|      2|        ("string", netsnmp_container_get_factory("binary_array"),
  124|      2|         netsnmp_compare_cstring);
  125|      2|    netsnmp_container_register_with_compare
  126|      2|        ("string_binary_array", netsnmp_container_get_factory("binary_array"),
  127|      2|         netsnmp_compare_cstring);
  128|       |
  129|      2|}
netsnmp_container_register_with_compare:
  153|     24|{
  154|     24|    container_type *ct, tmp;
  155|       |
  156|     24|    if (NULL==containers)
  ------------------
  |  Branch (156:9): [True: 0, False: 24]
  ------------------
  157|      0|        return -1;
  158|       |
  159|     24|    tmp.name = name;
  160|     24|    ct = (container_type *)CONTAINER_FIND(containers, &tmp);
  ------------------
  |  |  394|     24|#define CONTAINER_FIND(x,k)         (x)->find(x,k)
  ------------------
  161|     24|    if (NULL!=ct) {
  ------------------
  |  Branch (161:9): [True: 0, False: 24]
  ------------------
  162|      0|        DEBUGMSGT(("container_registry",
  ------------------
  |  |   62|      0|#define DEBUGMSGT(x)       do {if (_DBG_IF_) {__DBGMSGT(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGT(x)       do {if (_DBG_IF_) {__DBGMSGT(x);} }while(0)
  |  |  ------------------
  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  ------------------
  |  |  |  Branch (62:69): [Folded, False: 0]
  |  |  ------------------
  ------------------
  163|      0|                   "replacing previous container factory\n"));
  164|      0|        ct->factory = f;
  165|      0|    }
  166|     24|    else {
  167|     24|        ct = SNMP_MALLOC_TYPEDEF(container_type);
  ------------------
  |  |   73|     24|#define SNMP_MALLOC_TYPEDEF(td)  (td *) calloc(1, sizeof(td))
  ------------------
  168|     24|        if (NULL == ct)
  ------------------
  |  Branch (168:13): [True: 0, False: 24]
  ------------------
  169|      0|            return -1;
  170|     24|        ct->name = strdup(name);
  171|     24|        ct->factory = f;
  172|     24|        ct->compare = c;
  173|     24|        CONTAINER_INSERT(containers, ct);
  174|     24|    }
  175|     24|    DEBUGMSGT(("container_registry", "registered container factory %s (%s)\n",
  ------------------
  |  |   62|     24|#define DEBUGMSGT(x)       do {if (_DBG_IF_) {__DBGMSGT(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     24|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 24]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGT(x)       do {if (_DBG_IF_) {__DBGMSGT(x);} }while(0)
  |  |  ------------------
  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  ------------------
  |  |  |  Branch (62:69): [Folded, False: 24]
  |  |  ------------------
  ------------------
  176|     24|               ct->name, f->product));
  177|       |
  178|     24|    return 0;
  179|     24|}
netsnmp_container_register:
  183|     18|{
  184|       |    return netsnmp_container_register_with_compare(name, f, NULL);
  185|     18|}
netsnmp_container_get_factory:
  191|     12|{
  192|     12|    container_type ct, *found;
  193|       |    
  194|     12|    if (NULL==containers)
  ------------------
  |  Branch (194:9): [True: 0, False: 12]
  ------------------
  195|      0|        return NULL;
  196|       |
  197|     12|    ct.name = type;
  198|     12|    found = (container_type *)CONTAINER_FIND(containers, &ct);
  ------------------
  |  |  394|     12|#define CONTAINER_FIND(x,k)         (x)->find(x,k)
  ------------------
  199|       |
  200|     12|    return found ? found->factory : NULL;
  ------------------
  |  Branch (200:12): [True: 12, False: 0]
  ------------------
  201|     12|}
netsnmp_container_find:
  300|     12|{
  301|     12|    container_type *ct = netsnmp_container_find_ct(type);
  302|     12|    netsnmp_container *c = ct ? (netsnmp_container *)(ct->factory->produce()) : NULL;
  ------------------
  |  Branch (302:28): [True: 12, False: 0]
  ------------------
  303|       |
  304|       |    /*
  305|       |     * provide default compare and ncompare
  306|       |     */
  307|     12|    if (c) {
  ------------------
  |  Branch (307:9): [True: 12, False: 0]
  ------------------
  308|     12|        if (ct->compare)
  ------------------
  |  Branch (308:13): [True: 0, False: 12]
  ------------------
  309|      0|            c->compare = ct->compare;
  310|     12|        else if (NULL == c->compare)
  ------------------
  |  Branch (310:18): [True: 12, False: 0]
  ------------------
  311|     12|            c->compare = netsnmp_compare_netsnmp_index;
  312|       |
  313|     12|        if (NULL == c->ncompare)
  ------------------
  |  Branch (313:13): [True: 12, False: 0]
  ------------------
  314|     12|            c->ncompare = netsnmp_ncompare_netsnmp_index;
  315|     12|    }
  316|       |
  317|     12|    return c;
  318|     12|}
netsnmp_container_add_index:
  325|      6|{
  326|      6|    netsnmp_container *curr = primary;
  327|       |
  328|      6|    if((NULL == new_index) || (NULL == primary)) {
  ------------------
  |  Branch (328:8): [True: 0, False: 6]
  |  Branch (328:31): [True: 0, False: 6]
  ------------------
  329|      0|        snmp_log(LOG_ERR, "add index called with null pointer\n");
  330|      0|        return;
  331|      0|    }
  332|       |
  333|     12|    while(curr->next)
  ------------------
  |  Branch (333:11): [True: 6, False: 6]
  ------------------
  334|      6|        curr = curr->next;
  335|       |
  336|      6|    curr->next = new_index;
  337|      6|    new_index->prev = curr;
  338|      6|}
CONTAINER_INSERT_HELPER:
  341|     48|{
  342|     48|    while(x && x->insert_filter && x->insert_filter(x,k) == 1)
  ------------------
  |  Branch (342:11): [True: 24, False: 24]
  |  Branch (342:16): [True: 0, False: 24]
  |  Branch (342:36): [True: 0, False: 0]
  ------------------
  343|      0|        x = x->next;
  344|     48|    if(x) {
  ------------------
  |  Branch (344:8): [True: 24, False: 24]
  ------------------
  345|     24|        int rc = x->insert(x,k);
  346|     24|        if(rc)
  ------------------
  |  Branch (346:12): [True: 0, False: 24]
  ------------------
  347|      0|            snmp_log(LOG_DEBUG,"error on subcontainer '%s' insert (%d)\n",
  348|      0|                     x->container_name ? x->container_name : "", rc);
  ------------------
  |  Branch (348:22): [True: 0, False: 0]
  ------------------
  349|     24|        else {
  350|     24|            rc = CONTAINER_INSERT_HELPER(x->next, k);
  351|     24|            if(rc)
  ------------------
  |  Branch (351:16): [True: 0, False: 24]
  ------------------
  352|      0|                x->remove(x,k);
  353|     24|        }
  354|     24|        return rc;
  355|     24|    }
  356|     24|    return 0;
  357|     48|}
CONTAINER_INSERT:
  360|     24|{
  361|       |    /** start at first container */
  362|     24|    while(x->prev)
  ------------------
  |  Branch (362:11): [True: 0, False: 24]
  ------------------
  363|      0|        x = x->prev;
  364|     24|    return CONTAINER_INSERT_HELPER(x, k);
  365|     24|}
CONTAINER_FREE:
  469|      2|{
  470|      2|    int  rc2, rc = 0;
  471|       |
  472|      2|    if (!x)
  ------------------
  |  Branch (472:9): [True: 0, False: 2]
  ------------------
  473|      0|        return rc;
  474|       |
  475|       |    /** start at last container */
  476|      2|    while(x->next)
  ------------------
  |  Branch (476:11): [True: 0, False: 2]
  ------------------
  477|      0|        x = x->next;
  478|      4|    while(x) {
  ------------------
  |  Branch (478:11): [True: 2, False: 2]
  ------------------
  479|      2|        netsnmp_container *tmp;
  480|      2|        char *name;
  481|      2|        tmp = x->prev;
  482|      2|        name = x->container_name;
  483|      2|        x->container_name = NULL;
  484|      2|        rc2 = x->cfree(x);
  485|      2|        if (rc2) {
  ------------------
  |  Branch (485:13): [True: 0, False: 2]
  ------------------
  486|      0|            snmp_log(LOG_ERR,"error on subcontainer '%s' cfree (%d)\n",
  487|      0|                     name ? name : "", rc2);
  ------------------
  |  Branch (487:22): [True: 0, False: 0]
  ------------------
  488|      0|            rc = rc2;
  489|      0|        }
  490|       |        SNMP_FREE(name);
  ------------------
  |  |   62|      2|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 2, False: 0]
  |  |  |  Branch (62:66): [Folded, False: 2]
  |  |  ------------------
  ------------------
  491|      2|        x = tmp;
  492|      2|    }
  493|      2|    return rc;
  494|      2|}
CONTAINER_CLEAR:
  503|      2|{
  504|       |    /** start at last container */
  505|      2|    while(x->next)
  ------------------
  |  Branch (505:11): [True: 0, False: 2]
  ------------------
  506|      0|        x = x->next;
  507|      2|    while(x->prev) {
  ------------------
  |  Branch (507:11): [True: 0, False: 2]
  ------------------
  508|       |        x->clear(x, NULL, c);
  509|      0|        x = x->prev;
  510|      0|    }
  511|      2|    x->clear(x, f, c);
  512|      2|#ifdef HAVE_MALLOC_TRIM
  513|      2|    malloc_trim(0);
  514|      2|#endif
  515|      2|}
CONTAINER_FREE_ALL:
  524|      2|{
  525|      2|    CONTAINER_CLEAR(x, x->free_item, c);
  526|      2|}
netsnmp_init_container:
  563|     14|{
  564|     14|    if (c == NULL)
  ------------------
  |  Branch (564:9): [True: 0, False: 14]
  ------------------
  565|      0|        return;
  566|       |
  567|     14|    c->init = init;
  568|     14|    c->cfree = cfree;
  569|     14|    c->get_size = size;
  570|     14|    c->compare = cmp;
  571|     14|    c->insert = ins;
  572|     14|    c->remove = rem;
  573|     14|    c->find = fnd;
  574|     14|    c->free_item = netsnmp_container_simple_free;
  575|     14|}
netsnmp_compare_cstring:
  643|    298|{
  644|    298|    const container_type *lhs = lhs_arg;
  645|    298|    const container_type *rhs = rhs_arg;
  646|       |
  647|    298|    return strcmp(lhs->name, rhs->name);
  648|    298|}
container.c:netsnmp_container_get_ct:
  234|     24|{
  235|     24|    container_type ct;
  236|       |
  237|     24|    if (NULL == containers)
  ------------------
  |  Branch (237:9): [True: 0, False: 24]
  ------------------
  238|      0|        return NULL;
  239|       |    
  240|     24|    ct.name = type;
  241|     24|    return (container_type *)CONTAINER_FIND(containers, &ct);
  ------------------
  |  |  394|     24|#define CONTAINER_FIND(x,k)         (x)->find(x,k)
  ------------------
  242|     24|}
container.c:netsnmp_container_find_ct:
  246|     12|{
  247|     12|    container_type    *ct = NULL;
  248|     12|    char              *list, *entry;
  249|     12|    char              *st = NULL;
  250|       |
  251|     12|    if (NULL==type_list)
  ------------------
  |  Branch (251:9): [True: 0, False: 12]
  ------------------
  252|      0|        return NULL;
  253|       |
  254|     12|    list = strdup(type_list);
  255|     12|    if (!list)
  ------------------
  |  Branch (255:9): [True: 0, False: 12]
  ------------------
  256|      0|        return NULL;
  257|     12|    entry = strtok_r(list, ":", &st);
  258|     24|    while (entry) {
  ------------------
  |  Branch (258:12): [True: 24, False: 0]
  ------------------
  259|     24|        ct = netsnmp_container_get_ct(entry);
  260|     24|        if (NULL != ct)
  ------------------
  |  Branch (260:13): [True: 12, False: 12]
  ------------------
  261|     12|            break;
  262|     12|        entry = strtok_r(NULL, ":", &st);
  263|     12|    }
  264|       |
  265|     12|    free(list);
  266|     12|    return ct;
  267|     12|}

netsnmp_binary_array_options_set:
  232|      8|{
  233|      8|#define BA_FLAGS (CONTAINER_KEY_ALLOW_DUPLICATES|CONTAINER_KEY_UNSORTED)
  234|       |
  235|      8|    if (set) {
  ------------------
  |  Branch (235:9): [True: 8, False: 0]
  ------------------
  236|      8|        if ((flags & BA_FLAGS) == flags) {
  ------------------
  |  |  233|      8|#define BA_FLAGS (CONTAINER_KEY_ALLOW_DUPLICATES|CONTAINER_KEY_UNSORTED)
  |  |  ------------------
  |  |  |  |  370|      8|#define CONTAINER_KEY_ALLOW_DUPLICATES             0x00000001
  |  |  ------------------
  |  |               #define BA_FLAGS (CONTAINER_KEY_ALLOW_DUPLICATES|CONTAINER_KEY_UNSORTED)
  |  |  ------------------
  |  |  |  |  371|      8|#define CONTAINER_KEY_UNSORTED                     0x00000002
  |  |  ------------------
  ------------------
  |  Branch (236:13): [True: 8, False: 0]
  ------------------
  237|       |            /** if turning off unsorted, do sort */
  238|      8|            int sort = ((c->flags & CONTAINER_KEY_UNSORTED) &&
  ------------------
  |  |  371|      8|#define CONTAINER_KEY_UNSORTED                     0x00000002
  ------------------
  |  Branch (238:25): [True: 0, False: 8]
  ------------------
  239|      0|                        ! (flags & CONTAINER_KEY_UNSORTED));
  ------------------
  |  |  371|      0|#define CONTAINER_KEY_UNSORTED                     0x00000002
  ------------------
  |  Branch (239:25): [True: 0, False: 0]
  ------------------
  240|      8|            c->flags = flags;
  241|      8|            if (sort) {
  ------------------
  |  Branch (241:17): [True: 0, False: 8]
  ------------------
  242|      0|                binary_array_table *t = (binary_array_table*)c->container_data;
  243|      0|                t->dirty = 1; /* force sort */
  244|      0|                Sort_Array(c);
  245|      0|            }
  246|      8|            return flags;
  247|      8|        } else {
  248|      0|            return -1; /* unsupported flag */
  249|      0|        }
  250|      8|    } else {
  251|      0|        return ((c->flags & flags) == flags);
  252|      0|    }
  253|      8|}
netsnmp_container_get_binary_array:
  817|     12|{
  818|       |    /*
  819|       |     * allocate memory
  820|       |     */
  821|     12|    netsnmp_container *c = SNMP_MALLOC_TYPEDEF(netsnmp_container);
  ------------------
  |  |   73|     12|#define SNMP_MALLOC_TYPEDEF(td)  (td *) calloc(1, sizeof(td))
  ------------------
  822|     12|    if (NULL==c) {
  ------------------
  |  Branch (822:9): [True: 0, False: 12]
  ------------------
  823|      0|        snmp_log(LOG_ERR, "couldn't allocate memory\n");
  824|      0|        return NULL;
  825|      0|    }
  826|       |
  827|     12|    c->container_data = netsnmp_binary_array_initialize();
  828|     12|    if (NULL == c->container_data) {
  ------------------
  |  Branch (828:9): [True: 0, False: 12]
  ------------------
  829|      0|        free(c);
  830|      0|        snmp_log(LOG_ERR, "couldn't allocate memory for container_data\n");
  831|      0|        return NULL;
  832|      0|    }
  833|       |
  834|       |    /*
  835|       |     * NOTE: CHANGES HERE MUST BE DUPLICATED IN duplicate AS WELL!!
  836|       |     */
  837|     12|    netsnmp_init_container(c, NULL, _ba_free, _ba_size, NULL, _ba_insert,
  838|     12|                           _ba_remove, _ba_find);
  839|     12|    c->find_next = _ba_find_next;
  840|     12|    c->get_subset = _ba_get_subset;
  841|     12|    c->get_iterator = _ba_iterator_get;
  842|     12|    c->for_each = _ba_for_each;
  843|     12|    c->clear = _ba_clear;
  844|     12|    c->options = _ba_options;
  845|     12|    c->duplicate = _ba_duplicate;
  846|     12|    c->get_at = netsnmp_binary_array_get_at;
  847|     12|    c->remove_at = netsnmp_binary_array_remove_at;
  848|     12|    c->insert_before = _ba_insert_before;
  849|       |
  850|     12|    return c;
  851|     12|}
netsnmp_container_get_binary_array_factory:
  855|      2|{
  856|      2|    static netsnmp_factory f = { "binary_array",
  857|      2|                                 netsnmp_container_get_binary_array };
  858|       |    
  859|      2|    return &f;
  860|      2|}
netsnmp_container_binary_array_init:
  864|      2|{
  865|      2|    netsnmp_container_register("binary_array",
  866|      2|                               netsnmp_container_get_binary_array_factory());
  867|      2|}
container_binary_array.c:_ba_is_sorted:
  336|     24|{
  337|       |    /*
  338|       |     * The code below has been commented out because it negatively affects
  339|       |     * performance.
  340|       |     */
  341|       |#if 0
  342|       |    const binary_array_table *t = c->container_data;
  343|       |    int i;
  344|       |
  345|       |    for (i = 0; i + 1 < t->count; ++i)
  346|       |        if (c->compare(t->data[i], t->data[i + 1]) > 0)
  347|       |            return 0;
  348|       |#endif
  349|       |
  350|     24|    return 1;
  351|     24|}
container_binary_array.c:binary_search:
  125|     80|{
  126|     80|    binary_array_table *t = (binary_array_table*)c->container_data;
  127|     80|    size_t             len = t->count;
  128|     80|    size_t             half;
  129|     80|    size_t             first = 0;
  130|     80|    size_t             middle = 0; /* init not needed; keeps compiler happy */
  131|     80|    int                result = 0; /* init not needed; keeps compiler happy */
  132|       |
  133|     80|    if (!len) {
  ------------------
  |  Branch (133:9): [True: 0, False: 80]
  ------------------
  134|      0|        if (NULL != next)
  ------------------
  |  Branch (134:13): [True: 0, False: 0]
  ------------------
  135|      0|            *next = 0;
  136|      0|        return -1;
  137|      0|    }
  138|       |
  139|     80|    if (c->flags & CONTAINER_KEY_UNSORTED) {
  ------------------
  |  |  371|     80|#define CONTAINER_KEY_UNSORTED                     0x00000002
  ------------------
  |  Branch (139:9): [True: 0, False: 80]
  ------------------
  140|      0|        if (!exact) {
  ------------------
  |  Branch (140:13): [True: 0, False: 0]
  ------------------
  141|      0|            snmp_log(LOG_ERR, "non-exact search on unsorted container %s?!?\n",
  142|      0|                     c->container_name);
  143|      0|            return -1;
  144|      0|        }
  145|      0|        return linear_search(val, c);
  146|      0|    }
  147|       |
  148|     80|    if (t->dirty)
  ------------------
  |  Branch (148:9): [True: 0, False: 80]
  ------------------
  149|      0|        Sort_Array(c);
  150|       |
  151|    314|    while (len > 0) {
  ------------------
  |  Branch (151:12): [True: 258, False: 56]
  ------------------
  152|    258|        half = len >> 1;
  153|    258|        middle = first + half;
  154|    258|        if ((result = c->compare(t->data[middle], val)) < 0) {
  ------------------
  |  Branch (154:13): [True: 86, False: 172]
  ------------------
  155|     86|            first = middle + 1;
  156|     86|            len = len - half - 1;
  157|    172|        } else if (result == 0) {
  ------------------
  |  Branch (157:20): [True: 24, False: 148]
  ------------------
  158|     24|            first = middle;
  159|     24|            break;
  160|    148|        } else {
  161|    148|            len = half;
  162|    148|        }
  163|    258|    }
  164|       |
  165|     80|    if (first >= t->count) {
  ------------------
  |  Branch (165:9): [True: 8, False: 72]
  ------------------
  166|      8|        if (exact && NULL != next)
  ------------------
  |  Branch (166:13): [True: 8, False: 0]
  |  Branch (166:22): [True: 4, False: 4]
  ------------------
  167|      4|            *next = t->count;
  168|      8|        return -1;
  169|      8|    }
  170|       |
  171|     72|    if (first != middle) {
  ------------------
  |  Branch (171:9): [True: 40, False: 32]
  ------------------
  172|       |        /* last compare wasn't against first, so get actual result */
  173|     40|        result = c->compare(t->data[first], val);
  174|     40|    }
  175|       |
  176|     72|    if(result == 0) {
  ------------------
  |  Branch (176:8): [True: 24, False: 48]
  ------------------
  177|     24|        if (exact && NULL != next)
  ------------------
  |  Branch (177:13): [True: 24, False: 0]
  |  Branch (177:22): [True: 0, False: 24]
  ------------------
  178|      0|            *next = first+1;
  179|     24|        else if (!exact && ++first == t->count) {
  ------------------
  |  Branch (179:18): [True: 0, False: 24]
  |  Branch (179:28): [True: 0, False: 0]
  ------------------
  180|      0|            if (NULL != next)
  ------------------
  |  Branch (180:17): [True: 0, False: 0]
  ------------------
  181|      0|                *next = first;
  182|      0|            first = -1;
  183|      0|        }
  184|     48|    } else if(exact) {
  ------------------
  |  Branch (184:15): [True: 48, False: 0]
  ------------------
  185|     48|        if (NULL != next) {
  ------------------
  |  Branch (185:13): [True: 18, False: 30]
  ------------------
  186|     18|            if (result > 0)
  ------------------
  |  Branch (186:17): [True: 18, False: 0]
  ------------------
  187|     18|                *next = first;
  188|      0|            else
  189|      0|                *next = t->count;
  190|     18|        }
  191|     48|        first = -1;
  192|     48|    }
  193|       |
  194|     72|    return first;
  195|     80|}
container_binary_array.c:netsnmp_binary_array_initialize:
  199|     12|{
  200|     12|    binary_array_table *t;
  201|       |
  202|     12|    t = SNMP_MALLOC_TYPEDEF(binary_array_table);
  ------------------
  |  |   73|     12|#define SNMP_MALLOC_TYPEDEF(td)  (td *) calloc(1, sizeof(td))
  ------------------
  203|     12|    if (t == NULL)
  ------------------
  |  Branch (203:9): [True: 0, False: 12]
  ------------------
  204|      0|        return NULL;
  205|       |
  206|     12|    t->max_size = 0;
  207|     12|    t->count = 0;
  208|     12|    t->dirty = 0;
  209|     12|    t->data = NULL;
  210|       |
  211|     12|    return t;
  212|     12|}
container_binary_array.c:_ba_size:
  720|      2|{
  721|      2|    return netsnmp_binary_array_count(container);
  722|      2|}
container_binary_array.c:netsnmp_binary_array_count:
  257|      2|{
  258|      2|    binary_array_table *t = (binary_array_table*)c->container_data;
  259|       |    /*
  260|       |     * return count
  261|       |     */
  262|      2|    return t ? t->count : 0;
  ------------------
  |  Branch (262:12): [True: 2, False: 0]
  ------------------
  263|      2|}
container_binary_array.c:_ba_insert:
  694|     24|{
  695|     24|    return netsnmp_binary_array_insert(container, data);
  696|     24|}
container_binary_array.c:netsnmp_binary_array_insert:
  533|     24|{
  534|     24|    binary_array_table *t = (binary_array_table*)c->container_data;
  535|     24|    const int duplicates_allowed = c->flags & CONTAINER_KEY_ALLOW_DUPLICATES;
  ------------------
  |  |  370|     24|#define CONTAINER_KEY_ALLOW_DUPLICATES             0x00000001
  ------------------
  536|     24|    const int sorted = !(c->flags & CONTAINER_KEY_UNSORTED);
  ------------------
  |  |  371|     24|#define CONTAINER_KEY_UNSORTED                     0x00000002
  ------------------
  537|     24|    int             i = -2;
  538|     24|    size_t          next, pos;
  539|     24|    void           *entry = NETSNMP_REMOVE_CONST(void *, const_entry);
  ------------------
  |  |   91|     24|    (__extension__ ({ const t tmp = (e); (t)(size_t)tmp; }))
  ------------------
  540|       |
  541|     24|    if (NULL == entry)
  ------------------
  |  Branch (541:9): [True: 0, False: 24]
  ------------------
  542|      0|        return -1;
  543|       |
  544|       |    /*
  545|       |     * check key if we have at least 1 item and duplicates aren't allowed
  546|       |     */
  547|     24|    if (!duplicates_allowed && t->count) {
  ------------------
  |  Branch (547:9): [True: 24, False: 0]
  |  Branch (547:32): [True: 22, False: 2]
  ------------------
  548|     22|        i = binary_search(entry, c, 1, &next);
  549|     22|        if (i >= 0) {
  ------------------
  |  Branch (549:13): [True: 0, False: 22]
  ------------------
  550|      0|            DEBUGMSGTL(("container","not inserting duplicate key\n"));
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
  551|      0|            return -1;
  552|      0|        }
  553|     22|    }
  554|       | 
  555|       |    /*
  556|       |     * if unsorted, just add at the end
  557|       |     */
  558|     24|    if (!sorted) {
  ------------------
  |  Branch (558:9): [True: 0, False: 24]
  ------------------
  559|      0|        pos = t->count;
  560|     24|    } else {
  561|       |        /** if we haven't searched for key yet, do it now */
  562|     24|        if (-2 == i) {
  ------------------
  |  Branch (562:13): [True: 2, False: 22]
  ------------------
  563|      2|            if (0 == t->count) {
  ------------------
  |  Branch (563:17): [True: 2, False: 0]
  ------------------
  564|      2|                next = 0;
  565|      2|                i = -1;
  566|      2|            } else {
  567|      0|                i = binary_search(entry, c, 1, &next);
  568|      0|            }
  569|      2|        }
  570|       |
  571|     24|        pos = next;
  572|       |        /* if key found, advance past any duplicates */
  573|     24|        if (duplicates_allowed && i >= 0)
  ------------------
  |  Branch (573:13): [True: 0, False: 24]
  |  Branch (573:35): [True: 0, False: 0]
  ------------------
  574|      0|            while (pos < t->count && c->compare(t->data[pos], entry) == 0)
  ------------------
  |  Branch (574:20): [True: 0, False: 0]
  |  Branch (574:38): [True: 0, False: 0]
  ------------------
  575|      0|                ++pos;
  576|     24|    }
  577|       |
  578|     24|    return netsnmp_binary_array_insert_before(c, pos, entry, !sorted);
  579|     24|}
container_binary_array.c:netsnmp_binary_array_insert_before:
  487|     24|{
  488|     24|    binary_array_table *t = (binary_array_table*)c->container_data;
  489|       |
  490|     24|    if (NULL == entry)
  ------------------
  |  Branch (490:9): [True: 0, False: 24]
  ------------------
  491|      0|        return -1;
  492|       |
  493|     24|    if (index > t->count) {
  ------------------
  |  Branch (493:9): [True: 0, False: 24]
  ------------------
  494|      0|        DEBUGMSGTL(("container:insert:before", "index out of range\n"));
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
  495|      0|        return -1;
  496|      0|    }
  497|       |
  498|       |     /*
  499|       |      * check if we need to resize the array
  500|       |      */
  501|     24|    if (_ba_resize_check(t) < 0)
  ------------------
  |  Branch (501:9): [True: 0, False: 24]
  ------------------
  502|      0|        return -1;
  503|       |
  504|     24|    netsnmp_assert(t->count < t->max_size);
  ------------------
  |  |   47|     24|#      define netsnmp_assert(x)  do { \
  |  |   48|     24|              if ( x ) \
  |  |  ------------------
  |  |  |  Branch (48:20): [True: 24, False: 0]
  |  |  ------------------
  |  |   49|     24|                 ; \
  |  |   50|     24|              else \
  |  |   51|     24|                 snmp_log(LOG_ERR, \
  |  |   52|      0|                          "netsnmp_assert %s failed %s:%d" NETSNMP_FUNC_FMT, \
  |  |  ------------------
  |  |  |  |   40|      0|#          define NETSNMP_FUNC_FMT " %s()\n"
  |  |  ------------------
  |  |   53|      0|                          __STRING(x),__FILE__,__LINE__, \
  |  |   54|      0|                          NETSNMP_FUNC_PARAM); \
  |  |  ------------------
  |  |  |  |   41|      0|#          define NETSNMP_FUNC_PARAM NETSNMP_FUNCTION
  |  |  |  |  ------------------
  |  |  |  |  |  | 1727|      0|#define NETSNMP_FUNCTION __func__
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   55|     24|           }while(0)
  |  |  ------------------
  |  |  |  Branch (55:19): [Folded, False: 24]
  |  |  ------------------
  ------------------
  505|       |
  506|       |    /*
  507|       |     * shift array
  508|       |     */
  509|     24|    memmove(&t->data[index+1], &t->data[index],
  510|     24|            sizeof(void*) * (t->count - index));
  511|       |
  512|       |    /*
  513|       |     * Insert the new entry into the data array
  514|       |     */
  515|     24|    t->data[index] = NETSNMP_REMOVE_CONST(void *, entry);
  ------------------
  |  |   91|     24|    (__extension__ ({ const t tmp = (e); (t)(size_t)tmp; }))
  ------------------
  516|     24|    ++t->count;
  517|       |
  518|     24|    netsnmp_assert(index < t->count);
  ------------------
  |  |   47|     24|#      define netsnmp_assert(x)  do { \
  |  |   48|     24|              if ( x ) \
  |  |  ------------------
  |  |  |  Branch (48:20): [True: 24, False: 0]
  |  |  ------------------
  |  |   49|     24|                 ; \
  |  |   50|     24|              else \
  |  |   51|     24|                 snmp_log(LOG_ERR, \
  |  |   52|      0|                          "netsnmp_assert %s failed %s:%d" NETSNMP_FUNC_FMT, \
  |  |  ------------------
  |  |  |  |   40|      0|#          define NETSNMP_FUNC_FMT " %s()\n"
  |  |  ------------------
  |  |   53|      0|                          __STRING(x),__FILE__,__LINE__, \
  |  |   54|      0|                          NETSNMP_FUNC_PARAM); \
  |  |  ------------------
  |  |  |  |   41|      0|#          define NETSNMP_FUNC_PARAM NETSNMP_FUNCTION
  |  |  |  |  ------------------
  |  |  |  |  |  | 1727|      0|#define NETSNMP_FUNCTION __func__
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   55|     24|           }while(0)
  |  |  ------------------
  |  |  |  Branch (55:19): [Folded, False: 24]
  |  |  ------------------
  ------------------
  519|     24|    netsnmp_assert(t->count <= t->max_size);
  ------------------
  |  |   47|     24|#      define netsnmp_assert(x)  do { \
  |  |   48|     24|              if ( x ) \
  |  |  ------------------
  |  |  |  Branch (48:20): [True: 24, False: 0]
  |  |  ------------------
  |  |   49|     24|                 ; \
  |  |   50|     24|              else \
  |  |   51|     24|                 snmp_log(LOG_ERR, \
  |  |   52|      0|                          "netsnmp_assert %s failed %s:%d" NETSNMP_FUNC_FMT, \
  |  |  ------------------
  |  |  |  |   40|      0|#          define NETSNMP_FUNC_FMT " %s()\n"
  |  |  ------------------
  |  |   53|      0|                          __STRING(x),__FILE__,__LINE__, \
  |  |   54|      0|                          NETSNMP_FUNC_PARAM); \
  |  |  ------------------
  |  |  |  |   41|      0|#          define NETSNMP_FUNC_PARAM NETSNMP_FUNCTION
  |  |  |  |  ------------------
  |  |  |  |  |  | 1727|      0|#define NETSNMP_FUNCTION __func__
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   55|     24|           }while(0)
  |  |  ------------------
  |  |  |  Branch (55:19): [Folded, False: 24]
  |  |  ------------------
  ------------------
  520|       |
  521|     24|    if (dirty)
  ------------------
  |  Branch (521:9): [True: 0, False: 24]
  ------------------
  522|      0|        t->dirty = 1;
  523|       |
  524|     24|    netsnmp_assert(t->dirty || _ba_is_sorted(c));
  ------------------
  |  |   47|     24|#      define netsnmp_assert(x)  do { \
  |  |   48|     72|              if ( x ) \
  |  |  ------------------
  |  |  |  Branch (48:20): [True: 0, False: 24]
  |  |  |  Branch (48:20): [True: 24, False: 0]
  |  |  ------------------
  |  |   49|     24|                 ; \
  |  |   50|     24|              else \
  |  |   51|     24|                 snmp_log(LOG_ERR, \
  |  |   52|      0|                          "netsnmp_assert %s failed %s:%d" NETSNMP_FUNC_FMT, \
  |  |  ------------------
  |  |  |  |   40|      0|#          define NETSNMP_FUNC_FMT " %s()\n"
  |  |  ------------------
  |  |   53|      0|                          __STRING(x),__FILE__,__LINE__, \
  |  |   54|      0|                          NETSNMP_FUNC_PARAM); \
  |  |  ------------------
  |  |  |  |   41|      0|#          define NETSNMP_FUNC_PARAM NETSNMP_FUNCTION
  |  |  |  |  ------------------
  |  |  |  |  |  | 1727|      0|#define NETSNMP_FUNCTION __func__
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   55|     24|           }while(0)
  |  |  ------------------
  |  |  |  Branch (55:19): [Folded, False: 24]
  |  |  ------------------
  ------------------
  525|       |
  526|     24|    ++c->sync;
  527|       |
  528|     24|    return 0;
  529|     24|}
container_binary_array.c:_ba_resize_check:
  458|     24|{
  459|     24|    size_t new_max;
  460|     24|    void ** new_data;
  461|     24|    if (t->max_size > t->count)
  ------------------
  |  Branch (461:9): [True: 20, False: 4]
  ------------------
  462|     20|        return 0; /* resize not needed */
  463|       |
  464|       |    /*
  465|       |     * Table is full, so extend it to double the size, or use 10 elements
  466|       |     * if it is empty.
  467|       |     */
  468|      4|    new_max = t->max_size > 0 ? 2 * t->max_size : 10;
  ------------------
  |  Branch (468:15): [True: 2, False: 2]
  ------------------
  469|      4|    new_data = (void**) realloc(t->data, new_max * sizeof(void*));
  470|      4|    if (new_data == NULL) {
  ------------------
  |  Branch (470:9): [True: 0, False: 4]
  ------------------
  471|      0|        snmp_log(LOG_ERR, "malloc failed in _ba_resize_check\n");
  472|      0|        return -1; /* error */
  473|      0|    }
  474|       |
  475|      4|    memset(new_data + t->max_size, 0x0,
  476|      4|           (new_max - t->max_size) * sizeof(void*));
  477|       |
  478|      4|    t->data = new_data;
  479|      4|    t->max_size = new_max;
  480|       |
  481|      4|    return 1; /* resized */
  482|      4|}
container_binary_array.c:_ba_find:
  682|     60|{
  683|     60|    return netsnmp_binary_array_get(container, data, 1);
  684|     60|}
container_binary_array.c:netsnmp_binary_array_get:
  267|     60|{
  268|     60|    binary_array_table *t = (binary_array_table*)c->container_data;
  269|     60|    int             index = 0;
  270|       |
  271|       |    /*
  272|       |     * if there is no data, return NULL;
  273|       |     */
  274|     60|    if (!t->count)
  ------------------
  |  Branch (274:9): [True: 2, False: 58]
  ------------------
  275|      2|        return NULL;
  276|       |
  277|       |    /*
  278|       |     * if the table is dirty, sort it.
  279|       |     */
  280|     58|    if (t->dirty)
  ------------------
  |  Branch (280:9): [True: 0, False: 58]
  ------------------
  281|      0|        Sort_Array(c);
  282|       |
  283|       |    /*
  284|       |     * if there is a key, search. Otherwise default is 0;
  285|       |     */
  286|     58|    if (key) {
  ------------------
  |  Branch (286:9): [True: 58, False: 0]
  ------------------
  287|     58|        if ((index = binary_search(key, c, exact, NULL)) == -1)
  ------------------
  |  Branch (287:13): [True: 34, False: 24]
  ------------------
  288|     34|            return NULL;
  289|     24|        if (!exact &&
  ------------------
  |  Branch (289:13): [True: 0, False: 24]
  ------------------
  290|      0|            c->flags & CONTAINER_KEY_ALLOW_DUPLICATES) {
  ------------------
  |  |  370|      0|#define CONTAINER_KEY_ALLOW_DUPLICATES             0x00000001
  ------------------
  |  Branch (290:13): [True: 0, False: 0]
  ------------------
  291|      0|            int result;
  292|       |
  293|       |            /*
  294|       |             * If duplicates are allowed, we have to be extra
  295|       |             * sure that we didn't just increment to a duplicate,
  296|       |             * thus causing a getnext loop.
  297|       |             */
  298|      0|            result = c->compare(t->data[index], key);
  299|      0|            while (result == 0) {
  ------------------
  |  Branch (299:20): [True: 0, False: 0]
  ------------------
  300|      0|		DEBUGMSGTL(("container","skipping duplicate key in %s\n",
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
  301|      0|					    c->container_name));
  302|      0|                if (++index == t->count)
  ------------------
  |  Branch (302:21): [True: 0, False: 0]
  ------------------
  303|      0|                   return NULL;
  304|      0|                result = c->compare(t->data[index], key);
  305|      0|            }
  306|      0|        }
  307|     24|    }
  308|       |
  309|     24|    return t->data[index];
  310|     58|}
container_binary_array.c:_ba_options:
  762|      8|{
  763|      8|    return netsnmp_binary_array_options_set(c, set, flags);
  764|      8|}
container_binary_array.c:_ba_iterator_get:
 1026|      2|{
 1027|      2|    binary_array_iterator* it;
 1028|       |
 1029|      2|    if(NULL == c)
  ------------------
  |  Branch (1029:8): [True: 0, False: 2]
  ------------------
 1030|      0|        return NULL;
 1031|       |
 1032|      2|    it = SNMP_MALLOC_TYPEDEF(binary_array_iterator);
  ------------------
  |  |   73|      2|#define SNMP_MALLOC_TYPEDEF(td)  (td *) calloc(1, sizeof(td))
  ------------------
 1033|      2|    if(NULL == it)
  ------------------
  |  Branch (1033:8): [True: 0, False: 2]
  ------------------
 1034|      0|        return NULL;
 1035|       |
 1036|      2|    it->base.container = c;
 1037|       |    
 1038|      2|    it->base.first = _ba_iterator_first;
 1039|      2|    it->base.next = _ba_iterator_next;
 1040|      2|    it->base.curr = _ba_iterator_curr;
 1041|      2|    it->base.last = _ba_iterator_last;
 1042|      2|    it->base.remove = _ba_iterator_remove;
 1043|      2|    it->base.reset = _ba_iterator_reset;
 1044|      2|    it->base.release = _ba_iterator_release;
 1045|       |
 1046|      2|    (void)_ba_iterator_reset(&it->base);
 1047|       |
 1048|      2|    return &it->base;
 1049|      2|}
container_binary_array.c:_ba_iterator_first:
  932|      2|{
  933|      2|    binary_array_iterator *it = (void *)nit;
  934|       |
  935|      2|    return _ba_iterator_position(it, 0);
  936|      2|}
container_binary_array.c:_ba_iterator_position:
  895|      2|{
  896|      2|    binary_array_table *t = _ba_it2cont(it);
  897|      2|    if (NULL == t)
  ------------------
  |  Branch (897:9): [True: 0, False: 2]
  ------------------
  898|      0|        return t; /* msg already logged */
  899|       |
  900|      2|    if(it->base.container->sync != it->base.sync) {
  ------------------
  |  Branch (900:8): [True: 0, False: 2]
  ------------------
  901|      0|        DEBUGMSGTL(("container:iterator", "out of sync\n"));
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
  902|      0|        return NULL;
  903|      0|    }
  904|       |    
  905|      2|    if(0 == t->count) {
  ------------------
  |  Branch (905:8): [True: 2, False: 0]
  ------------------
  906|      2|        DEBUGMSGTL(("container:iterator", "empty\n"));
  ------------------
  |  |   66|      2|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      2|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 2]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 2]
  |  |  ------------------
  ------------------
  907|      2|        return NULL;
  908|      2|    }
  909|      0|    else if(pos >= t->count) {
  ------------------
  |  Branch (909:13): [True: 0, False: 0]
  ------------------
  910|      0|        DEBUGMSGTL(("container:iterator", "end of container\n"));
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
  911|      0|        return NULL;
  912|      0|    }
  913|       |
  914|      0|    return t->data[ pos ];
  915|      2|}
container_binary_array.c:_ba_it2cont:
  876|      4|{
  877|      4|    if(NULL == it) {
  ------------------
  |  Branch (877:8): [True: 0, False: 4]
  ------------------
  878|      0|        netsnmp_assert(NULL != it);
  ------------------
  |  |   47|      0|#      define netsnmp_assert(x)  do { \
  |  |   48|      0|              if ( x ) \
  |  |  ------------------
  |  |  |  Branch (48:20): [True: 0, False: 0]
  |  |  ------------------
  |  |   49|      0|                 ; \
  |  |   50|      0|              else \
  |  |   51|      0|                 snmp_log(LOG_ERR, \
  |  |   52|      0|                          "netsnmp_assert %s failed %s:%d" NETSNMP_FUNC_FMT, \
  |  |  ------------------
  |  |  |  |   40|      0|#          define NETSNMP_FUNC_FMT " %s()\n"
  |  |  ------------------
  |  |   53|      0|                          __STRING(x),__FILE__,__LINE__, \
  |  |   54|      0|                          NETSNMP_FUNC_PARAM); \
  |  |  ------------------
  |  |  |  |   41|      0|#          define NETSNMP_FUNC_PARAM NETSNMP_FUNCTION
  |  |  |  |  ------------------
  |  |  |  |  |  | 1727|      0|#define NETSNMP_FUNCTION __func__
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   55|      0|           }while(0)
  |  |  ------------------
  |  |  |  Branch (55:19): [Folded, False: 0]
  |  |  ------------------
  ------------------
  879|      0|        return NULL;
  880|      0|    }
  881|      4|    if(NULL == it->base.container) {
  ------------------
  |  Branch (881:8): [True: 0, False: 4]
  ------------------
  882|      0|        netsnmp_assert(NULL != it->base.container);
  ------------------
  |  |   47|      0|#      define netsnmp_assert(x)  do { \
  |  |   48|      0|              if ( x ) \
  |  |  ------------------
  |  |  |  Branch (48:20): [True: 0, False: 0]
  |  |  ------------------
  |  |   49|      0|                 ; \
  |  |   50|      0|              else \
  |  |   51|      0|                 snmp_log(LOG_ERR, \
  |  |   52|      0|                          "netsnmp_assert %s failed %s:%d" NETSNMP_FUNC_FMT, \
  |  |  ------------------
  |  |  |  |   40|      0|#          define NETSNMP_FUNC_FMT " %s()\n"
  |  |  ------------------
  |  |   53|      0|                          __STRING(x),__FILE__,__LINE__, \
  |  |   54|      0|                          NETSNMP_FUNC_PARAM); \
  |  |  ------------------
  |  |  |  |   41|      0|#          define NETSNMP_FUNC_PARAM NETSNMP_FUNCTION
  |  |  |  |  ------------------
  |  |  |  |  |  | 1727|      0|#define NETSNMP_FUNCTION __func__
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   55|      0|           }while(0)
  |  |  ------------------
  |  |  |  Branch (55:19): [Folded, False: 0]
  |  |  ------------------
  ------------------
  883|      0|        return NULL;
  884|      0|    }
  885|      4|    if(NULL == it->base.container->container_data) {
  ------------------
  |  Branch (885:8): [True: 0, False: 4]
  ------------------
  886|      0|        netsnmp_assert(NULL != it->base.container->container_data);
  ------------------
  |  |   47|      0|#      define netsnmp_assert(x)  do { \
  |  |   48|      0|              if ( x ) \
  |  |  ------------------
  |  |  |  Branch (48:20): [True: 0, False: 0]
  |  |  ------------------
  |  |   49|      0|                 ; \
  |  |   50|      0|              else \
  |  |   51|      0|                 snmp_log(LOG_ERR, \
  |  |   52|      0|                          "netsnmp_assert %s failed %s:%d" NETSNMP_FUNC_FMT, \
  |  |  ------------------
  |  |  |  |   40|      0|#          define NETSNMP_FUNC_FMT " %s()\n"
  |  |  ------------------
  |  |   53|      0|                          __STRING(x),__FILE__,__LINE__, \
  |  |   54|      0|                          NETSNMP_FUNC_PARAM); \
  |  |  ------------------
  |  |  |  |   41|      0|#          define NETSNMP_FUNC_PARAM NETSNMP_FUNCTION
  |  |  |  |  ------------------
  |  |  |  |  |  | 1727|      0|#define NETSNMP_FUNCTION __func__
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   55|      0|           }while(0)
  |  |  ------------------
  |  |  |  Branch (55:19): [Folded, False: 0]
  |  |  ------------------
  ------------------
  887|      0|        return NULL;
  888|      0|    }
  889|       |
  890|      4|    return (binary_array_table*)(it->base.container->container_data);
  891|      4|}
container_binary_array.c:_ba_iterator_reset:
  994|      2|{
  995|      2|    binary_array_iterator *it = (void *)nit;
  996|      2|    binary_array_table* t = _ba_it2cont(it);
  997|      2|    if(NULL == t) {
  ------------------
  |  Branch (997:8): [True: 0, False: 2]
  ------------------
  998|      0|        netsnmp_assert(NULL != t);
  ------------------
  |  |   47|      0|#      define netsnmp_assert(x)  do { \
  |  |   48|      0|              if ( x ) \
  |  |  ------------------
  |  |  |  Branch (48:20): [True: 0, False: 0]
  |  |  ------------------
  |  |   49|      0|                 ; \
  |  |   50|      0|              else \
  |  |   51|      0|                 snmp_log(LOG_ERR, \
  |  |   52|      0|                          "netsnmp_assert %s failed %s:%d" NETSNMP_FUNC_FMT, \
  |  |  ------------------
  |  |  |  |   40|      0|#          define NETSNMP_FUNC_FMT " %s()\n"
  |  |  ------------------
  |  |   53|      0|                          __STRING(x),__FILE__,__LINE__, \
  |  |   54|      0|                          NETSNMP_FUNC_PARAM); \
  |  |  ------------------
  |  |  |  |   41|      0|#          define NETSNMP_FUNC_PARAM NETSNMP_FUNCTION
  |  |  |  |  ------------------
  |  |  |  |  |  | 1727|      0|#define NETSNMP_FUNCTION __func__
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   55|      0|           }while(0)
  |  |  ------------------
  |  |  |  Branch (55:19): [Folded, False: 0]
  |  |  ------------------
  ------------------
  999|      0|        return -1;
 1000|      0|    }
 1001|       |
 1002|      2|    if (t->dirty)
  ------------------
  |  Branch (1002:9): [True: 0, False: 2]
  ------------------
 1003|      0|        Sort_Array(it->base.container);
 1004|       |
 1005|       |    /*
 1006|       |     * save sync count, to make sure container doesn't change while
 1007|       |     * iterator is in use.
 1008|       |     */
 1009|      2|    it->base.sync = it->base.container->sync;
 1010|       |
 1011|      2|    it->pos = 0;
 1012|       |
 1013|      2|    return 0;
 1014|      2|}
container_binary_array.c:_ba_iterator_release:
 1018|      2|{
 1019|      2|    free(it);
 1020|       |
 1021|      2|    return 0;
 1022|      2|}

netsnmp_container_get_usll:
  393|      2|{
  394|       |    /*
  395|       |     * allocate memory
  396|       |     */
  397|      2|    sl_container *sl = (sl_container *)netsnmp_container_get_ssll();
  398|      2|    if (NULL==sl)
  ------------------
  |  Branch (398:9): [True: 0, False: 2]
  ------------------
  399|      0|        return NULL; /* msg already logged */
  400|       |
  401|      2|    sl->unsorted = 1;
  402|       |
  403|      2|    return (netsnmp_container*)sl;
  404|      2|}
netsnmp_container_get_singly_linked_list:
  408|      2|{
  409|      2|    sl_container *sl = (sl_container *)netsnmp_container_get_usll();
  410|      2|    if (NULL == sl)
  ------------------
  |  Branch (410:9): [True: 0, False: 2]
  ------------------
  411|      0|        return NULL; /* error already logged */
  412|       |
  413|      2|    sl->fifo = fifo;
  414|       |
  415|      2|    return (netsnmp_container *)sl;
  416|      2|}
netsnmp_container_get_fifo:
  420|      2|{
  421|      2|    return netsnmp_container_get_singly_linked_list(1);
  422|      2|}
netsnmp_container_ssll_init:
  426|      2|{
  427|      2|    static netsnmp_factory ssll = {
  428|      2|        "sorted_singly_linked_list",
  429|      2|        netsnmp_container_get_ssll
  430|      2|    };
  431|      2|    static netsnmp_factory usll = {
  432|      2|        "unsorted_singly_linked_list-lifo",
  433|      2|        netsnmp_container_get_usll
  434|      2|    };
  435|      2|    static netsnmp_factory fifo = {
  436|      2|        "unsorted_singly_linked_list-fifo",
  437|      2|        netsnmp_container_get_fifo
  438|      2|    };
  439|       |
  440|      2|    netsnmp_container_register("sorted_singly_linked_list", &ssll);
  441|      2|    netsnmp_container_register("unsorted_singly_linked_list", &usll);
  442|      2|    netsnmp_container_register("lifo", &usll);
  443|      2|    netsnmp_container_register("fifo", &fifo);
  444|      2|}
container_list_ssll.c:netsnmp_container_get_ssll:
  368|      2|{
  369|       |    /*
  370|       |     * allocate memory
  371|       |     */
  372|      2|    sl_container *sl = SNMP_MALLOC_TYPEDEF(sl_container);
  ------------------
  |  |   73|      2|#define SNMP_MALLOC_TYPEDEF(td)  (td *) calloc(1, sizeof(td))
  ------------------
  373|      2|    if (NULL==sl) {
  ------------------
  |  Branch (373:9): [True: 0, False: 2]
  ------------------
  374|      0|        snmp_log(LOG_ERR, "couldn't allocate memory\n");
  375|      0|        return NULL;
  376|      0|    }
  377|       |
  378|      2|    netsnmp_init_container((netsnmp_container *)sl, NULL, _ssll_free,
  379|      2|                           _ssll_size, NULL, _ssll_insert, _ssll_remove,
  380|      2|                           _ssll_find);
  381|      2|    sl->c.find_next = _ssll_find_next;
  382|      2|    sl->c.get_subset = NULL;
  383|      2|    sl->c.get_iterator =_ssll_iterator_get;
  384|      2|    sl->c.for_each = _ssll_for_each;
  385|      2|    sl->c.clear = _ssll_clear;
  386|      2|    sl->c.duplicate = _ssll_duplicate;
  387|       |
  388|      2|    return &sl->c;
  389|      2|}
container_list_ssll.c:_ssll_free:
  110|      2|{
  111|      2|    if(c) {
  ------------------
  |  Branch (111:8): [True: 2, False: 0]
  ------------------
  112|      2|        sl_container *sl = (sl_container *)c;
  113|      2|        sl_node *curr, *next;
  114|       |
  115|      2|        for (curr = sl->head; curr; curr = next) {
  ------------------
  |  Branch (115:31): [True: 0, False: 2]
  ------------------
  116|      0|            next = curr->next;
  117|      0|            free(curr);
  118|      0|        }
  119|      2|        free(c);
  120|      2|    }
  121|      2|    return 0;
  122|      2|}
container_list_ssll.c:_ssll_clear:
  294|      2|{
  295|      2|    sl_container *sl = (sl_container*)c;
  296|      2|    sl_node  *curr, *next;
  297|       |    
  298|      2|    if(NULL == c)
  ------------------
  |  Branch (298:8): [True: 0, False: 2]
  ------------------
  299|      0|        return;
  300|       |    
  301|      2|    for(curr = sl->head; curr; curr = next) {
  ------------------
  |  Branch (301:26): [True: 0, False: 2]
  ------------------
  302|       |
  303|      0|        next = curr->next;
  304|       |
  305|      0|        if( NULL != f ) {
  ------------------
  |  Branch (305:13): [True: 0, False: 0]
  ------------------
  306|      0|            curr->next = NULL;
  307|      0|            (*f) ((void *)curr->data, context);
  308|      0|        }
  309|       |
  310|       |        /*
  311|       |         * free our node structure, but not the data
  312|       |         */
  313|      0|        free(curr);
  314|      0|    }
  315|       |    sl->head = NULL;
  316|      2|    sl->count = 0;
  317|      2|    ++c->sync;
  318|      2|}

netsnmp_container_get_null_factory:
  173|      2|{
  174|      2|    static netsnmp_factory f = { "null",
  175|      2|                                 netsnmp_container_get_null};
  176|       |    
  177|      2|    DEBUGMSGTL(("container:null:get_null_factory","in\n"));
  ------------------
  |  |   66|      2|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      2|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 2]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 2]
  |  |  ------------------
  ------------------
  178|      2|    return &f;
  179|      2|}
netsnmp_container_null_init:
  183|      2|{
  184|      2|    netsnmp_container_register("null",
  185|      2|                               netsnmp_container_get_null_factory());
  186|      2|}

netsnmp_free_all_list_data:
   49|      2|{
   50|      2|    netsnmp_data_list *tmpptr;
   51|      2|    for (; head;) {
  ------------------
  |  Branch (51:12): [True: 0, False: 2]
  ------------------
   52|      0|        netsnmp_free_list_data(head);
   53|      0|        tmpptr = head;
   54|      0|        head = head->next;
   55|       |        SNMP_FREE(tmpptr);
  ------------------
  |  |   62|      0|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 0, False: 0]
  |  |  |  Branch (62:66): [Folded, False: 0]
  |  |  ------------------
  ------------------
   56|      0|    }
   57|      2|}

netsnmp_ds_set_boolean:
  201|     10|{
  202|     10|    if (storeid < 0 || storeid >= NETSNMP_DS_MAX_IDS || 
  ------------------
  |  |   38|     20|#define NETSNMP_DS_MAX_IDS 3
  ------------------
  |  Branch (202:9): [True: 0, False: 10]
  |  Branch (202:24): [True: 0, False: 10]
  ------------------
  203|     10|	which   < 0 || which   >= NETSNMP_DS_MAX_SUBIDS) {
  ------------------
  |  |   39|     10|#define NETSNMP_DS_MAX_SUBIDS 64        /* needs to be a multiple of 8 */
  ------------------
  |  Branch (203:2): [True: 0, False: 10]
  |  Branch (203:17): [True: 0, False: 10]
  ------------------
  204|      0|        return SNMPERR_GENERR;
  ------------------
  |  |  185|      0|#define SNMPERR_GENERR			(-1)
  ------------------
  205|      0|    }
  206|       |
  207|     10|    DEBUGMSGTL(("netsnmp_ds_set_boolean", "Setting %s:%d = %d/%s\n",
  ------------------
  |  |   66|     10|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     10|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 10]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (164:52): [True: 0, False: 0]
  |  |  |  |  |  Branch (164:64): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 10]
  |  |  ------------------
  ------------------
  208|     10|                stores[storeid], which, value, ((value) ? "True" : "False")));
  209|       |
  210|     10|    if (value > 0) {
  ------------------
  |  Branch (210:9): [True: 10, False: 0]
  ------------------
  211|     10|        netsnmp_ds_booleans[storeid][which/8] |= (1 << (which % 8));
  212|     10|    } else {
  213|      0|        netsnmp_ds_booleans[storeid][which/8] &= (0xff7f >> (7 - (which % 8)));
  214|      0|    }
  215|       |
  216|     10|    return SNMPERR_SUCCESS;
  ------------------
  |  |  184|     10|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
  217|     10|}
netsnmp_ds_get_boolean:
  242|  10.7k|{
  243|  10.7k|    if (storeid < 0 || storeid >= NETSNMP_DS_MAX_IDS || 
  ------------------
  |  |   38|  21.4k|#define NETSNMP_DS_MAX_IDS 3
  ------------------
  |  Branch (243:9): [True: 0, False: 10.7k]
  |  Branch (243:24): [True: 0, False: 10.7k]
  ------------------
  244|  10.7k|	which   < 0 || which   >= NETSNMP_DS_MAX_SUBIDS) {
  ------------------
  |  |   39|  10.7k|#define NETSNMP_DS_MAX_SUBIDS 64        /* needs to be a multiple of 8 */
  ------------------
  |  Branch (244:2): [True: 0, False: 10.7k]
  |  Branch (244:17): [True: 0, False: 10.7k]
  ------------------
  245|      0|        return SNMPERR_GENERR;
  ------------------
  |  |  185|      0|#define SNMPERR_GENERR			(-1)
  ------------------
  246|      0|    }
  247|       |
  248|  10.7k|    return (netsnmp_ds_booleans[storeid][which/8] & (1 << (which % 8))) ? 1:0;
  ------------------
  |  Branch (248:12): [True: 104, False: 10.6k]
  ------------------
  249|  10.7k|}
netsnmp_ds_set_int:
  253|      4|{
  254|      4|    if (storeid < 0 || storeid >= NETSNMP_DS_MAX_IDS || 
  ------------------
  |  |   38|      8|#define NETSNMP_DS_MAX_IDS 3
  ------------------
  |  Branch (254:9): [True: 0, False: 4]
  |  Branch (254:24): [True: 0, False: 4]
  ------------------
  255|      4|	which   < 0 || which   >= NETSNMP_DS_MAX_SUBIDS) {
  ------------------
  |  |   39|      4|#define NETSNMP_DS_MAX_SUBIDS 64        /* needs to be a multiple of 8 */
  ------------------
  |  Branch (255:2): [True: 0, False: 4]
  |  Branch (255:17): [True: 0, False: 4]
  ------------------
  256|      0|        return SNMPERR_GENERR;
  ------------------
  |  |  185|      0|#define SNMPERR_GENERR			(-1)
  ------------------
  257|      0|    }
  258|       |
  259|      4|    DEBUGMSGTL(("netsnmp_ds_set_int", "Setting %s:%d = %d\n",
  ------------------
  |  |   66|      4|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      4|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 4]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 4]
  |  |  ------------------
  ------------------
  260|      4|                stores[storeid], which, value));
  261|       |
  262|      4|    netsnmp_ds_integers[storeid][which] = value;
  263|      4|    return SNMPERR_SUCCESS;
  ------------------
  |  |  184|      4|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
  264|      4|}
netsnmp_ds_set_string:
  279|     10|{
  280|     10|    if (storeid < 0 || storeid >= NETSNMP_DS_MAX_IDS || 
  ------------------
  |  |   38|     20|#define NETSNMP_DS_MAX_IDS 3
  ------------------
  |  Branch (280:9): [True: 0, False: 10]
  |  Branch (280:24): [True: 0, False: 10]
  ------------------
  281|     10|	which   < 0 || which   >= NETSNMP_DS_MAX_SUBIDS) {
  ------------------
  |  |   39|     10|#define NETSNMP_DS_MAX_SUBIDS 64        /* needs to be a multiple of 8 */
  ------------------
  |  Branch (281:2): [True: 0, False: 10]
  |  Branch (281:17): [True: 0, False: 10]
  ------------------
  282|      0|        return SNMPERR_GENERR;
  ------------------
  |  |  185|      0|#define SNMPERR_GENERR			(-1)
  ------------------
  283|      0|    }
  284|       |
  285|     10|    DEBUGMSGTL(("netsnmp_ds_set_string", "Setting %s:%d = \"%s\"\n",
  ------------------
  |  |   66|     10|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     10|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 10]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (164:52): [True: 0, False: 0]
  |  |  |  |  |  Branch (164:64): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 10]
  |  |  ------------------
  ------------------
  286|     10|                stores[storeid], which, (value ? value : "(null)")));
  287|       |
  288|       |    /*
  289|       |     * is some silly person is calling us with our own pointer?
  290|       |     */
  291|     10|    if (netsnmp_ds_strings[storeid][which] == value)
  ------------------
  |  Branch (291:9): [True: 2, False: 8]
  ------------------
  292|      2|        return SNMPERR_SUCCESS;
  ------------------
  |  |  184|      2|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
  293|       |
  294|      8|    snmp_res_lock(MT_LIBRARY_ID, MT_LIB_SESSION);
  ------------------
  |  |   79|      8|#define snmp_res_lock(x,y) do {} while (0)
  |  |  ------------------
  |  |  |  Branch (79:41): [Folded, False: 8]
  |  |  ------------------
  ------------------
  295|      8|    if (netsnmp_ds_strings[storeid][which] != NULL) {
  ------------------
  |  Branch (295:9): [True: 0, False: 8]
  ------------------
  296|      0|        free(netsnmp_ds_strings[storeid][which]);
  297|      0|	netsnmp_ds_strings[storeid][which] = NULL;
  298|      0|    }
  299|      8|    snmp_res_unlock(MT_LIBRARY_ID, MT_LIB_SESSION);
  ------------------
  |  |   80|      8|#define snmp_res_unlock(x,y) do {} while (0)
  |  |  ------------------
  |  |  |  Branch (80:43): [Folded, False: 8]
  |  |  ------------------
  ------------------
  300|       |
  301|      8|    if (value) {
  ------------------
  |  Branch (301:9): [True: 8, False: 0]
  ------------------
  302|      8|        netsnmp_ds_strings[storeid][which] = strdup(value);
  303|      8|    } else {
  304|      0|        netsnmp_ds_strings[storeid][which] = NULL;
  305|      0|    }
  306|       |
  307|      8|    return SNMPERR_SUCCESS;
  ------------------
  |  |  184|      8|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
  308|     10|}
netsnmp_ds_get_string:
  312|     38|{
  313|     38|    if (storeid < 0 || storeid >= NETSNMP_DS_MAX_IDS || 
  ------------------
  |  |   38|     76|#define NETSNMP_DS_MAX_IDS 3
  ------------------
  |  Branch (313:9): [True: 0, False: 38]
  |  Branch (313:24): [True: 0, False: 38]
  ------------------
  314|     38|	which   < 0 || which   >= NETSNMP_DS_MAX_SUBIDS) {
  ------------------
  |  |   39|     38|#define NETSNMP_DS_MAX_SUBIDS 64        /* needs to be a multiple of 8 */
  ------------------
  |  Branch (314:2): [True: 0, False: 38]
  |  Branch (314:17): [True: 0, False: 38]
  ------------------
  315|      0|        return NULL;
  316|      0|    }
  317|       |
  318|     38|    return netsnmp_ds_strings[storeid][which];
  319|     38|}
netsnmp_ds_register_config:
  447|     86|{
  448|     86|    netsnmp_ds_read_config *drsp;
  449|       |
  450|     86|    if (storeid < 0 || storeid >= NETSNMP_DS_MAX_IDS    || 
  ------------------
  |  |   38|    172|#define NETSNMP_DS_MAX_IDS 3
  ------------------
  |  Branch (450:9): [True: 0, False: 86]
  |  Branch (450:24): [True: 0, False: 86]
  ------------------
  451|     86|	which   < 0 || which   >= NETSNMP_DS_MAX_SUBIDS || token == NULL) {
  ------------------
  |  |   39|    172|#define NETSNMP_DS_MAX_SUBIDS 64        /* needs to be a multiple of 8 */
  ------------------
  |  Branch (451:2): [True: 0, False: 86]
  |  Branch (451:17): [True: 0, False: 86]
  |  Branch (451:53): [True: 0, False: 86]
  ------------------
  452|      0|        return SNMPERR_GENERR;
  ------------------
  |  |  185|      0|#define SNMPERR_GENERR			(-1)
  ------------------
  453|      0|    }
  454|       |
  455|     86|    if (netsnmp_ds_configs == NULL) {
  ------------------
  |  Branch (455:9): [True: 2, False: 84]
  ------------------
  456|      2|        netsnmp_ds_configs = SNMP_MALLOC_TYPEDEF(netsnmp_ds_read_config);
  ------------------
  |  |   73|      2|#define SNMP_MALLOC_TYPEDEF(td)  (td *) calloc(1, sizeof(td))
  ------------------
  457|      2|        if (netsnmp_ds_configs == NULL)
  ------------------
  |  Branch (457:13): [True: 0, False: 2]
  ------------------
  458|      0|            return SNMPERR_GENERR;
  ------------------
  |  |  185|      0|#define SNMPERR_GENERR			(-1)
  ------------------
  459|      2|        drsp = netsnmp_ds_configs;
  460|     84|    } else {
  461|  3.38k|        for (drsp = netsnmp_ds_configs; drsp->next != NULL; drsp = drsp->next);
  ------------------
  |  Branch (461:41): [True: 3.30k, False: 84]
  ------------------
  462|     84|        drsp->next = SNMP_MALLOC_TYPEDEF(netsnmp_ds_read_config);
  ------------------
  |  |   73|     84|#define SNMP_MALLOC_TYPEDEF(td)  (td *) calloc(1, sizeof(td))
  ------------------
  463|     84|        if (drsp->next == NULL)
  ------------------
  |  Branch (463:13): [True: 0, False: 84]
  ------------------
  464|      0|            return SNMPERR_GENERR;
  ------------------
  |  |  185|      0|#define SNMPERR_GENERR			(-1)
  ------------------
  465|     84|        drsp = drsp->next;
  466|     84|    }
  467|       |
  468|     86|    drsp->type    = type;
  469|     86|    drsp->ftype   = strdup(ftype);
  470|     86|    drsp->token   = strdup(token);
  471|     86|    drsp->storeid = storeid;
  472|     86|    drsp->which   = which;
  473|       |
  474|     86|    switch (type) {
  ------------------
  |  Branch (474:13): [True: 86, False: 0]
  ------------------
  475|     26|    case ASN_BOOLEAN:
  ------------------
  |  |   72|     26|#define ASN_BOOLEAN	    0x01U
  ------------------
  |  Branch (475:5): [True: 26, False: 60]
  ------------------
  476|     26|        register_config_handler(ftype, token, netsnmp_ds_handle_config, NULL,
  477|     26|                                "(1|yes|true|0|no|false)");
  478|     26|        break;
  479|       |
  480|     16|    case ASN_INTEGER:
  ------------------
  |  |   75|     16|#define ASN_INTEGER	    0x02U
  ------------------
  |  Branch (480:5): [True: 16, False: 70]
  ------------------
  481|     16|        register_config_handler(ftype, token, netsnmp_ds_handle_config, NULL,
  482|     16|                                "integerValue");
  483|     16|        break;
  484|       |
  485|     44|    case ASN_OCTET_STR:
  ------------------
  |  |   78|     44|#define ASN_OCTET_STR	    0x04U
  ------------------
  |  Branch (485:5): [True: 44, False: 42]
  ------------------
  486|     44|        register_config_handler(ftype, token, netsnmp_ds_handle_config, NULL,
  487|     44|                                "string");
  488|     44|        break;
  489|       |
  490|     86|    }
  491|     86|    return SNMPERR_SUCCESS;
  ------------------
  |  |  184|     86|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
  492|     86|}
netsnmp_ds_register_premib:
  497|     46|{
  498|     46|    netsnmp_ds_read_config *drsp;
  499|       |
  500|     46|    if (storeid < 0 || storeid >= NETSNMP_DS_MAX_IDS    || 
  ------------------
  |  |   38|     92|#define NETSNMP_DS_MAX_IDS 3
  ------------------
  |  Branch (500:9): [True: 0, False: 46]
  |  Branch (500:24): [True: 0, False: 46]
  ------------------
  501|     46|	which   < 0 || which   >= NETSNMP_DS_MAX_SUBIDS || token == NULL) {
  ------------------
  |  |   39|     92|#define NETSNMP_DS_MAX_SUBIDS 64        /* needs to be a multiple of 8 */
  ------------------
  |  Branch (501:2): [True: 0, False: 46]
  |  Branch (501:17): [True: 0, False: 46]
  |  Branch (501:53): [True: 0, False: 46]
  ------------------
  502|      0|        return SNMPERR_GENERR;
  ------------------
  |  |  185|      0|#define SNMPERR_GENERR			(-1)
  ------------------
  503|      0|    }
  504|       |
  505|     46|    if (netsnmp_ds_configs == NULL) {
  ------------------
  |  Branch (505:9): [True: 0, False: 46]
  ------------------
  506|      0|        netsnmp_ds_configs = SNMP_MALLOC_TYPEDEF(netsnmp_ds_read_config);
  ------------------
  |  |   73|      0|#define SNMP_MALLOC_TYPEDEF(td)  (td *) calloc(1, sizeof(td))
  ------------------
  507|      0|        if (netsnmp_ds_configs == NULL)
  ------------------
  |  Branch (507:13): [True: 0, False: 0]
  ------------------
  508|      0|            return SNMPERR_GENERR;
  ------------------
  |  |  185|      0|#define SNMPERR_GENERR			(-1)
  ------------------
  509|      0|        drsp = netsnmp_ds_configs;
  510|     46|    } else {
  511|    902|        for (drsp = netsnmp_ds_configs; drsp->next != NULL; drsp = drsp->next);
  ------------------
  |  Branch (511:41): [True: 856, False: 46]
  ------------------
  512|     46|        drsp->next = SNMP_MALLOC_TYPEDEF(netsnmp_ds_read_config);
  ------------------
  |  |   73|     46|#define SNMP_MALLOC_TYPEDEF(td)  (td *) calloc(1, sizeof(td))
  ------------------
  513|     46|        if (drsp->next == NULL)
  ------------------
  |  Branch (513:13): [True: 0, False: 46]
  ------------------
  514|      0|            return SNMPERR_GENERR;
  ------------------
  |  |  185|      0|#define SNMPERR_GENERR			(-1)
  ------------------
  515|     46|        drsp = drsp->next;
  516|     46|    }
  517|       |
  518|     46|    drsp->type    = type;
  519|     46|    drsp->ftype   = strdup(ftype);
  520|     46|    drsp->token   = strdup(token);
  521|     46|    drsp->storeid = storeid;
  522|     46|    drsp->which   = which;
  523|       |
  524|     46|    switch (type) {
  ------------------
  |  Branch (524:13): [True: 46, False: 0]
  ------------------
  525|     34|    case ASN_BOOLEAN:
  ------------------
  |  |   72|     34|#define ASN_BOOLEAN	    0x01U
  ------------------
  |  Branch (525:5): [True: 34, False: 12]
  ------------------
  526|     34|        register_prenetsnmp_mib_handler(ftype, token, netsnmp_ds_handle_config,
  527|     34|                                        NULL, "(1|yes|true|0|no|false)");
  528|     34|        break;
  529|       |
  530|      8|    case ASN_INTEGER:
  ------------------
  |  |   75|      8|#define ASN_INTEGER	    0x02U
  ------------------
  |  Branch (530:5): [True: 8, False: 38]
  ------------------
  531|      8|        register_prenetsnmp_mib_handler(ftype, token, netsnmp_ds_handle_config,
  532|      8|                                        NULL, "integerValue");
  533|      8|        break;
  534|       |
  535|      4|    case ASN_OCTET_STR:
  ------------------
  |  |   78|      4|#define ASN_OCTET_STR	    0x04U
  ------------------
  |  Branch (535:5): [True: 4, False: 42]
  ------------------
  536|      4|        register_prenetsnmp_mib_handler(ftype, token, netsnmp_ds_handle_config,
  537|      4|                                        NULL, "string");
  538|      4|        break;
  539|       |
  540|     46|    }
  541|     46|    return SNMPERR_SUCCESS;
  ------------------
  |  |  184|     46|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
  542|     46|}

generate_Ku:
  115|      8|{
  116|      8|    int             rval = SNMPERR_SUCCESS,
  ------------------
  |  |  184|      8|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
  117|      8|        nbytes = USM_LENGTH_EXPANDED_PASSPHRASE, auth_type;
  ------------------
  |  |   13|      8|#define USM_LENGTH_EXPANDED_PASSPHRASE	(1024 * 1024)   /* 1Meg. */
  ------------------
  118|       |#if !defined(NETSNMP_USE_OPENSSL) && \
  119|       |    defined(NETSNMP_USE_INTERNAL_MD5) || defined(NETSNMP_USE_INTERNAL_CRYPTO)
  120|       |    int             ret;
  121|       |#endif
  122|       |
  123|      8|    u_int           i, pindex = 0;
  124|       |
  125|      8|    u_char          buf[USM_LENGTH_KU_HASHBLOCK], *bufp;
  126|       |
  127|      8|#ifdef NETSNMP_USE_OPENSSL
  128|      8|    EVP_MD_CTX     *ctx = NULL;
  129|      8|    const EVP_MD   *hashfn = NULL;
  130|       |#elif defined(NETSNMP_USE_INTERNAL_CRYPTO)
  131|       |    SHA_CTX csha1;
  132|       |    MD5_CTX cmd5;
  133|       |    char    cryptotype = 0;
  134|       |#define TYPE_MD5  1
  135|       |#define TYPE_SHA1 2
  136|       |#else
  137|       |    MDstruct        MD;
  138|       |#endif
  139|       |    /*
  140|       |     * Sanity check.
  141|       |     */
  142|      8|    if (!hashtype || !P || !Ku || !kulen || (*kulen <= 0)) {
  ------------------
  |  Branch (142:9): [True: 0, False: 8]
  |  Branch (142:22): [True: 0, False: 8]
  |  Branch (142:28): [True: 0, False: 8]
  |  Branch (142:35): [True: 0, False: 8]
  |  Branch (142:45): [True: 0, False: 8]
  ------------------
  143|      0|        QUITFUN(SNMPERR_GENERR, generate_Ku_quit);
  ------------------
  |  |  143|      0|	if ( (e) != SNMPERR_SUCCESS) {	\
  |  |  ------------------
  |  |  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  ------------------
  |  |  |  Branch (143:7): [True: 0, Folded]
  |  |  ------------------
  |  |  144|      0|		rval = SNMPERR_GENERR;	\
  |  |  ------------------
  |  |  |  |  185|      0|#define SNMPERR_GENERR			(-1)
  |  |  ------------------
  |  |  145|      0|		goto l ;		\
  |  |  146|      0|	}
  ------------------
  144|      0|    }
  145|       |
  146|      8|    if (pplen < USM_LENGTH_P_MIN) {
  ------------------
  |  |   17|      8|#define USM_LENGTH_P_MIN		8       /* In characters. */
  ------------------
  |  Branch (146:9): [True: 0, False: 8]
  ------------------
  147|      0|        snmp_log(LOG_ERR, "Error: passphrase chosen is below the length "
  148|      0|                 "requirements of the USM (min=%d).\n",USM_LENGTH_P_MIN);
  ------------------
  |  |   17|      0|#define USM_LENGTH_P_MIN		8       /* In characters. */
  ------------------
  149|      0|        snmp_set_detail("The supplied password length is too short.");
  150|      0|        QUITFUN(SNMPERR_GENERR, generate_Ku_quit);
  ------------------
  |  |  143|      0|	if ( (e) != SNMPERR_SUCCESS) {	\
  |  |  ------------------
  |  |  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  ------------------
  |  |  |  Branch (143:7): [True: 0, Folded]
  |  |  ------------------
  |  |  144|      0|		rval = SNMPERR_GENERR;	\
  |  |  ------------------
  |  |  |  |  185|      0|#define SNMPERR_GENERR			(-1)
  |  |  ------------------
  |  |  145|      0|		goto l ;		\
  |  |  146|      0|	}
  ------------------
  151|      0|    }
  152|       |
  153|      8|    auth_type = sc_get_authtype(hashtype, hashtype_len);
  154|      8|    if (SNMPERR_GENERR == auth_type) {
  ------------------
  |  |  185|      8|#define SNMPERR_GENERR			(-1)
  ------------------
  |  Branch (154:9): [True: 0, False: 8]
  ------------------
  155|      0|        snmp_log(LOG_ERR, "Error: unknown authtype");
  156|      0|        snmp_set_detail("unknown authtype");
  157|      0|        QUITFUN(SNMPERR_GENERR, generate_Ku_quit);
  ------------------
  |  |  143|      0|	if ( (e) != SNMPERR_SUCCESS) {	\
  |  |  ------------------
  |  |  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  ------------------
  |  |  |  Branch (143:7): [True: 0, Folded]
  |  |  ------------------
  |  |  144|      0|		rval = SNMPERR_GENERR;	\
  |  |  ------------------
  |  |  |  |  185|      0|#define SNMPERR_GENERR			(-1)
  |  |  ------------------
  |  |  145|      0|		goto l ;		\
  |  |  146|      0|	}
  ------------------
  158|      0|    }
  159|       |
  160|       |    /*
  161|       |     * Setup for the transform type.
  162|       |     */
  163|      8|#ifdef NETSNMP_USE_OPENSSL
  164|       |
  165|      8|    if (*kulen < EVP_MAX_MD_SIZE) {
  ------------------
  |  Branch (165:9): [True: 0, False: 8]
  ------------------
  166|      0|        snmp_log(LOG_ERR, "Internal Error: ku buffer too small (min=%d).\n",
  167|      0|                 EVP_MAX_MD_SIZE);
  168|      0|        snmp_set_detail("Internal Error: ku buffer too small.");
  169|      0|        QUITFUN(SNMPERR_GENERR, generate_Ku_quit);
  ------------------
  |  |  143|      0|	if ( (e) != SNMPERR_SUCCESS) {	\
  |  |  ------------------
  |  |  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  ------------------
  |  |  |  Branch (143:7): [True: 0, Folded]
  |  |  ------------------
  |  |  144|      0|		rval = SNMPERR_GENERR;	\
  |  |  ------------------
  |  |  |  |  185|      0|#define SNMPERR_GENERR			(-1)
  |  |  ------------------
  |  |  145|      0|		goto l ;		\
  |  |  146|      0|	}
  ------------------
  170|      0|    }
  171|       |
  172|       |    /** get hash function */
  173|      8|    hashfn = sc_get_openssl_hashfn(auth_type);
  174|      8|    if (NULL == hashfn) {
  ------------------
  |  Branch (174:9): [True: 0, False: 8]
  ------------------
  175|      0|        snmp_log(LOG_ERR, "Error: no hashfn for authtype");
  176|      0|        snmp_set_detail("no hashfn for authtype");
  177|      0|        QUITFUN(SNMPERR_GENERR, generate_Ku_quit);
  ------------------
  |  |  143|      0|	if ( (e) != SNMPERR_SUCCESS) {	\
  |  |  ------------------
  |  |  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  ------------------
  |  |  |  Branch (143:7): [True: 0, Folded]
  |  |  ------------------
  |  |  144|      0|		rval = SNMPERR_GENERR;	\
  |  |  ------------------
  |  |  |  |  185|      0|#define SNMPERR_GENERR			(-1)
  |  |  ------------------
  |  |  145|      0|		goto l ;		\
  |  |  146|      0|	}
  ------------------
  178|      0|    }
  179|       |
  180|      8|#if defined(HAVE_EVP_MD_CTX_NEW)
  181|      8|    ctx = EVP_MD_CTX_new();
  182|       |#elif defined(HAVE_EVP_MD_CTX_CREATE)
  183|       |    ctx = EVP_MD_CTX_create();
  184|       |#elif defined(HAVE_VOID_EVP_MD_CTX_INIT)
  185|       |    ctx = malloc(sizeof(*ctx));
  186|       |    if (ctx)
  187|       |        EVP_MD_CTX_init(ctx);
  188|       |#else
  189|       |    ctx = malloc(sizeof(*ctx));
  190|       |    if (!ctx || !EVP_MD_CTX_init(ctx)) {
  191|       |        rval = SNMPERR_GENERR;
  192|       |        goto generate_Ku_quit;
  193|       |    }
  194|       |#endif
  195|      8|    if (!ctx || !EVP_DigestInit(ctx, hashfn)) {
  ------------------
  |  Branch (195:9): [True: 0, False: 8]
  |  Branch (195:17): [True: 0, False: 8]
  ------------------
  196|      0|        rval = SNMPERR_GENERR;
  ------------------
  |  |  185|      0|#define SNMPERR_GENERR			(-1)
  ------------------
  197|      0|        goto generate_Ku_quit;
  198|      0|    }
  199|       |
  200|       |#elif defined(NETSNMP_USE_INTERNAL_CRYPTO)
  201|       |#ifndef NETSNMP_DISABLE_MD5
  202|       |    if (NETSNMP_USMAUTH_HMACMD5 == auth_type) {
  203|       |        if (!MD5_Init(&cmd5))
  204|       |            return SNMPERR_GENERR;
  205|       |        cryptotype = TYPE_MD5;
  206|       |    } else
  207|       |#endif
  208|       |           if (NETSNMP_USMAUTH_HMACSHA1 == auth_type) {
  209|       |        if (!SHA1_Init(&csha1))
  210|       |            return SNMPERR_GENERR;
  211|       |        cryptotype = TYPE_SHA1;
  212|       |    } else {
  213|       |        return (SNMPERR_GENERR);
  214|       |    }
  215|       |#else
  216|       |    MDbegin(&MD);
  217|       |#endif                          /* NETSNMP_USE_OPENSSL */
  218|       |
  219|   131k|    while (nbytes > 0) {
  ------------------
  |  Branch (219:12): [True: 131k, False: 8]
  ------------------
  220|   131k|        bufp = buf;
  221|  8.51M|        for (i = 0; i < USM_LENGTH_KU_HASHBLOCK; i++) {
  ------------------
  |  |   15|  8.51M|#define USM_LENGTH_KU_HASHBLOCK		64      /* In bytes. */
  ------------------
  |  Branch (221:21): [True: 8.38M, False: 131k]
  ------------------
  222|  8.38M|            *bufp++ = P[pindex++ % pplen];
  223|  8.38M|        }
  224|   131k|#ifdef NETSNMP_USE_OPENSSL
  225|   131k|        if (!EVP_DigestUpdate(ctx, buf, USM_LENGTH_KU_HASHBLOCK)) {
  ------------------
  |  |   15|   131k|#define USM_LENGTH_KU_HASHBLOCK		64      /* In bytes. */
  ------------------
  |  Branch (225:13): [True: 0, False: 131k]
  ------------------
  226|      0|            rval = SNMPERR_USM_ENCRYPTIONERROR;
  ------------------
  |  |  229|      0|#define SNMPERR_USM_ENCRYPTIONERROR		(-45)
  ------------------
  227|      0|            goto generate_Ku_quit;
  228|      0|        }
  229|       |#elif defined(NETSNMP_USE_INTERNAL_CRYPTO)
  230|       |        if (TYPE_SHA1 == cryptotype) {
  231|       |            rval = !SHA1_Update(&csha1, buf, USM_LENGTH_KU_HASHBLOCK);
  232|       |        } else {
  233|       |            rval = !MD5_Update(&cmd5, buf, USM_LENGTH_KU_HASHBLOCK);
  234|       |        }
  235|       |        if (rval != 0) {
  236|       |            return SNMPERR_USM_ENCRYPTIONERROR;
  237|       |        }
  238|       |#elif defined(NETSNMP_USE_INTERNAL_MD5)
  239|       |        if (MDupdate(&MD, buf, USM_LENGTH_KU_HASHBLOCK * 8)) {
  240|       |            rval = SNMPERR_USM_ENCRYPTIONERROR;
  241|       |            goto md5_fin;
  242|       |        }
  243|       |#endif                          /* NETSNMP_USE_OPENSSL */
  244|   131k|        nbytes -= USM_LENGTH_KU_HASHBLOCK;
  ------------------
  |  |   15|   131k|#define USM_LENGTH_KU_HASHBLOCK		64      /* In bytes. */
  ------------------
  245|   131k|    }
  246|       |
  247|      8|#ifdef NETSNMP_USE_OPENSSL
  248|      8|    {
  249|      8|    unsigned int    tmp_len;
  250|       |
  251|      8|    tmp_len = *kulen;
  252|      8|    if (!EVP_DigestFinal(ctx, (unsigned char *) Ku, &tmp_len)) {
  ------------------
  |  Branch (252:9): [True: 0, False: 8]
  ------------------
  253|      0|        rval = SNMPERR_USM_ENCRYPTIONERROR;
  ------------------
  |  |  229|      0|#define SNMPERR_USM_ENCRYPTIONERROR		(-45)
  ------------------
  254|      0|        goto generate_Ku_quit;
  255|      0|    }
  256|      8|    *kulen = tmp_len;
  257|       |    /*
  258|       |     * what about free() 
  259|       |     */
  260|      8|    }
  261|       |#elif defined(NETSNMP_USE_INTERNAL_CRYPTO)
  262|       |    if (TYPE_SHA1 == cryptotype) {
  263|       |        SHA1_Final(Ku, &csha1);
  264|       |    } else {
  265|       |        MD5_Final(Ku, &cmd5);
  266|       |    }
  267|       |    ret = sc_get_properlength(hashtype, hashtype_len);
  268|       |    if (ret == SNMPERR_GENERR)
  269|       |        return SNMPERR_GENERR;
  270|       |    *kulen = ret;
  271|       |#elif defined(NETSNMP_USE_INTERNAL_MD5)
  272|       |    if (MDupdate(&MD, buf, 0)) {
  273|       |        rval = SNMPERR_USM_ENCRYPTIONERROR;
  274|       |        goto md5_fin;
  275|       |    }
  276|       |    ret = sc_get_properlength(hashtype, hashtype_len);
  277|       |    if (ret == SNMPERR_GENERR)
  278|       |        return SNMPERR_GENERR;
  279|       |    *kulen = ret;
  280|       |    MDget(&MD, Ku, *kulen);
  281|       |  md5_fin:
  282|       |    memset(&MD, 0, sizeof(MD));
  283|       |#endif                          /* NETSNMP_USE_INTERNAL_MD5 */
  284|       |
  285|       |
  286|       |#ifdef NETSNMP_ENABLE_TESTING_CODE
  287|       |    DEBUGMSGTL(("generate_Ku", "generating Ku (%s from %s): ",
  288|       |                usm_lookup_auth_str(auth_type), P));
  289|       |    for (i = 0; i < *kulen; i++)
  290|       |        DEBUGMSG(("generate_Ku", "%02x", Ku[i]));
  291|       |    DEBUGMSG(("generate_Ku", "\n"));
  292|       |#endif                          /* NETSNMP_ENABLE_TESTING_CODE */
  293|       |
  294|       |
  295|      8|  generate_Ku_quit:
  296|      8|    memset(buf, 0, sizeof(buf));
  297|      8|#ifdef NETSNMP_USE_OPENSSL
  298|      8|    if (ctx) {
  ------------------
  |  Branch (298:9): [True: 8, False: 0]
  ------------------
  299|      8|#if defined(HAVE_EVP_MD_CTX_FREE)
  300|      8|        EVP_MD_CTX_free(ctx);
  301|       |#elif defined(HAVE_EVP_MD_CTX_DESTROY)
  302|       |        EVP_MD_CTX_destroy(ctx);
  303|       |#else
  304|       |        EVP_MD_CTX_cleanup(ctx);
  305|       |        free(ctx);
  306|       |#endif
  307|      8|    }
  308|      8|#endif
  309|      8|    return rval;
  310|       |
  311|      8|}                               /* end generate_Ku() */
generate_kul:
  404|      8|{
  405|      8|    int             rval = SNMPERR_SUCCESS, auth_type;
  ------------------
  |  |  184|      8|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
  406|      8|    u_int           nbytes = 0;
  407|      8|    size_t          properlength;
  408|      8|    int             iproperlength;
  409|       |
  410|      8|    u_char          buf[SNMP_MAXBUF];
  411|       |#ifdef NETSNMP_ENABLE_TESTING_CODE
  412|       |    int             i;
  413|       |#endif
  414|       |
  415|       |
  416|       |    /*
  417|       |     * Sanity check.
  418|       |     */
  419|      8|    if (!hashtype || !engineID || !Ku || !Kul || !kul_len
  ------------------
  |  Branch (419:9): [True: 0, False: 8]
  |  Branch (419:22): [True: 0, False: 8]
  |  Branch (419:35): [True: 0, False: 8]
  |  Branch (419:42): [True: 0, False: 8]
  |  Branch (419:50): [True: 0, False: 8]
  ------------------
  420|      8|        || (engineID_len <= 0) || (ku_len <= 0) || (*kul_len <= 0)) {
  ------------------
  |  Branch (420:12): [True: 0, False: 8]
  |  Branch (420:35): [True: 0, False: 8]
  |  Branch (420:52): [True: 0, False: 8]
  ------------------
  421|      0|        QUITFUN(SNMPERR_GENERR, generate_kul_quit);
  ------------------
  |  |  143|      0|	if ( (e) != SNMPERR_SUCCESS) {	\
  |  |  ------------------
  |  |  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  ------------------
  |  |  |  Branch (143:7): [True: 0, Folded]
  |  |  ------------------
  |  |  144|      0|		rval = SNMPERR_GENERR;	\
  |  |  ------------------
  |  |  |  |  185|      0|#define SNMPERR_GENERR			(-1)
  |  |  ------------------
  |  |  145|      0|		goto l ;		\
  |  |  146|      0|	}
  ------------------
  422|      0|    }
  423|       |
  424|      8|    auth_type = sc_get_authtype(hashtype, hashtype_len);
  425|      8|    if (SNMPERR_GENERR == auth_type)
  ------------------
  |  |  185|      8|#define SNMPERR_GENERR			(-1)
  ------------------
  |  Branch (425:9): [True: 0, False: 8]
  ------------------
  426|      8|        QUITFUN(SNMPERR_GENERR, generate_kul_quit);
  ------------------
  |  |  143|      0|	if ( (e) != SNMPERR_SUCCESS) {	\
  |  |  ------------------
  |  |  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  ------------------
  |  |  |  Branch (143:7): [True: 0, Folded]
  |  |  ------------------
  |  |  144|      0|		rval = SNMPERR_GENERR;	\
  |  |  ------------------
  |  |  |  |  185|      0|#define SNMPERR_GENERR			(-1)
  |  |  ------------------
  |  |  145|      0|		goto l ;		\
  |  |  146|      0|	}
  ------------------
  427|       |
  428|      8|    iproperlength = sc_get_proper_auth_length_bytype(auth_type);
  429|      8|    if (iproperlength == SNMPERR_GENERR)
  ------------------
  |  |  185|      8|#define SNMPERR_GENERR			(-1)
  ------------------
  |  Branch (429:9): [True: 0, False: 8]
  ------------------
  430|      8|        QUITFUN(SNMPERR_GENERR, generate_kul_quit);
  ------------------
  |  |  143|      0|	if ( (e) != SNMPERR_SUCCESS) {	\
  |  |  ------------------
  |  |  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  ------------------
  |  |  |  Branch (143:7): [True: 0, Folded]
  |  |  ------------------
  |  |  144|      0|		rval = SNMPERR_GENERR;	\
  |  |  ------------------
  |  |  |  |  185|      0|#define SNMPERR_GENERR			(-1)
  |  |  ------------------
  |  |  145|      0|		goto l ;		\
  |  |  146|      0|	}
  ------------------
  431|       |
  432|      8|    properlength = (size_t) iproperlength;
  433|       |
  434|      8|    if ((*kul_len < properlength) || (ku_len < properlength) ||
  ------------------
  |  Branch (434:9): [True: 0, False: 8]
  |  Branch (434:38): [True: 0, False: 8]
  ------------------
  435|      8|        (engineID_len > sizeof(buf)) ||
  ------------------
  |  Branch (435:9): [True: 0, False: 8]
  ------------------
  436|      8|        (2 * properlength > sizeof(buf) - engineID_len)) {
  ------------------
  |  Branch (436:9): [True: 0, False: 8]
  ------------------
  437|      0|        QUITFUN(SNMPERR_GENERR, generate_kul_quit);
  ------------------
  |  |  143|      0|	if ( (e) != SNMPERR_SUCCESS) {	\
  |  |  ------------------
  |  |  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  ------------------
  |  |  |  Branch (143:7): [True: 0, Folded]
  |  |  ------------------
  |  |  144|      0|		rval = SNMPERR_GENERR;	\
  |  |  ------------------
  |  |  |  |  185|      0|#define SNMPERR_GENERR			(-1)
  |  |  ------------------
  |  |  145|      0|		goto l ;		\
  |  |  146|      0|	}
  ------------------
  438|      0|    }
  439|       |
  440|       |    /*
  441|       |     * Concatenate Ku and engineID properly, then hash the result.
  442|       |     * Store it in Kul.
  443|       |     */
  444|      8|    nbytes = 0;
  445|      8|    memcpy(buf, Ku, properlength);
  446|      8|    nbytes += properlength;
  447|      8|    memcpy(buf + nbytes, engineID, engineID_len);
  448|      8|    nbytes += engineID_len;
  449|      8|    memcpy(buf + nbytes, Ku, properlength);
  450|      8|    nbytes += properlength;
  451|       |
  452|      8|    rval = sc_hash(hashtype, hashtype_len, buf, nbytes, Kul, kul_len);
  453|       |
  454|       |#ifdef NETSNMP_ENABLE_TESTING_CODE
  455|       |    DEBUGMSGTL(("generate_kul", "generating Kul (%s from Ku): ",
  456|       |                usm_lookup_auth_str(auth_type) ));
  457|       |    for (i = 0; i < *kul_len; i++)
  458|       |        DEBUGMSG(("generate_kul", "%02x", Kul[i]));
  459|       |    DEBUGMSG(("generate_kul", "keytools\n"));
  460|       |#endif                          /* NETSNMP_ENABLE_TESTING_CODE */
  461|       |
  462|      8|    QUITFUN(rval, generate_kul_quit);
  ------------------
  |  |  143|      8|	if ( (e) != SNMPERR_SUCCESS) {	\
  |  |  ------------------
  |  |  |  |  184|      8|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  ------------------
  |  |  |  Branch (143:7): [True: 0, False: 8]
  |  |  ------------------
  |  |  144|      0|		rval = SNMPERR_GENERR;	\
  |  |  ------------------
  |  |  |  |  185|      0|#define SNMPERR_GENERR			(-1)
  |  |  ------------------
  |  |  145|      0|		goto l ;		\
  |  |  146|      0|	}
  ------------------
  463|       |
  464|       |
  465|      8|  generate_kul_quit:
  466|      8|    return rval;
  467|       |
  468|      8|}                               /* end generate_kul() */

set_enginetime:
  347|  2.35k|{
  348|  2.35k|    int             rval = SNMPERR_SUCCESS, iindex;
  ------------------
  |  |  184|  2.35k|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
  349|  2.35k|    Enginetime      e = NULL;
  350|       |
  351|       |
  352|       |
  353|       |    /*
  354|       |     * Sanity check.
  355|       |     */
  356|  2.35k|    if (!engineID || (engineID_len <= 0)) {
  ------------------
  |  Branch (356:9): [True: 0, False: 2.35k]
  |  Branch (356:22): [True: 1.77k, False: 584]
  ------------------
  357|  1.77k|        return rval;
  358|  1.77k|    }
  359|       |
  360|       |
  361|       |    /*
  362|       |     * Store the given <engine_time, engineboot> tuple in the record
  363|       |     * for engineID.  Create a new record if necessary.
  364|       |     */
  365|    584|    if (!(e = search_enginetime_list(engineID, engineID_len))) {
  ------------------
  |  Branch (365:9): [True: 143, False: 441]
  ------------------
  366|    143|        if ((iindex = hash_engineID(engineID, engineID_len)) < 0) {
  ------------------
  |  Branch (366:13): [True: 0, False: 143]
  ------------------
  367|      0|            QUITFUN(SNMPERR_GENERR, set_enginetime_quit);
  ------------------
  |  |  143|      0|	if ( (e) != SNMPERR_SUCCESS) {	\
  |  |  ------------------
  |  |  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  ------------------
  |  |  |  Branch (143:7): [True: 0, Folded]
  |  |  ------------------
  |  |  144|      0|		rval = SNMPERR_GENERR;	\
  |  |  ------------------
  |  |  |  |  185|      0|#define SNMPERR_GENERR			(-1)
  |  |  ------------------
  |  |  145|      0|		goto l ;		\
  |  |  146|      0|	}
  ------------------
  368|      0|        }
  369|       |
  370|    143|        e = calloc(1, sizeof(*e));
  371|    143|        if (!e) {
  ------------------
  |  Branch (371:13): [True: 0, False: 143]
  ------------------
  372|      0|            QUITFUN(SNMPERR_GENERR, set_enginetime_quit);
  ------------------
  |  |  143|      0|	if ( (e) != SNMPERR_SUCCESS) {	\
  |  |  ------------------
  |  |  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  ------------------
  |  |  |  Branch (143:7): [True: 0, Folded]
  |  |  ------------------
  |  |  144|      0|		rval = SNMPERR_GENERR;	\
  |  |  ------------------
  |  |  |  |  185|      0|#define SNMPERR_GENERR			(-1)
  |  |  ------------------
  |  |  145|      0|		goto l ;		\
  |  |  146|      0|	}
  ------------------
  373|      0|        }
  374|       |
  375|    143|        e->engineID = calloc(1, engineID_len);
  376|    143|        if (!e->engineID) {
  ------------------
  |  Branch (376:13): [True: 0, False: 143]
  ------------------
  377|      0|            QUITFUN(SNMPERR_GENERR, set_enginetime_quit);
  ------------------
  |  |  143|      0|	if ( (e) != SNMPERR_SUCCESS) {	\
  |  |  ------------------
  |  |  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  ------------------
  |  |  |  Branch (143:7): [True: 0, Folded]
  |  |  ------------------
  |  |  144|      0|		rval = SNMPERR_GENERR;	\
  |  |  ------------------
  |  |  |  |  185|      0|#define SNMPERR_GENERR			(-1)
  |  |  ------------------
  |  |  145|      0|		goto l ;		\
  |  |  146|      0|	}
  ------------------
  378|      0|        }
  379|    143|        memcpy(e->engineID, engineID, engineID_len);
  380|       |
  381|    143|        e->engineID_len = engineID_len;
  382|    143|        e->next = etimelist[iindex];
  383|    143|        etimelist[iindex] = e;
  384|    143|    }
  385|    584|#ifdef LCD_TIME_SYNC_OPT
  386|    584|    if (authenticated || !e->authenticatedFlag) {
  ------------------
  |  Branch (386:9): [True: 2, False: 582]
  |  Branch (386:26): [True: 582, False: 0]
  ------------------
  387|    584|        e->authenticatedFlag = authenticated;
  388|       |#else
  389|       |    if (authenticated) {
  390|       |#endif
  391|    584|        e->engineTime = engine_time;
  392|    584|        e->engineBoot = engineboot;
  393|    584|        e->lastReceivedEngineTime = snmpv3_local_snmpEngineTime();
  394|    584|    }
  395|       |
  396|    584|    e = NULL;                   /* Indicates a successful update. */
  397|       |
  398|    584|    DEBUGMSGTL(("lcd_set_enginetime", "engineID "));
  ------------------
  |  |   66|    584|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|    584|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 584]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 584]
  |  |  ------------------
  ------------------
  399|    584|    DEBUGMSGHEX(("lcd_set_enginetime", engineID, engineID_len));
  ------------------
  |  |   71|    584|#define DEBUGMSGHEX(x)     do {if (_DBG_IF_) {__DBGMSGHEX(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|    584|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 584]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGHEX(x)     do {if (_DBG_IF_) {__DBGMSGHEX(x);} }while(0)
  |  |  ------------------
  |  |  |  |  169|      0|#define __DBGMSGHEX(x)     debugmsg_hex x
  |  |  ------------------
  |  |  |  Branch (71:71): [Folded, False: 584]
  |  |  ------------------
  ------------------
  400|    584|    DEBUGMSG(("lcd_set_enginetime", ": boots=%d, time=%d\n", engineboot,
  ------------------
  |  |   61|    584|#define DEBUGMSG(x)        do {if (_DBG_IF_) {debugmsg x;} }while(0)
  |  |  ------------------
  |  |  |  |  144|    584|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 584]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (61:67): [Folded, False: 584]
  |  |  ------------------
  ------------------
  401|    584|              engine_time));
  402|       |
  403|    584|  set_enginetime_quit:
  404|    584|    SNMP_FREE(e);
  ------------------
  |  |   62|    584|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 0, False: 584]
  |  |  |  Branch (62:66): [Folded, False: 584]
  |  |  ------------------
  ------------------
  405|       |
  406|    584|    return rval;
  407|       |
  408|    584|}                               /* end set_enginetime() */
search_enginetime_list:
  431|    584|{
  432|    584|    int             rval = SNMPERR_SUCCESS;
  ------------------
  |  |  184|    584|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
  433|    584|    Enginetime      e = NULL;
  434|       |
  435|       |
  436|       |    /*
  437|       |     * Sanity check.
  438|       |     */
  439|    584|    if (!engineID || (engineID_len <= 0)) {
  ------------------
  |  Branch (439:9): [True: 0, False: 584]
  |  Branch (439:22): [True: 0, False: 584]
  ------------------
  440|      0|        QUITFUN(SNMPERR_GENERR, search_enginetime_list_quit);
  ------------------
  |  |  143|      0|	if ( (e) != SNMPERR_SUCCESS) {	\
  |  |  ------------------
  |  |  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  ------------------
  |  |  |  Branch (143:7): [True: 0, Folded]
  |  |  ------------------
  |  |  144|      0|		rval = SNMPERR_GENERR;	\
  |  |  ------------------
  |  |  |  |  185|      0|#define SNMPERR_GENERR			(-1)
  |  |  ------------------
  |  |  145|      0|		goto l ;		\
  |  |  146|      0|	}
  ------------------
  441|      0|    }
  442|       |
  443|       |
  444|       |    /*
  445|       |     * Find the entry for engineID if there be one.
  446|       |     */
  447|    584|    rval = hash_engineID(engineID, engineID_len);
  448|    584|    if (rval < 0) {
  ------------------
  |  Branch (448:9): [True: 0, False: 584]
  ------------------
  449|      0|        QUITFUN(SNMPERR_GENERR, search_enginetime_list_quit);
  ------------------
  |  |  143|      0|	if ( (e) != SNMPERR_SUCCESS) {	\
  |  |  ------------------
  |  |  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  ------------------
  |  |  |  Branch (143:7): [True: 0, Folded]
  |  |  ------------------
  |  |  144|      0|		rval = SNMPERR_GENERR;	\
  |  |  ------------------
  |  |  |  |  185|      0|#define SNMPERR_GENERR			(-1)
  |  |  ------------------
  |  |  145|      0|		goto l ;		\
  |  |  146|      0|	}
  ------------------
  450|      0|    }
  451|    584|    e = etimelist[rval];
  452|       |
  453|  2.76k|    for ( /*EMPTY*/; e; e = e->next) {
  ------------------
  |  Branch (453:22): [True: 2.61k, False: 143]
  ------------------
  454|  2.61k|        if ((engineID_len == e->engineID_len)
  ------------------
  |  Branch (454:13): [True: 1.09k, False: 1.52k]
  ------------------
  455|  1.09k|            && !memcmp(e->engineID, engineID, engineID_len)) {
  ------------------
  |  Branch (455:16): [True: 441, False: 656]
  ------------------
  456|    441|            break;
  457|    441|        }
  458|  2.61k|    }
  459|       |
  460|       |
  461|    584|  search_enginetime_list_quit:
  462|    584|    return e;
  463|       |
  464|    584|}                               /* end search_enginetime_list() */
hash_engineID:
  489|    727|{
  490|    727|    int             rval = SNMPERR_GENERR;
  ------------------
  |  |  185|    727|#define SNMPERR_GENERR			(-1)
  ------------------
  491|    727|    size_t          buf_len = SNMP_MAXBUF;
  ------------------
  |  |   43|    727|#define SNMP_MAXBUF		(1024 * 4)
  ------------------
  492|    727|    u_int           additive = 0;
  493|    727|    u_char         *bufp, buf[SNMP_MAXBUF];
  494|    727|    void           *context = NULL;
  495|       |
  496|       |
  497|       |
  498|       |    /*
  499|       |     * Sanity check.
  500|       |     */
  501|    727|    if (!engineID || (engineID_len <= 0)) {
  ------------------
  |  Branch (501:9): [True: 0, False: 727]
  |  Branch (501:22): [True: 0, False: 727]
  ------------------
  502|      0|        QUITFUN(SNMPERR_GENERR, hash_engineID_quit);
  ------------------
  |  |  143|      0|	if ( (e) != SNMPERR_SUCCESS) {	\
  |  |  ------------------
  |  |  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  ------------------
  |  |  |  Branch (143:7): [True: 0, Folded]
  |  |  ------------------
  |  |  144|      0|		rval = SNMPERR_GENERR;	\
  |  |  ------------------
  |  |  |  |  185|      0|#define SNMPERR_GENERR			(-1)
  |  |  ------------------
  |  |  145|      0|		goto l ;		\
  |  |  146|      0|	}
  ------------------
  503|      0|    }
  504|       |
  505|       |
  506|       |    /*
  507|       |     * Hash engineID into a list index.
  508|       |     */
  509|    727|#ifndef NETSNMP_DISABLE_MD5
  510|    727|    rval = sc_hash(usmHMACMD5AuthProtocol,
  511|    727|                   OID_LENGTH(usmHMACMD5AuthProtocol),
  ------------------
  |  |   64|    727|    (sizeof(x) / sizeof((x)[0]) +                                       \
  |  |   65|    727|     sizeof(int[-__builtin_types_compatible_p(typeof(x), typeof(&(x)[0]))]))
  ------------------
  512|    727|                   engineID, engineID_len, buf, &buf_len);
  513|    727|    if (rval == SNMPERR_SC_NOT_CONFIGURED) {
  ------------------
  |  |  223|    727|#define SNMPERR_SC_NOT_CONFIGURED	(-39)
  ------------------
  |  Branch (513:9): [True: 0, False: 727]
  ------------------
  514|       |        /* fall back to sha1 */
  515|      0|        rval = sc_hash(usmHMACSHA1AuthProtocol,
  516|      0|                   OID_LENGTH(usmHMACSHA1AuthProtocol),
  ------------------
  |  |   64|      0|    (sizeof(x) / sizeof((x)[0]) +                                       \
  |  |   65|      0|     sizeof(int[-__builtin_types_compatible_p(typeof(x), typeof(&(x)[0]))]))
  ------------------
  517|      0|                   engineID, engineID_len, buf, &buf_len);
  518|      0|    }
  519|       |#else
  520|       |    rval = sc_hash(usmHMACSHA1AuthProtocol,
  521|       |                   OID_LENGTH(usmHMACSHA1AuthProtocol),
  522|       |                   engineID, engineID_len, buf, &buf_len);
  523|       |#endif
  524|    727|    QUITFUN(rval, hash_engineID_quit);
  ------------------
  |  |  143|    727|	if ( (e) != SNMPERR_SUCCESS) {	\
  |  |  ------------------
  |  |  |  |  184|    727|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  ------------------
  |  |  |  Branch (143:7): [True: 0, False: 727]
  |  |  ------------------
  |  |  144|      0|		rval = SNMPERR_GENERR;	\
  |  |  ------------------
  |  |  |  |  185|      0|#define SNMPERR_GENERR			(-1)
  |  |  ------------------
  |  |  145|      0|		goto l ;		\
  |  |  146|      0|	}
  ------------------
  525|       |
  526|  3.63k|    for (bufp = buf; (bufp - buf) < (int) buf_len; bufp += 4) {
  ------------------
  |  Branch (526:22): [True: 2.90k, False: 727]
  ------------------
  527|  2.90k|        additive += (u_int) * bufp;
  528|  2.90k|    }
  529|       |
  530|    727|  hash_engineID_quit:
  531|    727|    SNMP_FREE(context);
  ------------------
  |  |   62|    727|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 0, False: 727]
  |  |  |  Branch (62:66): [Folded, False: 727]
  |  |  ------------------
  ------------------
  532|    727|    memset(buf, 0, SNMP_MAXBUF);
  ------------------
  |  |   43|    727|#define SNMP_MAXBUF		(1024 * 4)
  ------------------
  533|       |
  534|    727|    return (rval < 0) ? rval : (int)(additive % ETIMELIST_SIZE);
  ------------------
  |  |   21|    727|#define ETIMELIST_SIZE	23
  ------------------
  |  Branch (534:12): [True: 0, False: 727]
  ------------------
  535|       |
  536|    727|}                               /* end hash_engineID() */

register_mib_handlers:
 2488|      2|{
 2489|      2|#ifndef NETSNMP_DISABLE_MIB_LOADING
 2490|      2|    register_prenetsnmp_mib_handler("snmp", "mibdirs",
 2491|      2|                                    handle_mibdirs_conf, NULL,
 2492|      2|                                    "[mib-dirs|+mib-dirs|-mib-dirs]");
 2493|      2|    register_prenetsnmp_mib_handler("snmp", "mibs",
 2494|      2|                                    handle_mibs_conf, NULL,
 2495|      2|                                    "[mib-tokens|+mib-tokens|-mib-tokens]");
 2496|      2|    register_config_handler("snmp", "mibfile",
 2497|      2|                            handle_mibfile_conf, NULL, "mibfile-to-read");
 2498|       |    /*
 2499|       |     * register the snmp.conf configuration handlers for default
 2500|       |     * parsing behaviour 
 2501|       |     */
 2502|       |
 2503|      2|    netsnmp_ds_register_premib(ASN_BOOLEAN, "snmp", "showMibErrors",
  ------------------
  |  |   72|      2|#define ASN_BOOLEAN	    0x01U
  ------------------
 2504|      2|                       NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_MIB_ERRORS);
  ------------------
  |  |   48|      2|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
                                     NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_MIB_ERRORS);
  ------------------
  |  |   59|      2|#define NETSNMP_DS_LIB_MIB_ERRORS          0
  ------------------
 2505|      2|    netsnmp_ds_register_premib(ASN_BOOLEAN, "snmp", "commentToEOL",     /* Describes actual behaviour */
  ------------------
  |  |   72|      2|#define ASN_BOOLEAN	    0x01U
  ------------------
 2506|      2|                       NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_MIB_COMMENT_TERM);
  ------------------
  |  |   48|      2|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
                                     NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_MIB_COMMENT_TERM);
  ------------------
  |  |   61|      2|#define NETSNMP_DS_LIB_MIB_COMMENT_TERM    2
  ------------------
 2507|      2|    netsnmp_ds_register_premib(ASN_BOOLEAN, "snmp", "strictCommentTerm",    /* Backward compatibility */
  ------------------
  |  |   72|      2|#define ASN_BOOLEAN	    0x01U
  ------------------
 2508|      2|                       NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_MIB_COMMENT_TERM);
  ------------------
  |  |   48|      2|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
                                     NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_MIB_COMMENT_TERM);
  ------------------
  |  |   61|      2|#define NETSNMP_DS_LIB_MIB_COMMENT_TERM    2
  ------------------
 2509|      2|    netsnmp_ds_register_premib(ASN_BOOLEAN, "snmp", "mibAllowUnderline",
  ------------------
  |  |   72|      2|#define ASN_BOOLEAN	    0x01U
  ------------------
 2510|      2|                       NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_MIB_PARSE_LABEL);
  ------------------
  |  |   48|      2|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
                                     NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_MIB_PARSE_LABEL);
  ------------------
  |  |   62|      2|#define NETSNMP_DS_LIB_MIB_PARSE_LABEL     3
  ------------------
 2511|      2|    netsnmp_ds_register_premib(ASN_INTEGER, "snmp", "mibWarningLevel",
  ------------------
  |  |   75|      2|#define ASN_INTEGER	    0x02U
  ------------------
 2512|      2|                       NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_MIB_WARNINGS);
  ------------------
  |  |   48|      2|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
                                     NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_MIB_WARNINGS);
  ------------------
  |  |  114|      2|#define NETSNMP_DS_LIB_MIB_WARNINGS         0
  ------------------
 2513|      2|    netsnmp_ds_register_premib(ASN_BOOLEAN, "snmp", "mibReplaceWithLatest",
  ------------------
  |  |   72|      2|#define ASN_BOOLEAN	    0x01U
  ------------------
 2514|      2|                       NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_MIB_REPLACE);
  ------------------
  |  |   48|      2|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
                                     NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_MIB_REPLACE);
  ------------------
  |  |   67|      2|#define NETSNMP_DS_LIB_MIB_REPLACE         7    /* replace objects from latest module */
  ------------------
 2515|      2|#endif
 2516|       |
 2517|      2|    netsnmp_ds_register_premib(ASN_BOOLEAN, "snmp", "printNumericEnums",
  ------------------
  |  |   72|      2|#define ASN_BOOLEAN	    0x01U
  ------------------
 2518|      2|                       NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_PRINT_NUMERIC_ENUM);
  ------------------
  |  |   48|      2|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
                                     NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_PRINT_NUMERIC_ENUM);
  ------------------
  |  |   68|      2|#define NETSNMP_DS_LIB_PRINT_NUMERIC_ENUM  8    /* print only numeric enum values */
  ------------------
 2519|      2|    register_prenetsnmp_mib_handler("snmp", "printNumericOids",
 2520|      2|                       handle_print_numeric, NULL, "(1|yes|true|0|no|false)");
 2521|      2|    netsnmp_ds_register_premib(ASN_BOOLEAN, "snmp", "escapeQuotes",
  ------------------
  |  |   72|      2|#define ASN_BOOLEAN	    0x01U
  ------------------
 2522|      2|                       NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_ESCAPE_QUOTES);
  ------------------
  |  |   48|      2|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
                                     NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_ESCAPE_QUOTES);
  ------------------
  |  |   79|      2|#define NETSNMP_DS_LIB_ESCAPE_QUOTES       19   /* shell escape quote marks in oids */
  ------------------
 2523|      2|    netsnmp_ds_register_premib(ASN_BOOLEAN, "snmp", "dontBreakdownOids",
  ------------------
  |  |   72|      2|#define ASN_BOOLEAN	    0x01U
  ------------------
 2524|      2|                       NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_DONT_BREAKDOWN_OIDS);
  ------------------
  |  |   48|      2|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
                                     NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_DONT_BREAKDOWN_OIDS);
  ------------------
  |  |   70|      2|#define NETSNMP_DS_LIB_DONT_BREAKDOWN_OIDS 10   /* dont print oid indexes specially */
  ------------------
 2525|      2|    netsnmp_ds_register_premib(ASN_BOOLEAN, "snmp", "quickPrinting",
  ------------------
  |  |   72|      2|#define ASN_BOOLEAN	    0x01U
  ------------------
 2526|      2|                       NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICK_PRINT);
  ------------------
  |  |   48|      2|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
                                     NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICK_PRINT);
  ------------------
  |  |   73|      2|#define NETSNMP_DS_LIB_QUICK_PRINT         13   /* print very brief output for parsing */
  ------------------
 2527|      2|    netsnmp_ds_register_premib(ASN_BOOLEAN, "snmp", "numericTimeticks",
  ------------------
  |  |   72|      2|#define ASN_BOOLEAN	    0x01U
  ------------------
 2528|      2|                       NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_NUMERIC_TIMETICKS);
  ------------------
  |  |   48|      2|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
                                     NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_NUMERIC_TIMETICKS);
  ------------------
  |  |   78|      2|#define NETSNMP_DS_LIB_NUMERIC_TIMETICKS   18   /* print timeticks as a number */
  ------------------
 2529|      2|    netsnmp_ds_register_premib(ASN_INTEGER, "snmp", "oidOutputFormat",
  ------------------
  |  |   75|      2|#define ASN_INTEGER	    0x02U
  ------------------
 2530|      2|                       NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_OID_OUTPUT_FORMAT);
  ------------------
  |  |   48|      2|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
                                     NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_OID_OUTPUT_FORMAT);
  ------------------
  |  |  118|      2|#define NETSNMP_DS_LIB_OID_OUTPUT_FORMAT    4
  ------------------
 2531|      2|    netsnmp_ds_register_premib(ASN_INTEGER, "snmp", "suffixPrinting",
  ------------------
  |  |   75|      2|#define ASN_INTEGER	    0x02U
  ------------------
 2532|      2|                       NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_OID_OUTPUT_FORMAT);
  ------------------
  |  |   48|      2|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
                                     NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_OID_OUTPUT_FORMAT);
  ------------------
  |  |  118|      2|#define NETSNMP_DS_LIB_OID_OUTPUT_FORMAT    4
  ------------------
 2533|      2|    netsnmp_ds_register_premib(ASN_BOOLEAN, "snmp", "extendedIndex",
  ------------------
  |  |   72|      2|#define ASN_BOOLEAN	    0x01U
  ------------------
 2534|      2|                       NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_EXTENDED_INDEX);
  ------------------
  |  |   48|      2|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
                                     NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_EXTENDED_INDEX);
  ------------------
  |  |   82|      2|#define NETSNMP_DS_LIB_EXTENDED_INDEX	   22   /* print extended index format [x1][x2] */
  ------------------
 2535|      2|    netsnmp_ds_register_premib(ASN_BOOLEAN, "snmp", "printHexText",
  ------------------
  |  |   72|      2|#define ASN_BOOLEAN	    0x01U
  ------------------
 2536|      2|                       NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_PRINT_HEX_TEXT);
  ------------------
  |  |   48|      2|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
                                     NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_PRINT_HEX_TEXT);
  ------------------
  |  |   83|      2|#define NETSNMP_DS_LIB_PRINT_HEX_TEXT      23   /* print ASCII text along with hex strings */
  ------------------
 2537|      2|    netsnmp_ds_register_premib(ASN_BOOLEAN, "snmp", "printValueOnly",
  ------------------
  |  |   72|      2|#define ASN_BOOLEAN	    0x01U
  ------------------
 2538|      2|                       NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_PRINT_BARE_VALUE);
  ------------------
  |  |   48|      2|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
                                     NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_PRINT_BARE_VALUE);
  ------------------
  |  |   81|      2|#define NETSNMP_DS_LIB_PRINT_BARE_VALUE	   21   /* just print value (not OID = value) */
  ------------------
 2539|      2|    netsnmp_ds_register_premib(ASN_BOOLEAN, "snmp", "dontPrintUnits",
  ------------------
  |  |   72|      2|#define ASN_BOOLEAN	    0x01U
  ------------------
 2540|      2|                       NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_DONT_PRINT_UNITS);
  ------------------
  |  |   48|      2|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
                                     NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_DONT_PRINT_UNITS);
  ------------------
  |  |   89|      2|#define NETSNMP_DS_LIB_DONT_PRINT_UNITS    29 /* don't print UNITS suffix */
  ------------------
 2541|      2|    netsnmp_ds_register_premib(ASN_INTEGER, "snmp", "hexOutputLength",
  ------------------
  |  |   75|      2|#define ASN_INTEGER	    0x02U
  ------------------
 2542|      2|                       NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_HEX_OUTPUT_LENGTH);
  ------------------
  |  |   48|      2|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
                                     NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_HEX_OUTPUT_LENGTH);
  ------------------
  |  |  121|      2|#define NETSNMP_DS_LIB_HEX_OUTPUT_LENGTH    6
  ------------------
 2543|      2|}
netsnmp_set_mib_directory:
 2558|      2|{
 2559|      2|    const char *newdir;
 2560|      2|    char *olddir, *tmpdir = NULL;
 2561|       |
 2562|      2|    DEBUGTRACE;
  ------------------
  |  |   63|      2|#define DEBUGTRACE         do {if (_DBG_IF_) {__DBGTRACE;} }while(0)
  |  |  ------------------
  |  |  |  |  144|      2|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 2]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGTRACE         do {if (_DBG_IF_) {__DBGTRACE;} }while(0)
  |  |  ------------------
  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  ------------------
  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  ------------------
  |  |  |  Branch (63:67): [Folded, False: 2]
  |  |  ------------------
  ------------------
 2563|      2|    if (NULL == dir) {
  ------------------
  |  Branch (2563:9): [True: 0, False: 2]
  ------------------
 2564|      0|        return;
 2565|      0|    }
 2566|       |    
 2567|      2|    olddir = netsnmp_ds_get_string(NETSNMP_DS_LIBRARY_ID,
  ------------------
  |  |   48|      2|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
 2568|      2|				   NETSNMP_DS_LIB_MIBDIRS);
  ------------------
  |  |  162|      2|#define NETSNMP_DS_LIB_MIBDIRS           11
  ------------------
 2569|      2|    if (olddir) {
  ------------------
  |  Branch (2569:9): [True: 2, False: 0]
  ------------------
 2570|      2|        if ((*dir == '+') || (*dir == '-')) {
  ------------------
  |  Branch (2570:13): [True: 0, False: 2]
  |  Branch (2570:30): [True: 0, False: 2]
  ------------------
 2571|       |            /** New dir starts with '+', thus we add it. */
 2572|      0|            if (*dir++ == '+') {
  ------------------
  |  Branch (2572:17): [True: 0, False: 0]
  ------------------
 2573|      0|                if (asprintf(&tmpdir, "%s%c%s", olddir, ENV_SEPARATOR_CHAR, dir) < 0)
  ------------------
  |  |   70|      0|#define ENV_SEPARATOR_CHAR ':'
  ------------------
  |  Branch (2573:21): [True: 0, False: 0]
  ------------------
 2574|      0|                    tmpdir = NULL;
 2575|      0|            } else {
 2576|      0|                if (asprintf(&tmpdir, "%s%c%s", dir, ENV_SEPARATOR_CHAR, olddir) < 0)
  ------------------
  |  |   70|      0|#define ENV_SEPARATOR_CHAR ':'
  ------------------
  |  Branch (2576:21): [True: 0, False: 0]
  ------------------
 2577|      0|                    tmpdir = NULL;
 2578|      0|            }
 2579|      0|            if (!tmpdir) {
  ------------------
  |  Branch (2579:17): [True: 0, False: 0]
  ------------------
 2580|      0|                DEBUGMSGTL(("read_config:initmib", "set mibdir malloc failed"));
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
 2581|      0|                return;
 2582|      0|            }
 2583|      0|            newdir = tmpdir;
 2584|      2|        } else {
 2585|      2|            newdir = dir;
 2586|      2|        }
 2587|      2|    } else {
 2588|       |        /** If dir starts with '+' skip '+' it. */
 2589|      0|        newdir = ((*dir == '+') ? ++dir : dir);
  ------------------
  |  Branch (2589:19): [True: 0, False: 0]
  ------------------
 2590|      0|    }
 2591|      2|    netsnmp_ds_set_string(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_MIBDIRS,
  ------------------
  |  |   48|      2|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
                  netsnmp_ds_set_string(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_MIBDIRS,
  ------------------
  |  |  162|      2|#define NETSNMP_DS_LIB_MIBDIRS           11
  ------------------
 2592|      2|                          newdir);
 2593|       |
 2594|       |    /** set_string calls strdup, so if we allocated memory, free it */
 2595|      2|    if (tmpdir == newdir) {
  ------------------
  |  Branch (2595:9): [True: 0, False: 2]
  ------------------
 2596|       |        SNMP_FREE(tmpdir);
  ------------------
  |  |   62|      0|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 0, False: 0]
  |  |  |  Branch (62:66): [Folded, False: 0]
  |  |  ------------------
  ------------------
 2597|      0|    }
 2598|      2|}
netsnmp_get_mib_directory:
 2615|      6|{
 2616|      6|    char *dir;
 2617|       |
 2618|      6|    DEBUGTRACE;
  ------------------
  |  |   63|      6|#define DEBUGTRACE         do {if (_DBG_IF_) {__DBGTRACE;} }while(0)
  |  |  ------------------
  |  |  |  |  144|      6|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 6]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGTRACE         do {if (_DBG_IF_) {__DBGTRACE;} }while(0)
  |  |  ------------------
  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  ------------------
  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  ------------------
  |  |  |  Branch (63:67): [Folded, False: 6]
  |  |  ------------------
  ------------------
 2619|      6|    dir = netsnmp_ds_get_string(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_MIBDIRS);
  ------------------
  |  |   48|      6|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
                  dir = netsnmp_ds_get_string(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_MIBDIRS);
  ------------------
  |  |  162|      6|#define NETSNMP_DS_LIB_MIBDIRS           11
  ------------------
 2620|      6|    if (dir == NULL) {
  ------------------
  |  Branch (2620:9): [True: 0, False: 6]
  ------------------
 2621|      0|        DEBUGMSGTL(("get_mib_directory", "no mib directories set\n"));
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
 2622|       |
 2623|       |        /** Check if the environment variable is set */
 2624|      0|        dir = netsnmp_getenv("MIBDIRS");
 2625|      0|        if (dir == NULL) {
  ------------------
  |  Branch (2625:13): [True: 0, False: 0]
  ------------------
 2626|      0|            DEBUGMSGTL(("get_mib_directory", "no mib directories set by environment\n"));
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
 2627|       |            /** Not set use hard coded path */
 2628|      0|            if (confmibdir == NULL) {
  ------------------
  |  Branch (2628:17): [True: 0, False: 0]
  ------------------
 2629|      0|                DEBUGMSGTL(("get_mib_directory", "no mib directories set by config\n"));
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
 2630|      0|                netsnmp_set_mib_directory(NETSNMP_DEFAULT_MIBDIRS);
  ------------------
  |  | 1669|      0|#define NETSNMP_DEFAULT_MIBDIRS "$HOME/.snmp/mibs:/usr/local/net-snmp-master/share/snmp/mibs"
  ------------------
 2631|      0|            }
 2632|      0|            else if ((*confmibdir == '+') || (*confmibdir == '-')) {
  ------------------
  |  Branch (2632:22): [True: 0, False: 0]
  |  Branch (2632:46): [True: 0, False: 0]
  ------------------
 2633|      0|                DEBUGMSGTL(("get_mib_directory", "mib directories set by config (but added)\n"));
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
 2634|      0|                netsnmp_set_mib_directory(NETSNMP_DEFAULT_MIBDIRS);
  ------------------
  |  | 1669|      0|#define NETSNMP_DEFAULT_MIBDIRS "$HOME/.snmp/mibs:/usr/local/net-snmp-master/share/snmp/mibs"
  ------------------
 2635|      0|                netsnmp_set_mib_directory(confmibdir);
 2636|      0|            }
 2637|      0|            else {
 2638|      0|                DEBUGMSGTL(("get_mib_directory", "mib directories set by config\n"));
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
 2639|      0|                netsnmp_set_mib_directory(confmibdir);
 2640|      0|            }
 2641|      0|        } else if ((*dir == '+') || (*dir == '-')) {
  ------------------
  |  Branch (2641:20): [True: 0, False: 0]
  |  Branch (2641:37): [True: 0, False: 0]
  ------------------
 2642|      0|            DEBUGMSGTL(("get_mib_directory", "mib directories set by environment (but added)\n"));
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
 2643|      0|            netsnmp_set_mib_directory(NETSNMP_DEFAULT_MIBDIRS);
  ------------------
  |  | 1669|      0|#define NETSNMP_DEFAULT_MIBDIRS "$HOME/.snmp/mibs:/usr/local/net-snmp-master/share/snmp/mibs"
  ------------------
 2644|      0|            netsnmp_set_mib_directory(dir);
 2645|      0|        } else {
 2646|      0|            DEBUGMSGTL(("get_mib_directory", "mib directories set by environment\n"));
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
 2647|      0|            netsnmp_set_mib_directory(dir);
 2648|      0|        }
 2649|      0|        dir = netsnmp_ds_get_string(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_MIBDIRS);
  ------------------
  |  |   48|      0|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
                      dir = netsnmp_ds_get_string(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_MIBDIRS);
  ------------------
  |  |  162|      0|#define NETSNMP_DS_LIB_MIBDIRS           11
  ------------------
 2650|      0|    }
 2651|      6|    DEBUGMSGTL(("get_mib_directory", "mib directories set '%s'\n", dir));
  ------------------
  |  |   66|      6|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      6|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 6]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 6]
  |  |  ------------------
  ------------------
 2652|      6|    return(dir);
 2653|      6|}
netsnmp_fixup_mib_directory:
 2662|      2|{
 2663|      2|    const char *homepath = netsnmp_gethomedir();
 2664|      2|    char *mibpath = netsnmp_get_mib_directory();
 2665|      2|    char *oldmibpath = NULL;
 2666|      2|    char *ptr_home;
 2667|      2|    char *new_mibpath;
 2668|      2|    size_t new_mibpath_len;
 2669|       |
 2670|      2|    DEBUGTRACE;
  ------------------
  |  |   63|      2|#define DEBUGTRACE         do {if (_DBG_IF_) {__DBGTRACE;} }while(0)
  |  |  ------------------
  |  |  |  |  144|      2|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 2]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGTRACE         do {if (_DBG_IF_) {__DBGTRACE;} }while(0)
  |  |  ------------------
  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  ------------------
  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  ------------------
  |  |  |  Branch (63:67): [Folded, False: 2]
  |  |  ------------------
  ------------------
 2671|      2|    if (homepath && mibpath) {
  ------------------
  |  Branch (2671:9): [True: 2, False: 0]
  |  Branch (2671:21): [True: 2, False: 0]
  ------------------
 2672|      2|        DEBUGMSGTL(("fixup_mib_directory", "mib directories '%s'\n", mibpath));
  ------------------
  |  |   66|      2|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      2|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 2]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 2]
  |  |  ------------------
  ------------------
 2673|      2|        while ((ptr_home = strstr(mibpath, "$HOME"))) {
  ------------------
  |  Branch (2673:16): [True: 0, False: 2]
  ------------------
 2674|      0|            new_mibpath_len = strlen(mibpath) - strlen("$HOME") +
 2675|      0|					 strlen(homepath)+1;
 2676|      0|            new_mibpath = (char *)malloc(new_mibpath_len);
 2677|      0|            if (new_mibpath) {
  ------------------
  |  Branch (2677:17): [True: 0, False: 0]
  ------------------
 2678|      0|                *ptr_home = 0; /* null out the spot where we stop copying */
 2679|      0|                snprintf(new_mibpath, new_mibpath_len, "%s%s%s", mibpath, homepath,
 2680|      0|			ptr_home + strlen("$HOME"));
 2681|       |                /** swap in the new value and repeat */
 2682|      0|                mibpath = new_mibpath;
 2683|      0|		if (oldmibpath != NULL) {
  ------------------
  |  Branch (2683:7): [True: 0, False: 0]
  ------------------
 2684|      0|		    SNMP_FREE(oldmibpath);
  ------------------
  |  |   62|      0|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 0, False: 0]
  |  |  |  Branch (62:66): [Folded, False: 0]
  |  |  ------------------
  ------------------
 2685|      0|		}
 2686|      0|		oldmibpath = new_mibpath;
 2687|      0|            } else {
 2688|      0|                break;
 2689|      0|            }
 2690|      0|        }
 2691|       |
 2692|      2|        netsnmp_set_mib_directory(mibpath);
 2693|       |	
 2694|       |	/*  The above copies the mibpath for us, so...  */
 2695|       |
 2696|      2|	if (oldmibpath != NULL) {
  ------------------
  |  Branch (2696:6): [True: 0, False: 2]
  ------------------
 2697|      0|	    SNMP_FREE(oldmibpath);
  ------------------
  |  |   62|      0|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 0, False: 0]
  |  |  |  Branch (62:66): [Folded, False: 0]
  |  |  ------------------
  ------------------
 2698|      0|	}
 2699|       |
 2700|      2|    }
 2701|       |
 2702|      2|}
netsnmp_init_mib:
 2711|      2|{
 2712|      2|    const char     *prefix;
 2713|      2|    char           *env_var, *entry;
 2714|      2|    PrefixListPtr   pp = &mib_prefixes[0];
 2715|      2|    char           *st = NULL;
 2716|       |
 2717|      2|    if (Mib)
  ------------------
  |  Branch (2717:9): [True: 0, False: 2]
  ------------------
 2718|      0|        return;
 2719|      2|    netsnmp_init_mib_internals();
 2720|       |
 2721|       |    /*
 2722|       |     * Initialise the MIB directory/ies 
 2723|       |     */
 2724|      2|    netsnmp_fixup_mib_directory();
 2725|      2|    env_var = strdup(netsnmp_get_mib_directory());
 2726|      2|    if (!env_var)
  ------------------
  |  Branch (2726:9): [True: 0, False: 2]
  ------------------
 2727|      0|        return;
 2728|       |
 2729|      2|    DEBUGMSGTL(("init_mib",
  ------------------
  |  |   66|      2|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      2|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 2]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 2]
  |  |  ------------------
  ------------------
 2730|      2|                "Seen MIBDIRS: Looking in '%s' for mib dirs ...\n",
 2731|      2|                env_var));
 2732|       |
 2733|      2|    entry = strtok_r(env_var, ENV_SEPARATOR, &st);
  ------------------
  |  |   67|      2|#define ENV_SEPARATOR ":"
  ------------------
 2734|      4|    while (entry) {
  ------------------
  |  Branch (2734:12): [True: 2, False: 2]
  ------------------
 2735|      2|        add_mibdir(entry);
 2736|      2|        entry = strtok_r(NULL, ENV_SEPARATOR, &st);
  ------------------
  |  |   67|      2|#define ENV_SEPARATOR ":"
  ------------------
 2737|      2|    }
 2738|      2|    SNMP_FREE(env_var);
  ------------------
  |  |   62|      2|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 2, False: 0]
  |  |  |  Branch (62:66): [Folded, False: 2]
  |  |  ------------------
  ------------------
 2739|       |
 2740|      2|    env_var = netsnmp_getenv("MIBFILES");
 2741|      2|    if (env_var != NULL) {
  ------------------
  |  Branch (2741:9): [True: 0, False: 2]
  ------------------
 2742|      0|        if (*env_var == '+')
  ------------------
  |  Branch (2742:13): [True: 0, False: 0]
  ------------------
 2743|      0|            entry = strtok_r(env_var+1, ENV_SEPARATOR, &st);
  ------------------
  |  |   67|      0|#define ENV_SEPARATOR ":"
  ------------------
 2744|      0|        else
 2745|      0|            entry = strtok_r(env_var, ENV_SEPARATOR, &st);
  ------------------
  |  |   67|      0|#define ENV_SEPARATOR ":"
  ------------------
 2746|      0|        while (entry) {
  ------------------
  |  Branch (2746:16): [True: 0, False: 0]
  ------------------
 2747|      0|            add_mibfile(entry, NULL);
 2748|      0|            entry = strtok_r(NULL, ENV_SEPARATOR, &st);
  ------------------
  |  |   67|      0|#define ENV_SEPARATOR ":"
  ------------------
 2749|      0|        }
 2750|      0|    }
 2751|       |
 2752|      2|    netsnmp_init_mib_internals();
 2753|       |
 2754|       |    /*
 2755|       |     * Read in any modules or mibs requested 
 2756|       |     */
 2757|       |
 2758|      2|    env_var = netsnmp_getenv("MIBS");
 2759|      2|    if (env_var == NULL) {
  ------------------
  |  Branch (2759:9): [True: 2, False: 0]
  ------------------
 2760|      2|        if (confmibs != NULL)
  ------------------
  |  Branch (2760:13): [True: 0, False: 2]
  ------------------
 2761|      0|            env_var = strdup(confmibs);
 2762|      2|        else
 2763|      2|            env_var = strdup(NETSNMP_DEFAULT_MIBS);
  ------------------
  |  | 2017|      2|#define NETSNMP_DEFAULT_MIBS ":NET-SNMP-EXTEND-MIB:SNMPv2-MIB:IF-MIB:IP-MIB:TCP-MIB:UDP-MIB:HOST-RESOURCES-MIB:NOTIFICATION-LOG-MIB:DISMAN-EVENT-MIB:DISMAN-SCHEDULE-MIB:NET-SNMP-PERIODIC-NOTIFY-MIB:DISMAN-NSLOOKUP-MIB:DISMAN-PING-MIB:DISMAN-TRACEROUTE-MIB:EtherLike-MIB:NET-SNMP-EXAMPLES-MIB:HOST-RESOURCES-TYPES:IP-FORWARD-MIB:MTA-MIB:NETWORK-SERVICES-MIB:UCD-IPFWACC-MIB:RMON-MIB:SCTP-MIB:SNMP-USM-DH-OBJECTS-MIB:SNMP-TLS-TM-MIB:SNMP-TSM-MIB:TUNNEL-MIB:IPV6-FLOW-LABEL-MIB:UCD-DISKIO-MIB:LM-SENSORS-MIB:UCD-SNMP-MIB:UCD-DEMO-MIB:SNMP-TARGET-MIB:NET-SNMP-AGENT-MIB:SNMP-NOTIFICATION-MIB:NET-SNMP-PASS-MIB:SNMP-FRAMEWORK-MIB:SNMP-MPD-MIB:SNMP-USER-BASED-SM-MIB:SNMP-VIEW-BASED-ACM-MIB:SNMP-COMMUNITY-MIB:IPV6-ICMP-MIB:IPV6-MIB:IPV6-TCP-MIB:IPV6-UDP-MIB:UCD-DLMOD-MIB:SNMPv2-TM:NET-SNMP-VACM-MIB"
  ------------------
 2764|      2|    } else {
 2765|      0|        env_var = strdup(env_var);
 2766|      0|    }
 2767|      2|    if (env_var && ((*env_var == '+') || (*env_var == '-'))) {
  ------------------
  |  Branch (2767:9): [True: 2, False: 0]
  |  Branch (2767:21): [True: 0, False: 2]
  |  Branch (2767:42): [True: 0, False: 2]
  ------------------
 2768|      0|        int res;
 2769|       |
 2770|      0|        if (*env_var == '+')
  ------------------
  |  Branch (2770:13): [True: 0, False: 0]
  ------------------
 2771|      0|            res = asprintf(&entry, "%s%c%s", NETSNMP_DEFAULT_MIBS,
  ------------------
  |  | 2017|      0|#define NETSNMP_DEFAULT_MIBS ":NET-SNMP-EXTEND-MIB:SNMPv2-MIB:IF-MIB:IP-MIB:TCP-MIB:UDP-MIB:HOST-RESOURCES-MIB:NOTIFICATION-LOG-MIB:DISMAN-EVENT-MIB:DISMAN-SCHEDULE-MIB:NET-SNMP-PERIODIC-NOTIFY-MIB:DISMAN-NSLOOKUP-MIB:DISMAN-PING-MIB:DISMAN-TRACEROUTE-MIB:EtherLike-MIB:NET-SNMP-EXAMPLES-MIB:HOST-RESOURCES-TYPES:IP-FORWARD-MIB:MTA-MIB:NETWORK-SERVICES-MIB:UCD-IPFWACC-MIB:RMON-MIB:SCTP-MIB:SNMP-USM-DH-OBJECTS-MIB:SNMP-TLS-TM-MIB:SNMP-TSM-MIB:TUNNEL-MIB:IPV6-FLOW-LABEL-MIB:UCD-DISKIO-MIB:LM-SENSORS-MIB:UCD-SNMP-MIB:UCD-DEMO-MIB:SNMP-TARGET-MIB:NET-SNMP-AGENT-MIB:SNMP-NOTIFICATION-MIB:NET-SNMP-PASS-MIB:SNMP-FRAMEWORK-MIB:SNMP-MPD-MIB:SNMP-USER-BASED-SM-MIB:SNMP-VIEW-BASED-ACM-MIB:SNMP-COMMUNITY-MIB:IPV6-ICMP-MIB:IPV6-MIB:IPV6-TCP-MIB:IPV6-UDP-MIB:UCD-DLMOD-MIB:SNMPv2-TM:NET-SNMP-VACM-MIB"
  ------------------
 2772|      0|                           ENV_SEPARATOR_CHAR, env_var + 1);
  ------------------
  |  |   70|      0|#define ENV_SEPARATOR_CHAR ':'
  ------------------
 2773|      0|        else
 2774|      0|            res = asprintf(&entry, "%s%c%s", env_var + 1, ENV_SEPARATOR_CHAR,
  ------------------
  |  |   70|      0|#define ENV_SEPARATOR_CHAR ':'
  ------------------
 2775|      0|                           NETSNMP_DEFAULT_MIBS);
  ------------------
  |  | 2017|      0|#define NETSNMP_DEFAULT_MIBS ":NET-SNMP-EXTEND-MIB:SNMPv2-MIB:IF-MIB:IP-MIB:TCP-MIB:UDP-MIB:HOST-RESOURCES-MIB:NOTIFICATION-LOG-MIB:DISMAN-EVENT-MIB:DISMAN-SCHEDULE-MIB:NET-SNMP-PERIODIC-NOTIFY-MIB:DISMAN-NSLOOKUP-MIB:DISMAN-PING-MIB:DISMAN-TRACEROUTE-MIB:EtherLike-MIB:NET-SNMP-EXAMPLES-MIB:HOST-RESOURCES-TYPES:IP-FORWARD-MIB:MTA-MIB:NETWORK-SERVICES-MIB:UCD-IPFWACC-MIB:RMON-MIB:SCTP-MIB:SNMP-USM-DH-OBJECTS-MIB:SNMP-TLS-TM-MIB:SNMP-TSM-MIB:TUNNEL-MIB:IPV6-FLOW-LABEL-MIB:UCD-DISKIO-MIB:LM-SENSORS-MIB:UCD-SNMP-MIB:UCD-DEMO-MIB:SNMP-TARGET-MIB:NET-SNMP-AGENT-MIB:SNMP-NOTIFICATION-MIB:NET-SNMP-PASS-MIB:SNMP-FRAMEWORK-MIB:SNMP-MPD-MIB:SNMP-USER-BASED-SM-MIB:SNMP-VIEW-BASED-ACM-MIB:SNMP-COMMUNITY-MIB:IPV6-ICMP-MIB:IPV6-MIB:IPV6-TCP-MIB:IPV6-UDP-MIB:UCD-DLMOD-MIB:SNMPv2-TM:NET-SNMP-VACM-MIB"
  ------------------
 2776|      0|        SNMP_FREE(env_var);
  ------------------
  |  |   62|      0|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 0, False: 0]
  |  |  |  Branch (62:66): [Folded, False: 0]
  |  |  ------------------
  ------------------
 2777|      0|        if (res < 0) {
  ------------------
  |  Branch (2777:13): [True: 0, False: 0]
  ------------------
 2778|      0|            DEBUGMSGTL(("init_mib", "env mibs malloc failed"));
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
 2779|      0|            return;
 2780|      0|        }
 2781|      0|        env_var = entry;
 2782|      0|    }
 2783|       |
 2784|      2|    if (env_var != NULL) {
  ------------------
  |  Branch (2784:9): [True: 2, False: 0]
  ------------------
 2785|      2|        DEBUGMSGTL(("init_mib",
  ------------------
  |  |   66|      2|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      2|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 2]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 2]
  |  |  ------------------
  ------------------
 2786|      2|                    "Seen MIBS: Looking in '%s' for mib files ...\n",
 2787|      2|                    env_var));
 2788|      2|        entry = strtok_r(env_var, ENV_SEPARATOR, &st);
  ------------------
  |  |   67|      2|#define ENV_SEPARATOR ":"
  ------------------
 2789|     98|        while (entry) {
  ------------------
  |  Branch (2789:16): [True: 96, False: 2]
  ------------------
 2790|     96|            if (strcasecmp(entry, DEBUG_ALWAYS_TOKEN) == 0) {
  ------------------
  |  |  227|     96|#define DEBUG_ALWAYS_TOKEN "all"
  ------------------
  |  Branch (2790:17): [True: 0, False: 96]
  ------------------
 2791|      0|                read_all_mibs();
 2792|     96|            } else if (strstr(entry, "/") != NULL) {
  ------------------
  |  Branch (2792:24): [True: 0, False: 96]
  ------------------
 2793|      0|                read_mib(entry);
 2794|     96|            } else {
 2795|     96|                netsnmp_read_module(entry);
 2796|     96|            }
 2797|     96|            entry = strtok_r(NULL, ENV_SEPARATOR, &st);
  ------------------
  |  |   67|     96|#define ENV_SEPARATOR ":"
  ------------------
 2798|     96|        }
 2799|      2|        adopt_orphans();
 2800|      2|        SNMP_FREE(env_var);
  ------------------
  |  |   62|      2|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 2, False: 0]
  |  |  |  Branch (62:66): [Folded, False: 2]
  |  |  ------------------
  ------------------
 2801|      2|    }
 2802|       |
 2803|      2|    env_var = netsnmp_getenv("MIBFILES");
 2804|      2|    if (env_var != NULL) {
  ------------------
  |  Branch (2804:9): [True: 0, False: 2]
  ------------------
 2805|      0|        if ((*env_var == '+') || (*env_var == '-')) {
  ------------------
  |  Branch (2805:13): [True: 0, False: 0]
  |  Branch (2805:34): [True: 0, False: 0]
  ------------------
 2806|       |#ifdef NETSNMP_DEFAULT_MIBFILES
 2807|       |            int res;
 2808|       |
 2809|       |            if (*env_var++ == '+')
 2810|       |                res = asprintf(&entry, "%s%c%s", NETSNMP_DEFAULT_MIBFILES,
 2811|       |                               ENV_SEPARATOR_CHAR, env_var);
 2812|       |            else
 2813|       |                res = asprintf(&entry, "%s%c%s", env_var,
 2814|       |                               ENV_SEPARATOR_CHAR, NETSNMP_DEFAULT_MIBFILES);
 2815|       |            if (res >= 0)
 2816|       |                env_var = entry;
 2817|       |            else
 2818|       |                DEBUGMSGTL(("init_mib", "env mibfiles malloc failed"));
 2819|       |#else
 2820|      0|            env_var = strdup(env_var + 1);
 2821|      0|#endif
 2822|      0|        } else {
 2823|      0|            env_var = strdup(env_var);
 2824|      0|        }
 2825|      2|    } else {
 2826|       |#ifdef NETSNMP_DEFAULT_MIBFILES
 2827|       |        env_var = strdup(NETSNMP_DEFAULT_MIBFILES);
 2828|       |#endif
 2829|      2|    }
 2830|       |
 2831|      2|    if (env_var != NULL) {
  ------------------
  |  Branch (2831:9): [True: 0, False: 2]
  ------------------
 2832|      0|        DEBUGMSGTL(("init_mib",
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
 2833|      0|                    "Seen MIBFILES: Looking in '%s' for mib files ...\n",
 2834|      0|                    env_var));
 2835|      0|        entry = strtok_r(env_var, ENV_SEPARATOR, &st);
  ------------------
  |  |   67|      0|#define ENV_SEPARATOR ":"
  ------------------
 2836|      0|        while (entry) {
  ------------------
  |  Branch (2836:16): [True: 0, False: 0]
  ------------------
 2837|      0|            read_mib(entry);
 2838|      0|            entry = strtok_r(NULL, ENV_SEPARATOR, &st);
  ------------------
  |  |   67|      0|#define ENV_SEPARATOR ":"
  ------------------
 2839|      0|        }
 2840|      0|        SNMP_FREE(env_var);
  ------------------
  |  |   62|      0|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 0, False: 0]
  |  |  |  Branch (62:66): [Folded, False: 0]
  |  |  ------------------
  ------------------
 2841|      0|    }
 2842|       |
 2843|      2|    prefix = netsnmp_getenv("PREFIX");
 2844|       |
 2845|      2|    if (!prefix)
  ------------------
  |  Branch (2845:9): [True: 2, False: 0]
  ------------------
 2846|      2|        prefix = Standard_Prefix;
 2847|       |
 2848|      2|    Prefix = (char *) malloc(strlen(prefix) + 2);
 2849|      2|    if (!Prefix)
  ------------------
  |  Branch (2849:9): [True: 0, False: 2]
  ------------------
 2850|      0|        DEBUGMSGTL(("init_mib", "Prefix malloc failed"));
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
 2851|      2|    else
 2852|      2|        strcpy(Prefix, prefix);
 2853|       |
 2854|      2|    DEBUGMSGTL(("init_mib",
  ------------------
  |  |   66|      2|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      2|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 2]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 2]
  |  |  ------------------
  ------------------
 2855|      2|                "Seen PREFIX: Looking in '%s' for prefix ...\n", Prefix));
 2856|       |
 2857|       |    /*
 2858|       |     * remove trailing dot 
 2859|       |     */
 2860|      2|    if (Prefix) {
  ------------------
  |  Branch (2860:9): [True: 2, False: 0]
  ------------------
 2861|      2|        env_var = &Prefix[strlen(Prefix) - 1];
 2862|      2|        if (*env_var == '.')
  ------------------
  |  Branch (2862:13): [True: 0, False: 2]
  ------------------
 2863|      0|            *env_var = '\0';
 2864|      2|    }
 2865|       |
 2866|      2|    pp->str = Prefix;           /* fixup first mib_prefix entry */
 2867|       |    /*
 2868|       |     * now that the list of prefixes is built, save each string length. 
 2869|       |     */
 2870|     14|    while (pp->str) {
  ------------------
  |  Branch (2870:12): [True: 12, False: 2]
  ------------------
 2871|     12|        pp->len = strlen(pp->str);
 2872|     12|        pp++;
 2873|     12|    }
 2874|       |
 2875|      2|    Mib = tree_head;            /* Backwards compatibility */
 2876|      2|    tree_top = calloc(1, sizeof(struct tree));
 2877|       |    /*
 2878|       |     * XX error check ? 
 2879|       |     */
 2880|      2|    if (tree_top) {
  ------------------
  |  Branch (2880:9): [True: 2, False: 0]
  ------------------
 2881|      2|        tree_top->label = strdup("(top)");
 2882|      2|        tree_top->child_list = tree_head;
 2883|      2|    }
 2884|      2|}
set_function:
 2947|      6|{
 2948|      6|    subtree->printer = NULL;
 2949|      6|    switch (subtree->type) {
 2950|      0|    case TYPE_OBJID:
  ------------------
  |  |  155|      0|#define TYPE_OBJID          1
  ------------------
  |  Branch (2950:5): [True: 0, False: 6]
  ------------------
 2951|      0|        subtree->printomat = sprint_realloc_object_identifier;
 2952|      0|        break;
 2953|      0|    case TYPE_OCTETSTR:
  ------------------
  |  |  156|      0|#define TYPE_OCTETSTR       2
  ------------------
  |  Branch (2953:5): [True: 0, False: 6]
  ------------------
 2954|      0|        subtree->printomat = sprint_realloc_octet_string;
 2955|      0|        break;
 2956|      0|    case TYPE_INTEGER:
  ------------------
  |  |  157|      0|#define TYPE_INTEGER        3
  ------------------
  |  Branch (2956:5): [True: 0, False: 6]
  ------------------
 2957|      0|        subtree->printomat = sprint_realloc_integer;
 2958|      0|        break;
 2959|      0|    case TYPE_INTEGER32:
  ------------------
  |  |  170|      0|#define TYPE_INTEGER32      16
  ------------------
  |  Branch (2959:5): [True: 0, False: 6]
  ------------------
 2960|      0|        subtree->printomat = sprint_realloc_integer;
 2961|      0|        break;
 2962|      0|    case TYPE_NETADDR:
  ------------------
  |  |  158|      0|#define TYPE_NETADDR        4
  ------------------
  |  Branch (2962:5): [True: 0, False: 6]
  ------------------
 2963|      0|        subtree->printomat = sprint_realloc_networkaddress;
 2964|      0|        break;
 2965|      0|    case TYPE_IPADDR:
  ------------------
  |  |  159|      0|#define TYPE_IPADDR         5
  ------------------
  |  Branch (2965:5): [True: 0, False: 6]
  ------------------
 2966|      0|        subtree->printomat = sprint_realloc_ipaddress;
 2967|      0|        break;
 2968|      0|    case TYPE_COUNTER:
  ------------------
  |  |  160|      0|#define TYPE_COUNTER        6
  ------------------
  |  Branch (2968:5): [True: 0, False: 6]
  ------------------
 2969|      0|        subtree->printomat = sprint_realloc_counter;
 2970|      0|        break;
 2971|      0|    case TYPE_GAUGE:
  ------------------
  |  |  161|      0|#define TYPE_GAUGE          7
  ------------------
  |  Branch (2971:5): [True: 0, False: 6]
  ------------------
 2972|      0|        subtree->printomat = sprint_realloc_gauge;
 2973|      0|        break;
 2974|      0|    case TYPE_TIMETICKS:
  ------------------
  |  |  162|      0|#define TYPE_TIMETICKS      8
  ------------------
  |  Branch (2974:5): [True: 0, False: 6]
  ------------------
 2975|      0|        subtree->printomat = sprint_realloc_timeticks;
 2976|      0|        break;
 2977|      0|    case TYPE_OPAQUE:
  ------------------
  |  |  163|      0|#define TYPE_OPAQUE         9
  ------------------
  |  Branch (2977:5): [True: 0, False: 6]
  ------------------
 2978|      0|        subtree->printomat = sprint_realloc_opaque;
 2979|      0|        break;
 2980|      0|    case TYPE_NULL:
  ------------------
  |  |  164|      0|#define TYPE_NULL           10
  ------------------
  |  Branch (2980:5): [True: 0, False: 6]
  ------------------
 2981|      0|        subtree->printomat = sprint_realloc_null;
 2982|      0|        break;
 2983|      0|    case TYPE_BITSTRING:
  ------------------
  |  |  166|      0|#define TYPE_BITSTRING      12
  ------------------
  |  Branch (2983:5): [True: 0, False: 6]
  ------------------
 2984|      0|        subtree->printomat = sprint_realloc_bitstring;
 2985|      0|        break;
 2986|      0|    case TYPE_NSAPADDRESS:
  ------------------
  |  |  167|      0|#define TYPE_NSAPADDRESS    13
  ------------------
  |  Branch (2986:5): [True: 0, False: 6]
  ------------------
 2987|      0|        subtree->printomat = sprint_realloc_nsapaddress;
 2988|      0|        break;
 2989|      0|    case TYPE_COUNTER64:
  ------------------
  |  |  165|      0|#define TYPE_COUNTER64      11
  ------------------
  |  Branch (2989:5): [True: 0, False: 6]
  ------------------
 2990|      0|        subtree->printomat = sprint_realloc_counter64;
 2991|      0|        break;
 2992|      0|    case TYPE_UINTEGER:
  ------------------
  |  |  168|      0|#define TYPE_UINTEGER       14
  ------------------
  |  Branch (2992:5): [True: 0, False: 6]
  ------------------
 2993|      0|        subtree->printomat = sprint_realloc_uinteger;
 2994|      0|        break;
 2995|      0|    case TYPE_UNSIGNED32:
  ------------------
  |  |  169|      0|#define TYPE_UNSIGNED32     15
  ------------------
  |  Branch (2995:5): [True: 0, False: 6]
  ------------------
 2996|      0|        subtree->printomat = sprint_realloc_gauge;
 2997|      0|        break;
 2998|      6|    case TYPE_OTHER:
  ------------------
  |  |  154|      6|#define TYPE_OTHER          0
  ------------------
  |  Branch (2998:5): [True: 6, False: 0]
  ------------------
 2999|      6|    default:
  ------------------
  |  Branch (2999:5): [True: 0, False: 6]
  ------------------
 3000|      6|        subtree->printomat = sprint_realloc_by_type;
 3001|      6|        break;
 3002|      6|    }
 3003|      6|}

netsnmp_init_mib_internals:
  703|    102|{
  704|    102|    register struct tok *tp;
  705|    102|    register int    b, i;
  706|    102|    int             max_modc;
  707|       |
  708|    102|    if (tree_head)
  ------------------
  |  Branch (708:9): [True: 100, False: 2]
  ------------------
  709|    100|        return;
  710|       |
  711|       |    /*
  712|       |     * Set up hash list of pre-defined tokens
  713|       |     */
  714|      2|    memset(buckets, 0, sizeof(buckets));
  715|    186|    for (tp = tokens; tp->name; tp++) {
  ------------------
  |  Branch (715:23): [True: 184, False: 2]
  ------------------
  716|    184|        tp->hash = name_hash(tp->name);
  717|    184|        b = BUCKET(tp->hash);
  ------------------
  |  |  527|    184|#define BUCKET(x)       (x & (HASHSIZE-1))
  |  |  ------------------
  |  |  |  |  526|    184|#define HASHSIZE        32
  |  |  ------------------
  ------------------
  718|    184|        if (buckets[b])
  ------------------
  |  Branch (718:13): [True: 120, False: 64]
  ------------------
  719|    120|            tp->next = buckets[b];      /* BUG ??? */
  720|    184|        buckets[b] = tp;
  721|    184|    }
  722|       |
  723|       |    /*
  724|       |     * Initialise other internal structures
  725|       |     */
  726|       |
  727|      2|    max_modc = sizeof(module_map) / sizeof(module_map[0]) - 1;
  728|     44|    for (i = 0; i < max_modc; ++i)
  ------------------
  |  Branch (728:17): [True: 42, False: 2]
  ------------------
  729|     42|        module_map[i].next = &(module_map[i + 1]);
  730|      2|    module_map[max_modc].next = NULL;
  731|      2|    module_map_head = module_map;
  732|       |
  733|      2|    memset(nbuckets, 0, sizeof(nbuckets));
  734|      2|    memset(tbuckets, 0, sizeof(tbuckets));
  735|      2|    free(tclist);
  736|      2|    tc_alloc = TC_INCR;
  ------------------
  |  |  134|      2|#define TC_INCR 100
  ------------------
  737|      2|    tclist = calloc(tc_alloc, sizeof(struct tc));
  738|      2|    build_translation_table();
  739|      2|    init_tree_roots();          /* Set up initial roots */
  740|       |    /*
  741|       |     * Relies on 'add_mibdir' having set up the modules 
  742|       |     */
  743|      2|}
which_module:
 4125|      6|{
 4126|      6|    struct module  *mp;
 4127|       |
 4128|      6|    for (mp = module_head; mp; mp = mp->next)
  ------------------
  |  Branch (4128:28): [True: 0, False: 6]
  ------------------
 4129|      0|        if (!label_compare(mp->name, name))
  ------------------
  |  | 1240|      0|#define	label_compare	strcmp
  ------------------
  |  Branch (4129:13): [True: 0, False: 0]
  ------------------
 4130|      0|            return (mp->modid);
 4131|       |
 4132|      6|    DEBUGMSGTL(("parse-mibs", "Module %s not found\n", name));
  ------------------
  |  |   66|      6|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      6|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 6]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 6]
  |  |  ------------------
  ------------------
 4133|      6|    return (-1);
 4134|      6|}
adopt_orphans:
 4323|      2|{
 4324|      2|    struct node    *np = NULL, *onp;
 4325|      2|    struct tree    *tp;
 4326|      2|    int             i, adopted = 1;
 4327|       |
 4328|      2|    if (!orphan_nodes)
  ------------------
  |  Branch (4328:9): [True: 2, False: 0]
  ------------------
 4329|      2|        return;
 4330|      0|    init_node_hash(orphan_nodes);
 4331|      0|    orphan_nodes = NULL;
 4332|       |
 4333|      0|    while (adopted) {
  ------------------
  |  Branch (4333:12): [True: 0, False: 0]
  ------------------
 4334|      0|        adopted = 0;
 4335|      0|        for (i = 0; i < NHASHSIZE; i++)
  ------------------
  |  |  529|      0|#define NHASHSIZE    128
  ------------------
  |  Branch (4335:21): [True: 0, False: 0]
  ------------------
 4336|      0|            if (nbuckets[i]) {
  ------------------
  |  Branch (4336:17): [True: 0, False: 0]
  ------------------
 4337|      0|                for (np = nbuckets[i]; np != NULL; np = np->next) {
  ------------------
  |  Branch (4337:40): [True: 0, False: 0]
  ------------------
 4338|      0|                    tp = find_tree_node(np->parent, -1);
 4339|      0|		    if (tp) {
  ------------------
  |  Branch (4339:11): [True: 0, False: 0]
  ------------------
 4340|      0|			do_subtree(tp, &np);
 4341|      0|			adopted = 1;
 4342|       |                        /*
 4343|       |                         * if do_subtree adopted the entire bucket, stop
 4344|       |                         */
 4345|      0|                        if(NULL == nbuckets[i])
  ------------------
  |  Branch (4345:28): [True: 0, False: 0]
  ------------------
 4346|      0|                            break;
 4347|       |
 4348|       |                        /*
 4349|       |                         * do_subtree may modify nbuckets, and if np
 4350|       |                         * was adopted, np->next probably isn't an orphan
 4351|       |                         * anymore. if np is still in the bucket (do_subtree
 4352|       |                         * didn't adopt it) keep on plugging. otherwise
 4353|       |                         * start over, at the top of the bucket.
 4354|       |                         */
 4355|      0|                        for(onp = nbuckets[i]; onp; onp = onp->next)
  ------------------
  |  Branch (4355:48): [True: 0, False: 0]
  ------------------
 4356|      0|                            if(onp == np)
  ------------------
  |  Branch (4356:32): [True: 0, False: 0]
  ------------------
 4357|      0|                                break;
 4358|      0|                        if(NULL == onp) { /* not in the list */
  ------------------
  |  Branch (4358:28): [True: 0, False: 0]
  ------------------
 4359|      0|                            np = nbuckets[i]; /* start over */
 4360|      0|                        }
 4361|      0|		    }
 4362|      0|		}
 4363|      0|            }
 4364|      0|    }
 4365|       |
 4366|       |    /*
 4367|       |     * Report on outstanding orphans
 4368|       |     *    and link them back into the orphan list
 4369|       |     */
 4370|      0|    for (i = 0; i < NHASHSIZE; i++)
  ------------------
  |  |  529|      0|#define NHASHSIZE    128
  ------------------
  |  Branch (4370:17): [True: 0, False: 0]
  ------------------
 4371|      0|        if (nbuckets[i]) {
  ------------------
  |  Branch (4371:13): [True: 0, False: 0]
  ------------------
 4372|      0|            if (orphan_nodes)
  ------------------
  |  Branch (4372:17): [True: 0, False: 0]
  ------------------
 4373|      0|                onp = np->next = nbuckets[i];
 4374|      0|            else
 4375|      0|                onp = orphan_nodes = nbuckets[i];
 4376|      0|            nbuckets[i] = NULL;
 4377|      0|            while (onp) {
  ------------------
  |  Branch (4377:20): [True: 0, False: 0]
  ------------------
 4378|      0|                char            modbuf[256];
 4379|      0|                snmp_log(LOG_WARNING,
 4380|      0|                         "Cannot resolve OID in %s: %s ::= { %s %ld } at line %d in %s\n",
 4381|      0|                         module_name(onp->modid, modbuf),
 4382|      0|                         (onp->label ? onp->label : "<no label>"),
  ------------------
  |  Branch (4382:27): [True: 0, False: 0]
  ------------------
 4383|      0|                         (onp->parent ? onp->parent : "<no parent>"),
  ------------------
  |  Branch (4383:27): [True: 0, False: 0]
  ------------------
 4384|      0|                         onp->subid, onp->lineno, onp->filename);
 4385|      0|                np = onp;
 4386|      0|                onp = onp->next;
 4387|      0|            }
 4388|      0|        }
 4389|      0|}
netsnmp_read_module:
 4401|     96|{
 4402|     96|    int status = 0;
 4403|     96|    status = read_module_internal(name);
 4404|       |
 4405|     96|    if (status == MODULE_NOT_FOUND) {
  ------------------
  |  |  513|     96|#define MODULE_NOT_FOUND	0
  ------------------
  |  Branch (4405:9): [True: 96, False: 0]
  ------------------
 4406|     96|        if (!read_module_replacements(name))
  ------------------
  |  Branch (4406:13): [True: 96, False: 0]
  ------------------
 4407|     96|            print_module_not_found(name);
 4408|     96|    } else if (status == MODULE_SYNTAX_ERROR) {
  ------------------
  |  |  520|      0|#define MODULE_SYNTAX_ERROR     4
  ------------------
  |  Branch (4408:16): [True: 0, False: 0]
  ------------------
 4409|      0|        gMibError = 0;
 4410|      0|        gLoop = 1;
 4411|       |
 4412|      0|        strncat(gMibNames, " ", sizeof(gMibNames) - strlen(gMibNames) - 1);
 4413|      0|        strncat(gMibNames, name, sizeof(gMibNames) - strlen(gMibNames) - 1);
 4414|      0|    }
 4415|       |
 4416|     96|    return tree_head;
 4417|     96|}
add_mibdir:
 5581|      2|{
 5582|      2|    const char     *oldFile = File;
 5583|      2|    int             oldLine = mibLine;
 5584|      2|    char          **filenames;
 5585|      2|    int             count = 0;
 5586|      2|    int             filename_count, i;
 5587|       |
 5588|      2|    DEBUGMSGTL(("parse-mibs", "Scanning directory %s\n", dirname));
  ------------------
  |  |   66|      2|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      2|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 2]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 2]
  |  |  ------------------
  ------------------
 5589|       |
 5590|      2|    filename_count = scan_directory(&filenames, dirname);
 5591|       |
 5592|      2|    if (filename_count >= 0) {
  ------------------
  |  Branch (5592:9): [True: 0, False: 2]
  ------------------
 5593|      0|        for (i = 0; i < filename_count; i++) {
  ------------------
  |  Branch (5593:21): [True: 0, False: 0]
  ------------------
 5594|      0|            if (add_mibfile(filenames[i], strrchr(filenames[i], '/')) == 0)
  ------------------
  |  Branch (5594:17): [True: 0, False: 0]
  ------------------
 5595|      0|                count++;
 5596|      0|	    free(filenames[i]);
 5597|      0|        }
 5598|      0|        File = oldFile;
 5599|      0|        mibLine = oldLine;
 5600|      0|        free(filenames);
 5601|      0|        return (count);
 5602|      0|    }
 5603|      2|    else
 5604|      2|        DEBUGMSGTL(("parse-mibs","cannot open MIB directory %s\n", dirname));
  ------------------
  |  |   66|      2|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      2|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 2]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 2]
  |  |  ------------------
  ------------------
 5605|       |
 5606|      2|    return (-1);
 5607|      2|}
parse.c:name_hash:
  690|    190|{
  691|    190|    int             hash = 0;
  692|    190|    const char     *cp;
  693|       |
  694|    190|    if (!name)
  ------------------
  |  Branch (694:9): [True: 0, False: 190]
  ------------------
  695|      0|        return 0;
  696|  2.00k|    for (cp = name; *cp; cp++)
  ------------------
  |  Branch (696:21): [True: 1.81k, False: 190]
  ------------------
  697|  1.81k|        hash += tolower((unsigned char)(*cp));
  ------------------
  |  Branch (697:17): [True: 0, False: 0]
  |  Branch (697:17): [True: 0, False: 0]
  |  Branch (697:17): [Folded, False: 1.81k]
  ------------------
  698|    190|    return (hash);
  699|    190|}
parse.c:build_translation_table:
 1075|      2|{
 1076|      2|    int             count;
 1077|       |
 1078|    514|    for (count = 0; count < 256; count++) {
  ------------------
  |  Branch (1078:21): [True: 512, False: 2]
  ------------------
 1079|    512|        switch (count) {
 1080|      2|        case OBJID:
  ------------------
  |  |  167|      2|#define OBJID       (4 | SYNTAX_MASK)
  |  |  ------------------
  |  |  |  |  157|      2|#define SYNTAX_MASK     0x80
  |  |  ------------------
  ------------------
  |  Branch (1080:9): [True: 2, False: 510]
  ------------------
 1081|      2|            translation_table[count] = TYPE_OBJID;
  ------------------
  |  |  155|      2|#define TYPE_OBJID          1
  ------------------
 1082|      2|            break;
 1083|      2|        case OCTETSTR:
  ------------------
  |  |  168|      2|#define OCTETSTR    (5 | SYNTAX_MASK)
  |  |  ------------------
  |  |  |  |  157|      2|#define SYNTAX_MASK     0x80
  |  |  ------------------
  ------------------
  |  Branch (1083:9): [True: 2, False: 510]
  ------------------
 1084|      2|            translation_table[count] = TYPE_OCTETSTR;
  ------------------
  |  |  156|      2|#define TYPE_OCTETSTR       2
  ------------------
 1085|      2|            break;
 1086|      2|        case INTEGER:
  ------------------
  |  |  169|      2|#define INTEGER     (6 | SYNTAX_MASK)
  |  |  ------------------
  |  |  |  |  157|      2|#define SYNTAX_MASK     0x80
  |  |  ------------------
  ------------------
  |  Branch (1086:9): [True: 2, False: 510]
  ------------------
 1087|      2|            translation_table[count] = TYPE_INTEGER;
  ------------------
  |  |  157|      2|#define TYPE_INTEGER        3
  ------------------
 1088|      2|            break;
 1089|      2|        case NETADDR:
  ------------------
  |  |  170|      2|#define NETADDR     (7 | SYNTAX_MASK)
  |  |  ------------------
  |  |  |  |  157|      2|#define SYNTAX_MASK     0x80
  |  |  ------------------
  ------------------
  |  Branch (1089:9): [True: 2, False: 510]
  ------------------
 1090|      2|            translation_table[count] = TYPE_NETADDR;
  ------------------
  |  |  158|      2|#define TYPE_NETADDR        4
  ------------------
 1091|      2|            break;
 1092|      2|        case IPADDR:
  ------------------
  |  |  171|      2|#define IPADDR      (8 | SYNTAX_MASK)
  |  |  ------------------
  |  |  |  |  157|      2|#define SYNTAX_MASK     0x80
  |  |  ------------------
  ------------------
  |  Branch (1092:9): [True: 2, False: 510]
  ------------------
 1093|      2|            translation_table[count] = TYPE_IPADDR;
  ------------------
  |  |  159|      2|#define TYPE_IPADDR         5
  ------------------
 1094|      2|            break;
 1095|      2|        case COUNTER:
  ------------------
  |  |  172|      2|#define COUNTER     (9 | SYNTAX_MASK)
  |  |  ------------------
  |  |  |  |  157|      2|#define SYNTAX_MASK     0x80
  |  |  ------------------
  ------------------
  |  Branch (1095:9): [True: 2, False: 510]
  ------------------
 1096|      2|            translation_table[count] = TYPE_COUNTER;
  ------------------
  |  |  160|      2|#define TYPE_COUNTER        6
  ------------------
 1097|      2|            break;
 1098|      2|        case GAUGE:
  ------------------
  |  |  173|      2|#define GAUGE       (10 | SYNTAX_MASK)
  |  |  ------------------
  |  |  |  |  157|      2|#define SYNTAX_MASK     0x80
  |  |  ------------------
  ------------------
  |  Branch (1098:9): [True: 2, False: 510]
  ------------------
 1099|      2|            translation_table[count] = TYPE_GAUGE;
  ------------------
  |  |  161|      2|#define TYPE_GAUGE          7
  ------------------
 1100|      2|            break;
 1101|      2|        case TIMETICKS:
  ------------------
  |  |  174|      2|#define TIMETICKS   (11 | SYNTAX_MASK)
  |  |  ------------------
  |  |  |  |  157|      2|#define SYNTAX_MASK     0x80
  |  |  ------------------
  ------------------
  |  Branch (1101:9): [True: 2, False: 510]
  ------------------
 1102|      2|            translation_table[count] = TYPE_TIMETICKS;
  ------------------
  |  |  162|      2|#define TYPE_TIMETICKS      8
  ------------------
 1103|      2|            break;
 1104|      2|        case KW_OPAQUE:
  ------------------
  |  |  175|      2|#define KW_OPAQUE   (12 | SYNTAX_MASK)
  |  |  ------------------
  |  |  |  |  157|      2|#define SYNTAX_MASK     0x80
  |  |  ------------------
  ------------------
  |  Branch (1104:9): [True: 2, False: 510]
  ------------------
 1105|      2|            translation_table[count] = TYPE_OPAQUE;
  ------------------
  |  |  163|      2|#define TYPE_OPAQUE         9
  ------------------
 1106|      2|            break;
 1107|      2|        case NUL:
  ------------------
  |  |  176|      2|#define NUL         (13 | SYNTAX_MASK)
  |  |  ------------------
  |  |  |  |  157|      2|#define SYNTAX_MASK     0x80
  |  |  ------------------
  ------------------
  |  Branch (1107:9): [True: 2, False: 510]
  ------------------
 1108|      2|            translation_table[count] = TYPE_NULL;
  ------------------
  |  |  164|      2|#define TYPE_NULL           10
  ------------------
 1109|      2|            break;
 1110|      2|        case COUNTER64:
  ------------------
  |  |  211|      2|#define COUNTER64   (43 | SYNTAX_MASK)
  |  |  ------------------
  |  |  |  |  157|      2|#define SYNTAX_MASK     0x80
  |  |  ------------------
  ------------------
  |  Branch (1110:9): [True: 2, False: 510]
  ------------------
 1111|      2|            translation_table[count] = TYPE_COUNTER64;
  ------------------
  |  |  165|      2|#define TYPE_COUNTER64      11
  ------------------
 1112|      2|            break;
 1113|      2|        case BITSTRING:
  ------------------
  |  |  209|      2|#define BITSTRING   (41 | SYNTAX_MASK)
  |  |  ------------------
  |  |  |  |  157|      2|#define SYNTAX_MASK     0x80
  |  |  ------------------
  ------------------
  |  Branch (1113:9): [True: 2, False: 510]
  ------------------
 1114|      2|            translation_table[count] = TYPE_BITSTRING;
  ------------------
  |  |  166|      2|#define TYPE_BITSTRING      12
  ------------------
 1115|      2|            break;
 1116|      2|        case NSAPADDRESS:
  ------------------
  |  |  210|      2|#define NSAPADDRESS (42 | SYNTAX_MASK)
  |  |  ------------------
  |  |  |  |  157|      2|#define SYNTAX_MASK     0x80
  |  |  ------------------
  ------------------
  |  Branch (1116:9): [True: 2, False: 510]
  ------------------
 1117|      2|            translation_table[count] = TYPE_NSAPADDRESS;
  ------------------
  |  |  167|      2|#define TYPE_NSAPADDRESS    13
  ------------------
 1118|      2|            break;
 1119|      2|        case INTEGER32:
  ------------------
  |  |  274|      2|#define INTEGER32	(105 | SYNTAX_MASK)
  |  |  ------------------
  |  |  |  |  157|      2|#define SYNTAX_MASK     0x80
  |  |  ------------------
  ------------------
  |  Branch (1119:9): [True: 2, False: 510]
  ------------------
 1120|      2|            translation_table[count] = TYPE_INTEGER32;
  ------------------
  |  |  170|      2|#define TYPE_INTEGER32      16
  ------------------
 1121|      2|            break;
 1122|      2|        case UINTEGER32:
  ------------------
  |  |  224|      2|#define UINTEGER32 (56 | SYNTAX_MASK)
  |  |  ------------------
  |  |  |  |  157|      2|#define SYNTAX_MASK     0x80
  |  |  ------------------
  ------------------
  |  Branch (1122:9): [True: 2, False: 510]
  ------------------
 1123|      2|            translation_table[count] = TYPE_UINTEGER;
  ------------------
  |  |  168|      2|#define TYPE_UINTEGER       14
  ------------------
 1124|      2|            break;
 1125|      2|        case UNSIGNED32:
  ------------------
  |  |  273|      2|#define UNSIGNED32	(104 | SYNTAX_MASK)
  |  |  ------------------
  |  |  |  |  157|      2|#define SYNTAX_MASK     0x80
  |  |  ------------------
  ------------------
  |  Branch (1125:9): [True: 2, False: 510]
  ------------------
 1126|      2|            translation_table[count] = TYPE_UNSIGNED32;
  ------------------
  |  |  169|      2|#define TYPE_UNSIGNED32     15
  ------------------
 1127|      2|            break;
 1128|      2|        case TRAPTYPE:
  ------------------
  |  |  229|      2|#define TRAPTYPE    61
  ------------------
  |  Branch (1128:9): [True: 2, False: 510]
  ------------------
 1129|      2|            translation_table[count] = TYPE_TRAPTYPE;
  ------------------
  |  |  174|      2|#define TYPE_TRAPTYPE	    20
  ------------------
 1130|      2|            break;
 1131|      2|        case NOTIFTYPE:
  ------------------
  |  |  213|      2|#define NOTIFTYPE   45
  ------------------
  |  Branch (1131:9): [True: 2, False: 510]
  ------------------
 1132|      2|            translation_table[count] = TYPE_NOTIFTYPE;
  ------------------
  |  |  175|      2|#define TYPE_NOTIFTYPE      21
  ------------------
 1133|      2|            break;
 1134|      2|        case NOTIFGROUP:
  ------------------
  |  |  258|      2|#define NOTIFGROUP  88
  ------------------
  |  Branch (1134:9): [True: 2, False: 510]
  ------------------
 1135|      2|            translation_table[count] = TYPE_NOTIFGROUP;
  ------------------
  |  |  177|      2|#define TYPE_NOTIFGROUP	    23
  ------------------
 1136|      2|            break;
 1137|      2|        case OBJGROUP:
  ------------------
  |  |  212|      2|#define OBJGROUP    44
  ------------------
  |  Branch (1137:9): [True: 2, False: 510]
  ------------------
 1138|      2|            translation_table[count] = TYPE_OBJGROUP;
  ------------------
  |  |  176|      2|#define TYPE_OBJGROUP	    22
  ------------------
 1139|      2|            break;
 1140|      2|        case MODULEIDENTITY:
  ------------------
  |  |  220|      2|#define MODULEIDENTITY 52
  ------------------
  |  Branch (1140:9): [True: 2, False: 510]
  ------------------
 1141|      2|            translation_table[count] = TYPE_MODID;
  ------------------
  |  |  178|      2|#define TYPE_MODID	    24
  ------------------
 1142|      2|            break;
 1143|      2|        case OBJIDENTITY:
  ------------------
  |  |  275|      2|#define OBJIDENTITY	106
  ------------------
  |  Branch (1143:9): [True: 2, False: 510]
  ------------------
 1144|      2|            translation_table[count] = TYPE_OBJIDENTITY;
  ------------------
  |  |  181|      2|#define TYPE_OBJIDENTITY    27
  ------------------
 1145|      2|            break;
 1146|      2|        case AGENTCAP:
  ------------------
  |  |  243|      2|#define AGENTCAP    73
  ------------------
  |  Branch (1146:9): [True: 2, False: 510]
  ------------------
 1147|      2|            translation_table[count] = TYPE_AGENTCAP;
  ------------------
  |  |  179|      2|#define TYPE_AGENTCAP       25
  ------------------
 1148|      2|            break;
 1149|      2|        case COMPLIANCE:
  ------------------
  |  |  215|      2|#define COMPLIANCE  47
  ------------------
  |  Branch (1149:9): [True: 2, False: 510]
  ------------------
 1150|      2|            translation_table[count] = TYPE_MODCOMP;
  ------------------
  |  |  180|      2|#define TYPE_MODCOMP        26
  ------------------
 1151|      2|            break;
 1152|    464|        default:
  ------------------
  |  Branch (1152:9): [True: 464, False: 48]
  ------------------
 1153|    464|            translation_table[count] = TYPE_OTHER;
  ------------------
  |  |  154|    464|#define TYPE_OTHER          0
  ------------------
 1154|    464|            break;
 1155|    512|        }
 1156|    512|    }
 1157|      2|}
parse.c:init_tree_roots:
 1161|      2|{
 1162|      2|    struct tree    *tp, *lasttp;
 1163|      2|    int             base_modid;
 1164|      2|    int             hash;
 1165|       |
 1166|      2|    base_modid = which_module("SNMPv2-SMI");
 1167|      2|    if (base_modid == -1)
  ------------------
  |  Branch (1167:9): [True: 2, False: 0]
  ------------------
 1168|      2|        base_modid = which_module("RFC1155-SMI");
 1169|      2|    if (base_modid == -1)
  ------------------
  |  Branch (1169:9): [True: 2, False: 0]
  ------------------
 1170|      2|        base_modid = which_module("RFC1213-MIB");
 1171|       |
 1172|       |    /*
 1173|       |     * build root node 
 1174|       |     */
 1175|      2|    tp = calloc(1, sizeof(struct tree));
 1176|      2|    if (tp == NULL)
  ------------------
  |  Branch (1176:9): [True: 0, False: 2]
  ------------------
 1177|      0|        return;
 1178|      2|    tp->label = strdup("joint-iso-ccitt");
 1179|      2|    tp->modid = base_modid;
 1180|      2|    tp->number_modules = 1;
 1181|      2|    tp->module_list = &(tp->modid);
 1182|      2|    tp->subid = 2;
 1183|      2|    tp->tc_index = -1;
 1184|      2|    set_function(tp);           /* from mib.c */
 1185|      2|    hash = NBUCKET(name_hash(tp->label));
  ------------------
  |  |  530|      2|#define NBUCKET(x)   (x & (NHASHSIZE-1))
  |  |  ------------------
  |  |  |  |  529|      2|#define NHASHSIZE    128
  |  |  ------------------
  ------------------
 1186|      2|    tp->next = tbuckets[hash];
 1187|      2|    tbuckets[hash] = tp;
 1188|      2|    lasttp = tp;
 1189|      2|    root_imports[0].label = strdup(tp->label);
 1190|      2|    root_imports[0].modid = base_modid;
 1191|       |
 1192|       |    /*
 1193|       |     * build root node 
 1194|       |     */
 1195|      2|    tp = calloc(1, sizeof(struct tree));
 1196|      2|    if (tp == NULL)
  ------------------
  |  Branch (1196:9): [True: 0, False: 2]
  ------------------
 1197|      0|        return;
 1198|      2|    tp->next_peer = lasttp;
 1199|      2|    tp->label = strdup("ccitt");
 1200|      2|    tp->modid = base_modid;
 1201|      2|    tp->number_modules = 1;
 1202|      2|    tp->module_list = &(tp->modid);
 1203|      2|    tp->subid = 0;
 1204|      2|    tp->tc_index = -1;
 1205|      2|    set_function(tp);           /* from mib.c */
 1206|      2|    hash = NBUCKET(name_hash(tp->label));
  ------------------
  |  |  530|      2|#define NBUCKET(x)   (x & (NHASHSIZE-1))
  |  |  ------------------
  |  |  |  |  529|      2|#define NHASHSIZE    128
  |  |  ------------------
  ------------------
 1207|      2|    tp->next = tbuckets[hash];
 1208|      2|    tbuckets[hash] = tp;
 1209|      2|    lasttp = tp;
 1210|      2|    root_imports[1].label = strdup(tp->label);
 1211|      2|    root_imports[1].modid = base_modid;
 1212|       |
 1213|       |    /*
 1214|       |     * build root node 
 1215|       |     */
 1216|      2|    tp = calloc(1, sizeof(struct tree));
 1217|      2|    if (tp == NULL)
  ------------------
  |  Branch (1217:9): [True: 0, False: 2]
  ------------------
 1218|      0|        return;
 1219|      2|    tp->next_peer = lasttp;
 1220|      2|    tp->label = strdup("iso");
 1221|      2|    tp->modid = base_modid;
 1222|      2|    tp->number_modules = 1;
 1223|      2|    tp->module_list = &(tp->modid);
 1224|      2|    tp->subid = 1;
 1225|      2|    tp->tc_index = -1;
 1226|      2|    set_function(tp);           /* from mib.c */
 1227|      2|    hash = NBUCKET(name_hash(tp->label));
  ------------------
  |  |  530|      2|#define NBUCKET(x)   (x & (NHASHSIZE-1))
  |  |  ------------------
  |  |  |  |  529|      2|#define NHASHSIZE    128
  |  |  ------------------
  ------------------
 1228|      2|    tp->next = tbuckets[hash];
 1229|      2|    tbuckets[hash] = tp;
 1230|      2|    lasttp = tp;
 1231|      2|    root_imports[2].label = strdup(tp->label);
 1232|      2|    root_imports[2].modid = base_modid;
 1233|       |
 1234|      2|    tree_head = tp;
 1235|      2|}
parse.c:read_module_internal:
 4309|     96|{
 4310|     96|    struct module  *mp;
 4311|       |
 4312|     96|    netsnmp_init_mib_internals();
 4313|       |
 4314|     96|    for (mp = module_head; mp; mp = mp->next)
  ------------------
  |  Branch (4314:28): [True: 0, False: 96]
  ------------------
 4315|      0|        if (!label_compare(mp->name, name))
  ------------------
  |  | 1240|      0|#define	label_compare	strcmp
  ------------------
  |  Branch (4315:13): [True: 0, False: 0]
  ------------------
 4316|      0|            return read_from_file(mp, name);
 4317|       |
 4318|     96|    return MODULE_NOT_FOUND;
  ------------------
  |  |  513|     96|#define MODULE_NOT_FOUND	0
  ------------------
 4319|     96|}
parse.c:print_error:
  783|     96|{
  784|     96|    erroneousMibs++;
  785|     96|    if (!netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID,
  ------------------
  |  |   48|     96|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  |  Branch (785:9): [True: 0, False: 96]
  ------------------
  786|     96|                                NETSNMP_DS_LIB_MIB_ERRORS))
  ------------------
  |  |   59|     96|#define NETSNMP_DS_LIB_MIB_ERRORS          0
  ------------------
  787|      0|	return;
  788|     96|    DEBUGMSGTL(("parse-mibs", "\n"));
  ------------------
  |  |   66|     96|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     96|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 96]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 96]
  |  |  ------------------
  ------------------
  789|     96|    if (type == ENDOFFILE)
  ------------------
  |  |  163|     96|#define ENDOFFILE   0
  ------------------
  |  Branch (789:9): [True: 0, False: 96]
  ------------------
  790|      0|        snmp_log(LOG_ERR, "%s (EOF): At line %d in %s\n", str, mibLine,
  791|      0|                 File);
  792|     96|    else if (token && *token)
  ------------------
  |  Branch (792:14): [True: 96, False: 0]
  |  Branch (792:23): [True: 96, False: 0]
  ------------------
  793|     96|        snmp_log(LOG_ERR, "%s (%s): At line %d in %s\n", str, token,
  794|     96|                 mibLine, File);
  795|      0|    else
  796|      0|        snmp_log(LOG_ERR, "%s: At line %d in %s\n", str, mibLine, File);
  797|     96|}
parse.c:read_module_replacements:
 4189|     96|{
 4190|     96|    struct module_compatability *mcp;
 4191|       |
 4192|  2.20k|    for (mcp = module_map_head; mcp; mcp = mcp->next) {
  ------------------
  |  Branch (4192:33): [True: 2.11k, False: 96]
  ------------------
 4193|  2.11k|        if (!label_compare(mcp->old_module, name)) {
  ------------------
  |  | 1240|  2.11k|#define	label_compare	strcmp
  ------------------
  |  Branch (4193:13): [True: 0, False: 2.11k]
  ------------------
 4194|      0|            if (netsnmp_ds_get_int(NETSNMP_DS_LIBRARY_ID, 
  ------------------
  |  |   48|      0|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  |  Branch (4194:17): [True: 0, False: 0]
  ------------------
 4195|      0|				   NETSNMP_DS_LIB_MIB_WARNINGS)) {
  ------------------
  |  |  114|      0|#define NETSNMP_DS_LIB_MIB_WARNINGS         0
  ------------------
 4196|      0|                snmp_log(LOG_WARNING,
 4197|      0|                         "Loading replacement module %s for %s (%s)\n",
 4198|      0|                         mcp->new_module, name, File);
 4199|      0|	    }
 4200|      0|            (void) netsnmp_read_module(mcp->new_module);
 4201|      0|            return 1;
 4202|      0|        }
 4203|  2.11k|    }
 4204|     96|    return 0;
 4205|     96|}
parse.c:print_module_not_found:
  801|     96|{
  802|     96|    if (first_err_module) {
  ------------------
  |  Branch (802:9): [True: 2, False: 94]
  ------------------
  803|      2|        snmp_log(LOG_ERR, "MIB search path: %s\n",
  804|      2|                           netsnmp_get_mib_directory());
  805|      2|        first_err_module = 0;
  806|      2|    }
  807|     96|    if (!last_err_module || strcmp(cp, last_err_module))
  ------------------
  |  Branch (807:9): [True: 2, False: 94]
  |  Branch (807:29): [True: 94, False: 0]
  ------------------
  808|     96|        print_error("Cannot find module", cp, CONTINUE);
  ------------------
  |  |  162|     96|#define CONTINUE    -1
  ------------------
  809|     96|    if (last_err_module)
  ------------------
  |  Branch (809:9): [True: 94, False: 2]
  ------------------
  810|     94|        free(last_err_module);
  811|     96|    last_err_module = strdup(cp);
  812|     96|}
parse.c:scan_directory:
 5511|      2|{
 5512|      2|    DIR            *dir, *dir2;
 5513|      2|    struct dirent  *file;
 5514|      2|    char          **filenames = NULL;
 5515|      2|    int             fname_len, i, filename_count = 0, array_size = 0;
 5516|      2|    char           *tmpstr;
 5517|       |
 5518|      2|    *result = NULL;
 5519|       |
 5520|      2|    dir = opendir(dirname);
 5521|      2|    if (!dir)
  ------------------
  |  Branch (5521:9): [True: 2, False: 0]
  ------------------
 5522|      2|        return -1;
 5523|       |
 5524|      0|    while ((file = readdir(dir))) {
  ------------------
  |  Branch (5524:12): [True: 0, False: 0]
  ------------------
 5525|       |        /*
 5526|       |         * Only parse file names that don't begin with a '.'
 5527|       |         * Also skip files ending in '~', or starting/ending
 5528|       |         * with '#' which are typically editor backup files.
 5529|       |         */
 5530|      0|        fname_len = strlen(file->d_name);
 5531|      0|        if (fname_len > 0 && file->d_name[0] != '.'
  ------------------
  |  Branch (5531:13): [True: 0, False: 0]
  |  Branch (5531:30): [True: 0, False: 0]
  ------------------
 5532|      0|            && file->d_name[0] != '#'
  ------------------
  |  Branch (5532:16): [True: 0, False: 0]
  ------------------
 5533|      0|            && file->d_name[fname_len-1] != '#'
  ------------------
  |  Branch (5533:16): [True: 0, False: 0]
  ------------------
 5534|      0|            && file->d_name[fname_len-1] != '~') {
  ------------------
  |  Branch (5534:16): [True: 0, False: 0]
  ------------------
 5535|      0|            if (asprintf(&tmpstr, "%s/%s", dirname, file->d_name) < 0)
  ------------------
  |  Branch (5535:17): [True: 0, False: 0]
  ------------------
 5536|      0|                continue;
 5537|      0|            dir2 = opendir(tmpstr);
 5538|      0|            if (dir2) {
  ------------------
  |  Branch (5538:17): [True: 0, False: 0]
  ------------------
 5539|       |                /* file is a directory, don't read it */
 5540|      0|                closedir(dir2);
 5541|      0|            } else {
 5542|      0|                if (filename_count >= array_size) {
  ------------------
  |  Branch (5542:21): [True: 0, False: 0]
  ------------------
 5543|      0|                    char **new_filenames;
 5544|       |
 5545|      0|                    array_size = (array_size + 16) * 2;
 5546|      0|                    new_filenames = realloc(filenames,
 5547|      0|                                        array_size * sizeof(filenames[0]));
 5548|      0|                    if (!new_filenames) {
  ------------------
  |  Branch (5548:25): [True: 0, False: 0]
  ------------------
 5549|      0|                        free(tmpstr);
 5550|      0|                        for (i = 0; i < filename_count; i++)
  ------------------
  |  Branch (5550:37): [True: 0, False: 0]
  ------------------
 5551|      0|                            free(filenames[i]);
 5552|      0|                        free(filenames);
 5553|      0|                        closedir(dir);
 5554|      0|                        return -1;
 5555|      0|                    }
 5556|      0|                    filenames = new_filenames;
 5557|      0|                }
 5558|      0|                filenames[filename_count++] = tmpstr;
 5559|      0|                tmpstr = NULL;
 5560|      0|            }
 5561|      0|            free(tmpstr);
 5562|      0|        }
 5563|      0|    }
 5564|      0|    closedir(dir);
 5565|       |
 5566|      0|    if (filenames)
  ------------------
  |  Branch (5566:9): [True: 0, False: 0]
  ------------------
 5567|      0|        qsort(filenames, filename_count, sizeof(filenames[0]), elemcmp);
 5568|      0|    *result = filenames;
 5569|       |
 5570|      0|    return filename_count;
 5571|      0|}

register_prenetsnmp_mib_handler:
  256|     70|{
  257|     70|    return internal_register_config_handler(type, token, parser, NULL, releaser,
  258|     70|					    help, PREMIB_CONFIG);
  ------------------
  |  |   15|     70|#define PREMIB_CONFIG 1
  ------------------
  259|     70|}
register_config_handler:
  311|    126|{
  312|    126|    return internal_register_config_handler(type, token, parser, NULL, releaser,
  313|    126|					    help, NORMAL_CONFIG);
  ------------------
  |  |   14|    126|#define NORMAL_CONFIG 0
  ------------------
  314|    126|}
register_const_config_handler:
  321|      2|{
  322|      2|    return internal_register_config_handler(type, token, NULL, parser, releaser,
  323|      2|					    help, NORMAL_CONFIG);
  ------------------
  |  |   14|      2|#define NORMAL_CONFIG 0
  ------------------
  324|      2|}
register_app_config_handler:
  330|      4|{
  331|       |    return register_config_handler(NULL, token, parser, releaser, help);
  332|      4|}
netsnmp_config_remember_free_list:
  695|      2|{
  696|      2|    struct read_config_memory *tmpmem;
  697|      2|    while (*mem) {
  ------------------
  |  Branch (697:12): [True: 0, False: 2]
  ------------------
  698|      0|        SNMP_FREE((*mem)->line);
  ------------------
  |  |   62|      0|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 0, False: 0]
  |  |  |  Branch (62:66): [Folded, False: 0]
  |  |  ------------------
  ------------------
  699|      0|        tmpmem = (*mem)->next;
  700|       |        SNMP_FREE(*mem);
  ------------------
  |  |   62|      0|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 0, False: 0]
  |  |  |  Branch (62:66): [Folded, False: 0]
  |  |  ------------------
  ------------------
  701|      0|        *mem = tmpmem;
  702|      0|    }
  703|      2|}
netsnmp_config_process_memory_list:
  708|      4|{
  709|       |
  710|      4|    struct read_config_memory *mem;
  711|       |
  712|      4|    if (!memp)
  ------------------
  |  Branch (712:9): [True: 0, False: 4]
  ------------------
  713|      0|        return;
  714|       |
  715|      4|    mem = *memp;
  716|       |
  717|      4|    while (mem) {
  ------------------
  |  Branch (717:12): [True: 0, False: 4]
  ------------------
  718|      0|        DEBUGMSGTL(("read_config:mem", "processing memory: %s\n", mem->line));
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
  719|      0|        snmp_config_when(mem->line, when);
  720|      0|        mem = mem->next;
  721|      0|    }
  722|       |
  723|      4|    if (clear)
  ------------------
  |  Branch (723:9): [True: 2, False: 2]
  ------------------
  724|      2|        netsnmp_config_remember_free_list(memp);
  725|      4|}
netsnmp_config_process_memories_when:
  746|      4|{
  747|      4|    netsnmp_config_process_memory_list(&memorylist, when, clear);
  748|      4|}
free_config:
 1036|      2|{
 1037|      2|    struct config_files *ctmp = config_files;
 1038|      2|    struct config_line *ltmp;
 1039|       |
 1040|      6|    for (; ctmp != NULL; ctmp = ctmp->next)
  ------------------
  |  Branch (1040:12): [True: 4, False: 2]
  ------------------
 1041|    206|        for (ltmp = ctmp->start; ltmp != NULL; ltmp = ltmp->next)
  ------------------
  |  Branch (1041:34): [True: 202, False: 4]
  ------------------
 1042|    202|            if (ltmp->free_func)
  ------------------
  |  Branch (1042:17): [True: 14, False: 188]
  ------------------
 1043|     14|                (*(ltmp->free_func)) ();
 1044|      2|}
read_configs:
 1089|      2|{
 1090|      2|    char *optional_config = netsnmp_ds_get_string(NETSNMP_DS_LIBRARY_ID, 
  ------------------
  |  |   48|      2|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
 1091|      2|					       NETSNMP_DS_LIB_OPTIONALCONFIG);
  ------------------
  |  |  156|      2|#define NETSNMP_DS_LIB_OPTIONALCONFIG    5
  ------------------
 1092|       |
 1093|      2|    snmp_call_callbacks(SNMP_CALLBACK_LIBRARY,
  ------------------
  |  |   18|      2|#define SNMP_CALLBACK_LIBRARY     0
  ------------------
 1094|      2|                        SNMP_CALLBACK_PRE_READ_CONFIG, NULL);
  ------------------
  |  |   30|      2|#define SNMP_CALLBACK_PRE_READ_CONFIG	        7
  ------------------
 1095|       |
 1096|      2|    DEBUGMSGTL(("read_config", "reading normal configuration tokens\n"));
  ------------------
  |  |   66|      2|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      2|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 2]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 2]
  |  |  ------------------
  ------------------
 1097|       |
 1098|      2|    if ((NULL != optional_config) && (*optional_config == '-')) {
  ------------------
  |  Branch (1098:9): [True: 0, False: 2]
  |  Branch (1098:38): [True: 0, False: 0]
  ------------------
 1099|      0|        (void)read_configs_optional(++optional_config, NORMAL_CONFIG);
  ------------------
  |  |   14|      0|#define NORMAL_CONFIG 0
  ------------------
 1100|      0|        optional_config = NULL; /* clear, so we don't read them twice */
 1101|      0|    }
 1102|       |
 1103|      2|    (void)read_config_files(NORMAL_CONFIG);
  ------------------
  |  |   14|      2|#define NORMAL_CONFIG 0
  ------------------
 1104|       |
 1105|       |    /*
 1106|       |     * do this even when the normal above wasn't done 
 1107|       |     */
 1108|      2|    if (NULL != optional_config)
  ------------------
  |  Branch (1108:9): [True: 0, False: 2]
  ------------------
 1109|      0|        (void)read_configs_optional(optional_config, NORMAL_CONFIG);
  ------------------
  |  |   14|      0|#define NORMAL_CONFIG 0
  ------------------
 1110|       |
 1111|      2|    netsnmp_config_process_memories_when(NORMAL_CONFIG, 1);
  ------------------
  |  |   14|      2|#define NORMAL_CONFIG 0
  ------------------
 1112|       |
 1113|      2|    netsnmp_ds_set_boolean(NETSNMP_DS_LIBRARY_ID, 
  ------------------
  |  |   48|      2|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
 1114|      2|			   NETSNMP_DS_LIB_HAVE_READ_CONFIG, 1);
  ------------------
  |  |   87|      2|#define NETSNMP_DS_LIB_HAVE_READ_CONFIG    27   /* have the config tokens been processed */
  ------------------
 1115|      2|    snmp_call_callbacks(SNMP_CALLBACK_LIBRARY,
  ------------------
  |  |   18|      2|#define SNMP_CALLBACK_LIBRARY     0
  ------------------
 1116|      2|                        SNMP_CALLBACK_POST_READ_CONFIG, NULL);
  ------------------
  |  |   24|      2|#define SNMP_CALLBACK_POST_READ_CONFIG	        0
  ------------------
 1117|      2|}
read_premib_configs:
 1121|      2|{
 1122|      2|    char *optional_config = netsnmp_ds_get_string(NETSNMP_DS_LIBRARY_ID, 
  ------------------
  |  |   48|      2|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
 1123|      2|					       NETSNMP_DS_LIB_OPTIONALCONFIG);
  ------------------
  |  |  156|      2|#define NETSNMP_DS_LIB_OPTIONALCONFIG    5
  ------------------
 1124|       |
 1125|      2|    snmp_call_callbacks(SNMP_CALLBACK_LIBRARY,
  ------------------
  |  |   18|      2|#define SNMP_CALLBACK_LIBRARY     0
  ------------------
 1126|      2|                        SNMP_CALLBACK_PRE_PREMIB_READ_CONFIG, NULL);
  ------------------
  |  |   31|      2|#define SNMP_CALLBACK_PRE_PREMIB_READ_CONFIG	8
  ------------------
 1127|       |
 1128|      2|    DEBUGMSGTL(("read_config", "reading premib configuration tokens\n"));
  ------------------
  |  |   66|      2|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      2|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 2]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 2]
  |  |  ------------------
  ------------------
 1129|       |
 1130|      2|    if ((NULL != optional_config) && (*optional_config == '-')) {
  ------------------
  |  Branch (1130:9): [True: 0, False: 2]
  |  Branch (1130:38): [True: 0, False: 0]
  ------------------
 1131|      0|        (void)read_configs_optional(++optional_config, PREMIB_CONFIG);
  ------------------
  |  |   15|      0|#define PREMIB_CONFIG 1
  ------------------
 1132|      0|        optional_config = NULL; /* clear, so we don't read them twice */
 1133|      0|    }
 1134|       |
 1135|      2|    (void)read_config_files(PREMIB_CONFIG);
  ------------------
  |  |   15|      2|#define PREMIB_CONFIG 1
  ------------------
 1136|       |
 1137|      2|    if (NULL != optional_config)
  ------------------
  |  Branch (1137:9): [True: 0, False: 2]
  ------------------
 1138|      0|        (void)read_configs_optional(optional_config, PREMIB_CONFIG);
  ------------------
  |  |   15|      0|#define PREMIB_CONFIG 1
  ------------------
 1139|       |
 1140|      2|    netsnmp_config_process_memories_when(PREMIB_CONFIG, 0);
  ------------------
  |  |   15|      2|#define PREMIB_CONFIG 1
  ------------------
 1141|       |
 1142|      2|    netsnmp_ds_set_boolean(NETSNMP_DS_LIBRARY_ID, 
  ------------------
  |  |   48|      2|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
 1143|      2|			   NETSNMP_DS_LIB_HAVE_READ_PREMIB_CONFIG, 1);
  ------------------
  |  |   86|      2|#define NETSNMP_DS_LIB_HAVE_READ_PREMIB_CONFIG 26       /* have the pre-mib parsing config tokens been processed */
  ------------------
 1144|      2|    snmp_call_callbacks(SNMP_CALLBACK_LIBRARY,
  ------------------
  |  |   18|      2|#define SNMP_CALLBACK_LIBRARY     0
  ------------------
 1145|      2|                        SNMP_CALLBACK_POST_PREMIB_READ_CONFIG, NULL);
  ------------------
  |  |   27|      2|#define SNMP_CALLBACK_POST_PREMIB_READ_CONFIG	3
  ------------------
 1146|      2|}
set_configuration_directory:
 1158|      2|{
 1159|      2|    netsnmp_ds_set_string(NETSNMP_DS_LIBRARY_ID, 
  ------------------
  |  |   48|      2|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
 1160|      2|			  NETSNMP_DS_LIB_CONFIGURATION_DIR, dir);
  ------------------
  |  |  160|      2|#define NETSNMP_DS_LIB_CONFIGURATION_DIR 9
  ------------------
 1161|      2|}
get_configuration_directory:
 1177|      2|{
 1178|      2|    char            defaultPath[SPRINT_MAX_LEN];
 1179|      2|    const char     *homepath;
 1180|       |
 1181|      2|    if (NULL == netsnmp_ds_get_string(NETSNMP_DS_LIBRARY_ID, 
  ------------------
  |  |   48|      2|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  |  Branch (1181:9): [True: 2, False: 0]
  ------------------
 1182|      2|				      NETSNMP_DS_LIB_CONFIGURATION_DIR)) {
  ------------------
  |  |  160|      2|#define NETSNMP_DS_LIB_CONFIGURATION_DIR 9
  ------------------
 1183|      2|        homepath = netsnmp_gethomedir();
 1184|      2|        snprintf(defaultPath, sizeof(defaultPath), "%s%c%s%c%s%s%s%s",
 1185|      2|                SNMPCONFPATH, ENV_SEPARATOR_CHAR,
  ------------------
  |  | 2062|      2|#define SNMPCONFPATH "/usr/local/net-snmp-master/etc/snmp"
  ------------------
                              SNMPCONFPATH, ENV_SEPARATOR_CHAR,
  ------------------
  |  |   70|      2|#define ENV_SEPARATOR_CHAR ':'
  ------------------
 1186|      2|                SNMPSHAREPATH, ENV_SEPARATOR_CHAR, SNMPLIBPATH,
  ------------------
  |  | 2061|      2|#define SNMPSHAREPATH "/usr/local/net-snmp-master/share/snmp"
  ------------------
                              SNMPSHAREPATH, ENV_SEPARATOR_CHAR, SNMPLIBPATH,
  ------------------
  |  |   70|      2|#define ENV_SEPARATOR_CHAR ':'
  ------------------
                              SNMPSHAREPATH, ENV_SEPARATOR_CHAR, SNMPLIBPATH,
  ------------------
  |  | 2060|      2|#define SNMPLIBPATH "/usr/local/net-snmp-master/lib/snmp"
  ------------------
 1187|      2|                ((homepath == NULL) ? "" : ENV_SEPARATOR),
  ------------------
  |  |   67|      2|#define ENV_SEPARATOR ":"
  ------------------
  |  Branch (1187:18): [True: 0, False: 2]
  ------------------
 1188|      2|                ((homepath == NULL) ? "" : homepath),
  ------------------
  |  Branch (1188:18): [True: 0, False: 2]
  ------------------
 1189|      2|                ((homepath == NULL) ? "" : "/.snmp"));
  ------------------
  |  Branch (1189:18): [True: 0, False: 2]
  ------------------
 1190|      2|        defaultPath[ sizeof(defaultPath)-1 ] = 0;
 1191|      2|        set_configuration_directory(defaultPath);
 1192|      2|    }
 1193|      2|    return (netsnmp_ds_get_string(NETSNMP_DS_LIBRARY_ID, 
  ------------------
  |  |   48|      2|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
 1194|      2|				  NETSNMP_DS_LIB_CONFIGURATION_DIR));
  ------------------
  |  |  160|      2|#define NETSNMP_DS_LIB_CONFIGURATION_DIR 9
  ------------------
 1195|      2|}
get_persistent_directory:
 1225|      2|{
 1226|      2|    if (NULL == netsnmp_ds_get_string(NETSNMP_DS_LIBRARY_ID, 
  ------------------
  |  |   48|      2|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  |  Branch (1226:9): [True: 0, False: 2]
  ------------------
 1227|      2|				      NETSNMP_DS_LIB_PERSISTENT_DIR)) {
  ------------------
  |  |  159|      2|#define NETSNMP_DS_LIB_PERSISTENT_DIR    8
  ------------------
 1228|      0|        const char *persdir = netsnmp_getenv("SNMP_PERSISTENT_DIR");
 1229|      0|        if (NULL == persdir)
  ------------------
  |  Branch (1229:13): [True: 0, False: 0]
  ------------------
 1230|      0|            persdir = NETSNMP_PERSISTENT_DIRECTORY;
  ------------------
  |  | 2032|      0|#define NETSNMP_PERSISTENT_DIRECTORY "/var/net-snmp"
  ------------------
 1231|      0|        set_persistent_directory(persdir);
 1232|      0|    }
 1233|      2|    return (netsnmp_ds_get_string(NETSNMP_DS_LIBRARY_ID, 
  ------------------
  |  |   48|      2|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
 1234|      2|				  NETSNMP_DS_LIB_PERSISTENT_DIR));
  ------------------
  |  |  159|      2|#define NETSNMP_DS_LIB_PERSISTENT_DIR    8
  ------------------
 1235|      2|}
read_config_files_of_type:
 1419|      8|{
 1420|      8|    const char     *confpath, *persfile, *envconfpath;
 1421|      8|    char           *perspath;
 1422|      8|    int             ret = SNMPERR_GENERR;
  ------------------
  |  |  185|      8|#define SNMPERR_GENERR			(-1)
  ------------------
 1423|       |
 1424|      8|    if (netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID,
  ------------------
  |  |   48|      8|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  |  Branch (1424:9): [True: 8, False: 0]
  ------------------
 1425|      8|                               NETSNMP_DS_LIB_DONT_PERSIST_STATE)
  ------------------
  |  |   92|      8|#define NETSNMP_DS_LIB_DONT_PERSIST_STATE  32	/* don't load config and don't load/save persistent file */
  ------------------
 1426|      0|        || netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID,
  ------------------
  |  |   48|      0|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  |  Branch (1426:12): [True: 0, False: 0]
  ------------------
 1427|      0|                                  NETSNMP_DS_LIB_DISABLE_CONFIG_LOAD)
  ------------------
  |  |   66|      0|#define NETSNMP_DS_LIB_DISABLE_CONFIG_LOAD      NETSNMP_DS_LIB_DONT_READ_CONFIGS
  |  |  ------------------
  |  |  |  |   65|      0|#define NETSNMP_DS_LIB_DONT_READ_CONFIGS   6    /* don't read normal config files */
  |  |  ------------------
  ------------------
 1428|      8|        || (NULL == ctmp)) return ret;
  ------------------
  |  Branch (1428:12): [True: 0, False: 0]
  ------------------
 1429|       |
 1430|       |    /*
 1431|       |     * these shouldn't change
 1432|       |     */
 1433|      0|    confpath = get_configuration_directory();
 1434|      0|    persfile = netsnmp_getenv("SNMP_PERSISTENT_FILE");
 1435|      0|    envconfpath = netsnmp_getenv("SNMPCONFPATH");
 1436|       |
 1437|       |
 1438|       |        /*
 1439|       |         * read the config files. strdup() the result of
 1440|       |         * get_persistent_directory() to avoid that parsing the "persistentDir"
 1441|       |         * keyword transforms the perspath pointer into a dangling pointer.
 1442|       |         */
 1443|      0|        perspath = strdup(get_persistent_directory());
 1444|      0|        if (perspath == NULL) {
  ------------------
  |  Branch (1444:13): [True: 0, False: 0]
  ------------------
 1445|      0|            return SNMPERR_GENERR;
  ------------------
  |  |  185|      0|#define SNMPERR_GENERR			(-1)
  ------------------
 1446|      0|        }
 1447|      0|        if (envconfpath == NULL) {
  ------------------
  |  Branch (1447:13): [True: 0, False: 0]
  ------------------
 1448|       |            /*
 1449|       |             * read just the config files (no persistent stuff), since
 1450|       |             * persistent path can change via conf file. Then get the
 1451|       |             * current persistent directory, and read files there.
 1452|       |             */
 1453|      0|            if ( read_config_files_in_path(confpath, ctmp, when, perspath,
  ------------------
  |  Branch (1453:18): [True: 0, False: 0]
  ------------------
 1454|      0|                                      persfile) == SNMPERR_SUCCESS )
  ------------------
  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
 1455|      0|                ret = SNMPERR_SUCCESS;
  ------------------
  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
 1456|      0|            free(perspath);
 1457|      0|            perspath = strdup(get_persistent_directory());
 1458|      0|            if (perspath == NULL) {
  ------------------
  |  Branch (1458:17): [True: 0, False: 0]
  ------------------
 1459|      0|                return SNMPERR_GENERR;
  ------------------
  |  |  185|      0|#define SNMPERR_GENERR			(-1)
  ------------------
 1460|      0|            }
 1461|      0|            if ( read_config_files_in_path(perspath, ctmp, when, perspath,
  ------------------
  |  Branch (1461:18): [True: 0, False: 0]
  ------------------
 1462|      0|                                      persfile) == SNMPERR_SUCCESS )
  ------------------
  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
 1463|      0|                ret = SNMPERR_SUCCESS;
  ------------------
  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
 1464|      0|        }
 1465|      0|        else {
 1466|       |            /*
 1467|       |             * only read path specified by user
 1468|       |             */
 1469|      0|            if ( read_config_files_in_path(envconfpath, ctmp, when, perspath,
  ------------------
  |  Branch (1469:18): [True: 0, False: 0]
  ------------------
 1470|      0|                                      persfile) == SNMPERR_SUCCESS )
  ------------------
  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
 1471|      0|                ret = SNMPERR_SUCCESS;
  ------------------
  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
 1472|      0|        }
 1473|      0|        free(perspath);
 1474|      0|        return ret;
 1475|      0|}
read_config_files:
 1483|      4|read_config_files(int when) {
 1484|       |
 1485|      4|    struct config_files *ctmp = config_files;
 1486|      4|    int                  ret  = SNMPERR_GENERR;
  ------------------
  |  |  185|      4|#define SNMPERR_GENERR			(-1)
  ------------------
 1487|       |
 1488|      4|    config_errors = 0;
 1489|       |
 1490|      4|    if (when == PREMIB_CONFIG)
  ------------------
  |  |   15|      4|#define PREMIB_CONFIG 1
  ------------------
  |  Branch (1490:9): [True: 2, False: 2]
  ------------------
 1491|      2|        free_config();
 1492|       |
 1493|       |    /*
 1494|       |     * read all config file types 
 1495|       |     */
 1496|     12|    for (; ctmp != NULL; ctmp = ctmp->next) {
  ------------------
  |  Branch (1496:12): [True: 8, False: 4]
  ------------------
 1497|      8|        if ( read_config_files_of_type(when, ctmp) == SNMPERR_SUCCESS )
  ------------------
  |  |  184|      8|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
  |  Branch (1497:14): [True: 0, False: 8]
  ------------------
 1498|      0|            ret = SNMPERR_SUCCESS;
  ------------------
  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
 1499|      8|    }
 1500|       |
 1501|      4|    if (config_errors) {
  ------------------
  |  Branch (1501:9): [True: 0, False: 4]
  ------------------
 1502|       |        snmp_log(LOG_ERR, "net-snmp: %d error(s) in config file(s)\n",
 1503|      0|                 config_errors);
 1504|      0|    }
 1505|      4|    return ret;
 1506|      4|}
skip_white_const:
 1813|     30|{
 1814|     30|    if (ptr == NULL)
  ------------------
  |  Branch (1814:9): [True: 0, False: 30]
  ------------------
 1815|      0|        return (NULL);
 1816|     50|    while (*ptr != 0 && isspace((unsigned char)*ptr))
  ------------------
  |  Branch (1816:12): [True: 40, False: 10]
  |  Branch (1816:25): [True: 20, False: 20]
  ------------------
 1817|     20|        ptr++;
 1818|     30|    if (*ptr == 0 || *ptr == '#')
  ------------------
  |  Branch (1818:9): [True: 10, False: 20]
  |  Branch (1818:22): [True: 0, False: 20]
  ------------------
 1819|     10|        return (NULL);
 1820|     20|    return (ptr);
 1821|     30|}
copy_nword:
 1872|     22|{
 1873|     22|    return NETSNMP_REMOVE_CONST(char *, copy_nword_const(from, to, len));
  ------------------
  |  |   91|     22|    (__extension__ ({ const t tmp = (e); (t)(size_t)tmp; }))
  ------------------
 1874|     22|}
copy_nword_const:
 1878|     30|{
 1879|     30|    char            quote;
 1880|     30|    if (!from || !to)
  ------------------
  |  Branch (1880:9): [True: 0, False: 30]
  |  Branch (1880:18): [True: 0, False: 30]
  ------------------
 1881|      0|        return NULL;
 1882|     30|    if ((*from == '\"') || (*from == '\'')) {
  ------------------
  |  Branch (1882:9): [True: 0, False: 30]
  |  Branch (1882:28): [True: 0, False: 30]
  ------------------
 1883|      0|        quote = *(from++);
 1884|      0|        while ((*from != quote) && (*from != 0)) {
  ------------------
  |  Branch (1884:16): [True: 0, False: 0]
  |  Branch (1884:36): [True: 0, False: 0]
  ------------------
 1885|      0|            if ((*from == '\\') && (*(from + 1) != 0)) {
  ------------------
  |  Branch (1885:17): [True: 0, False: 0]
  |  Branch (1885:36): [True: 0, False: 0]
  ------------------
 1886|      0|                if (len > 0) {  /* don't copy beyond len bytes */
  ------------------
  |  Branch (1886:21): [True: 0, False: 0]
  ------------------
 1887|      0|                    *to++ = *(from + 1);
 1888|      0|                    if (--len == 0)
  ------------------
  |  Branch (1888:25): [True: 0, False: 0]
  ------------------
 1889|      0|                        *(to - 1) = '\0';       /* null protect the last spot */
 1890|      0|                }
 1891|      0|                from = from + 2;
 1892|      0|            } else {
 1893|      0|                if (len > 0) {  /* don't copy beyond len bytes */
  ------------------
  |  Branch (1893:21): [True: 0, False: 0]
  ------------------
 1894|      0|                    *to++ = *from++;
 1895|      0|                    if (--len == 0)
  ------------------
  |  Branch (1895:25): [True: 0, False: 0]
  ------------------
 1896|      0|                        *(to - 1) = '\0';       /* null protect the last spot */
 1897|      0|                } else
 1898|      0|                    from++;
 1899|      0|            }
 1900|      0|        }
 1901|      0|        if (*from == 0) {
  ------------------
  |  Branch (1901:13): [True: 0, False: 0]
  ------------------
 1902|      0|            DEBUGMSGTL(("read_config_copy_word",
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1903|      0|                        "no end quote found in config string\n"));
 1904|      0|        } else
 1905|      0|            from++;
 1906|     30|    } else {
 1907|    258|        while (*from != 0 && !isspace((unsigned char)(*from))) {
  ------------------
  |  Branch (1907:16): [True: 248, False: 10]
  |  Branch (1907:30): [True: 228, False: 20]
  ------------------
 1908|    228|            if ((*from == '\\') && (*(from + 1) != 0)) {
  ------------------
  |  Branch (1908:17): [True: 0, False: 228]
  |  Branch (1908:36): [True: 0, False: 0]
  ------------------
 1909|      0|                if (len > 0) {  /* don't copy beyond len bytes */
  ------------------
  |  Branch (1909:21): [True: 0, False: 0]
  ------------------
 1910|      0|                    *to++ = *(from + 1);
 1911|      0|                    if (--len == 0)
  ------------------
  |  Branch (1911:25): [True: 0, False: 0]
  ------------------
 1912|      0|                        *(to - 1) = '\0';       /* null protect the last spot */
 1913|      0|                }
 1914|      0|                from = from + 2;
 1915|    228|            } else {
 1916|    228|                if (len > 0) {  /* don't copy beyond len bytes */
  ------------------
  |  Branch (1916:21): [True: 228, False: 0]
  ------------------
 1917|    228|                    *to++ = *from++;
 1918|    228|                    if (--len == 0)
  ------------------
  |  Branch (1918:25): [True: 0, False: 228]
  ------------------
 1919|      0|                        *(to - 1) = '\0';       /* null protect the last spot */
 1920|    228|                } else
 1921|      0|                    from++;
 1922|    228|            }
 1923|    228|        }
 1924|     30|    }
 1925|     30|    if (len > 0)
  ------------------
  |  Branch (1925:9): [True: 30, False: 0]
  ------------------
 1926|     30|        *to = 0;
 1927|     30|    from = skip_white_const(from);
 1928|     30|    return (from);
 1929|     30|}                               /* copy_nword */
read_config.c:internal_register_config_handler:
  153|    206|{
  154|    206|    struct config_files **ctmp = &config_files;
  155|    206|    struct config_line  **ltmp;
  156|    206|    const char           *type = type_param;
  157|       |
  158|    206|    if (type == NULL || *type == '\0') {
  ------------------
  |  Branch (158:9): [True: 4, False: 202]
  |  Branch (158:25): [True: 4, False: 198]
  ------------------
  159|      8|        type = netsnmp_ds_get_string(NETSNMP_DS_LIBRARY_ID, 
  ------------------
  |  |   48|      8|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  160|      8|				     NETSNMP_DS_LIB_APPTYPE);
  ------------------
  |  |  157|      8|#define NETSNMP_DS_LIB_APPTYPE           6
  ------------------
  161|      8|    }
  162|       |
  163|       |    /*
  164|       |     * Handle multiple types (recursively)
  165|       |     */
  166|    206|    if (strchr(type, ':')) {
  ------------------
  |  Branch (166:9): [True: 4, False: 202]
  ------------------
  167|      4|        struct config_line *ltmp2 = NULL;
  168|      4|        char                buf[STRINGMAX];
  169|      4|        char               *cptr = buf;
  170|       |
  171|      4|        strlcpy(buf, type, STRINGMAX);
  ------------------
  |  |   12|      4|#define STRINGMAX 1024
  ------------------
  172|     12|        while (cptr) {
  ------------------
  |  Branch (172:16): [True: 8, False: 4]
  ------------------
  173|      8|            char* c = cptr;
  174|      8|            cptr = strchr(cptr, ':');
  175|      8|            if(cptr) {
  ------------------
  |  Branch (175:16): [True: 4, False: 4]
  ------------------
  176|      4|                *cptr = '\0';
  177|      4|                ++cptr;
  178|      4|            }
  179|      8|            ltmp2 = internal_register_config_handler(c, token, parser1, parser2,
  180|      8|                                                     releaser, help, when);
  181|      8|        }
  182|      4|        return ltmp2;
  183|      4|    }
  184|       |    
  185|       |    /*
  186|       |     * Find type in current list  -OR-  create a new file type.
  187|       |     */
  188|    236|    while (*ctmp != NULL && strcmp((*ctmp)->fileHeader, type)) {
  ------------------
  |  Branch (188:12): [True: 232, False: 4]
  |  Branch (188:29): [True: 34, False: 198]
  ------------------
  189|     34|        ctmp = &((*ctmp)->next);
  190|     34|    }
  191|       |
  192|    202|    if (*ctmp == NULL) {
  ------------------
  |  Branch (192:9): [True: 4, False: 198]
  ------------------
  193|      4|        *ctmp = (struct config_files *)
  194|      4|            calloc(1, sizeof(struct config_files));
  195|      4|        if (!*ctmp) {
  ------------------
  |  Branch (195:13): [True: 0, False: 4]
  ------------------
  196|      0|            return NULL;
  197|      0|        }
  198|       |
  199|      4|        (*ctmp)->fileHeader = strdup(type);
  200|      4|        if (!(*ctmp)->fileHeader) {
  ------------------
  |  Branch (200:13): [True: 0, False: 4]
  ------------------
  201|      0|            free(*ctmp);
  202|      0|            *ctmp = NULL;
  203|      0|            return NULL;
  204|      0|        }
  205|      4|        DEBUGMSGTL(("9:read_config:type", "new type %s\n", type));
  ------------------
  |  |   66|      4|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      4|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 4]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 4]
  |  |  ------------------
  ------------------
  206|      4|    }
  207|       |
  208|    202|    DEBUGMSGTL(("9:read_config:register_handler", "registering %s %s\n",
  ------------------
  |  |   66|    202|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|    202|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 202]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 202]
  |  |  ------------------
  ------------------
  209|    202|                type, token));
  210|       |    /*
  211|       |     * Find parser type in current list  -OR-  create a new
  212|       |     * line parser entry.
  213|       |     */
  214|    202|    ltmp = &((*ctmp)->start);
  215|       |
  216|  7.44k|    while (*ltmp != NULL && strcmp((*ltmp)->config_token, token)) {
  ------------------
  |  Branch (216:12): [True: 7.24k, False: 202]
  |  Branch (216:29): [True: 7.24k, False: 0]
  ------------------
  217|  7.24k|        ltmp = &((*ltmp)->next);
  218|  7.24k|    }
  219|       |
  220|    202|    if (*ltmp == NULL) {
  ------------------
  |  Branch (220:9): [True: 202, False: 0]
  ------------------
  221|    202|        *ltmp = (struct config_line *)
  222|    202|            calloc(1, sizeof(struct config_line));
  223|    202|        if (!*ltmp) {
  ------------------
  |  Branch (223:13): [True: 0, False: 202]
  ------------------
  224|      0|            return NULL;
  225|      0|        }
  226|       |
  227|    202|        (*ltmp)->config_time = when;
  228|    202|        (*ltmp)->config_token = strdup(token);
  229|    202|        if (!(*ltmp)->config_token) {
  ------------------
  |  Branch (229:13): [True: 0, False: 202]
  ------------------
  230|      0|            free(*ltmp);
  231|      0|            *ltmp = NULL;
  232|      0|            return NULL;
  233|      0|        }
  234|       |
  235|    202|        if (help != NULL)
  ------------------
  |  Branch (235:13): [True: 178, False: 24]
  ------------------
  236|    178|            (*ltmp)->help = strdup(help);
  237|    202|    }
  238|       |
  239|       |    /*
  240|       |     * Add/Replace the parse/free functions for the given line type
  241|       |     * in the given file type.
  242|       |     */
  243|    202|    (*ltmp)->parse_line1 = parser1;
  244|    202|    (*ltmp)->parse_line2 = parser2;
  245|    202|    (*ltmp)->free_func = releaser;
  246|       |
  247|    202|    return (*ltmp);
  248|       |
  249|    202|}                               /* end register_config_handler() */

sc_get_priv_alg_bytype:
  249|      4|{
  250|      4|    int i = 0;
  251|       |
  252|      4|    DEBUGTRACE;
  ------------------
  |  |   63|      4|#define DEBUGTRACE         do {if (_DBG_IF_) {__DBGTRACE;} }while(0)
  |  |  ------------------
  |  |  |  |  144|      4|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 4]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGTRACE         do {if (_DBG_IF_) {__DBGTRACE;} }while(0)
  |  |  ------------------
  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  ------------------
  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  ------------------
  |  |  |  Branch (63:67): [Folded, False: 4]
  |  |  ------------------
  ------------------
  253|       |
  254|     10|    for( ; _priv_alg_info[i].type != -1; ++i) {
  ------------------
  |  Branch (254:12): [True: 10, False: 0]
  ------------------
  255|     10|        if (type != _priv_alg_info[i].type)
  ------------------
  |  Branch (255:13): [True: 6, False: 4]
  ------------------
  256|      6|            continue;
  257|      4|        return(&_priv_alg_info[i]);
  258|     10|    }
  259|       |
  260|      0|    return NULL;
  261|      4|}
sc_find_auth_alg_byoid:
  270|    755|{
  271|    755|    int i = 0;
  272|       |
  273|    755|    DEBUGTRACE;
  ------------------
  |  |   63|    755|#define DEBUGTRACE         do {if (_DBG_IF_) {__DBGTRACE;} }while(0)
  |  |  ------------------
  |  |  |  |  144|    755|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 755]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGTRACE         do {if (_DBG_IF_) {__DBGTRACE;} }while(0)
  |  |  ------------------
  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  ------------------
  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  ------------------
  |  |  |  Branch (63:67): [Folded, False: 755]
  |  |  ------------------
  ------------------
  274|       |
  275|    755|    if ((NULL == authoid) || (0 == len))
  ------------------
  |  Branch (275:9): [True: 0, False: 755]
  |  Branch (275:30): [True: 0, False: 755]
  ------------------
  276|      0|        return NULL;
  277|       |
  278|  2.25k|    for( ; _auth_alg_info[i].type != -1; ++i) {
  ------------------
  |  Branch (278:12): [True: 2.25k, False: 0]
  ------------------
  279|  2.25k|        if (len != _auth_alg_info[i].oid_len)
  ------------------
  |  Branch (279:13): [True: 0, False: 2.25k]
  ------------------
  280|      0|            continue;
  281|  2.25k|        if (snmp_oid_compare(_auth_alg_info[i].alg_oid,
  ------------------
  |  Branch (281:13): [True: 755, False: 1.49k]
  ------------------
  282|  2.25k|                             _auth_alg_info[i].oid_len,
  283|  2.25k|                             authoid, len) == 0 )
  284|    755|            return(&_auth_alg_info[i]);
  285|  2.25k|    }
  286|       |
  287|       |/*    DEBUGMSGTL(("scapi", "No auth alg found for"));
  288|       |      DEBUGMSGOID(("scapi", authoid, len ));*/
  289|       |
  290|      0|    return NULL;
  291|    755|}
sc_find_auth_alg_bytype:
  317|    751|{
  318|    751|    int i = 0;
  319|       |
  320|    751|    DEBUGTRACE;
  ------------------
  |  |   63|    751|#define DEBUGTRACE         do {if (_DBG_IF_) {__DBGTRACE;} }while(0)
  |  |  ------------------
  |  |  |  |  144|    751|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 751]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGTRACE         do {if (_DBG_IF_) {__DBGTRACE;} }while(0)
  |  |  ------------------
  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  ------------------
  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  ------------------
  |  |  |  Branch (63:67): [Folded, False: 751]
  |  |  ------------------
  ------------------
  321|       |
  322|  2.24k|    for( ; _auth_alg_info[i].type != -1; ++i) {
  ------------------
  |  Branch (322:12): [True: 2.24k, False: 0]
  ------------------
  323|  2.24k|        if (type != _auth_alg_info[i].type)
  ------------------
  |  Branch (323:13): [True: 1.49k, False: 751]
  ------------------
  324|  1.49k|            continue;
  325|    751|        return(&_auth_alg_info[i]);
  326|  2.24k|    }
  327|       |
  328|      0|    return NULL;
  329|    751|}
sc_get_authtype:
  342|    755|{
  343|    755|    const netsnmp_auth_alg_info *aai;
  344|       |
  345|    755|    DEBUGTRACE;
  ------------------
  |  |   63|    755|#define DEBUGTRACE         do {if (_DBG_IF_) {__DBGTRACE;} }while(0)
  |  |  ------------------
  |  |  |  |  144|    755|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 755]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGTRACE         do {if (_DBG_IF_) {__DBGTRACE;} }while(0)
  |  |  ------------------
  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  ------------------
  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  ------------------
  |  |  |  Branch (63:67): [Folded, False: 755]
  |  |  ------------------
  ------------------
  346|       |
  347|    755|    aai = sc_find_auth_alg_byoid(hashtype, hashtype_len);
  348|    755|    if (NULL == aai)
  ------------------
  |  Branch (348:9): [True: 0, False: 755]
  ------------------
  349|      0|        return SNMPERR_GENERR;
  ------------------
  |  |  185|      0|#define SNMPERR_GENERR			(-1)
  ------------------
  350|       |
  351|    755|    return aai->type;
  352|    755|}
sc_get_proper_auth_length_bytype:
  399|    747|{
  400|    747|    const netsnmp_auth_alg_info *aai;
  401|       |
  402|    747|    DEBUGTRACE;
  ------------------
  |  |   63|    747|#define DEBUGTRACE         do {if (_DBG_IF_) {__DBGTRACE;} }while(0)
  |  |  ------------------
  |  |  |  |  144|    747|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 747]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGTRACE         do {if (_DBG_IF_) {__DBGTRACE;} }while(0)
  |  |  ------------------
  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  ------------------
  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  ------------------
  |  |  |  Branch (63:67): [Folded, False: 747]
  |  |  ------------------
  ------------------
  403|       |
  404|    747|    aai = sc_find_auth_alg_bytype(hashtype);
  405|    747|    if (NULL == aai)
  ------------------
  |  Branch (405:9): [True: 0, False: 747]
  ------------------
  406|      0|        return SNMPERR_GENERR;
  ------------------
  |  |  185|      0|#define SNMPERR_GENERR			(-1)
  ------------------
  407|       |
  408|    747|    return aai->proper_length;
  409|    747|}
sc_get_auth_oid:
  418|      4|{
  419|      4|    const netsnmp_auth_alg_info *ai;
  420|       |
  421|      4|    DEBUGTRACE;
  ------------------
  |  |   63|      4|#define DEBUGTRACE         do {if (_DBG_IF_) {__DBGTRACE;} }while(0)
  |  |  ------------------
  |  |  |  |  144|      4|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 4]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGTRACE         do {if (_DBG_IF_) {__DBGTRACE;} }while(0)
  |  |  ------------------
  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  ------------------
  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  ------------------
  |  |  |  Branch (63:67): [Folded, False: 4]
  |  |  ------------------
  ------------------
  422|       |
  423|      4|    ai = sc_find_auth_alg_bytype(type);
  424|      4|    if (NULL == ai)
  ------------------
  |  Branch (424:9): [True: 0, False: 4]
  ------------------
  425|      0|        return NULL;
  426|       |
  427|      4|    if (NULL != oid_len)
  ------------------
  |  Branch (427:9): [True: 4, False: 0]
  ------------------
  428|      4|        *oid_len = ai->oid_len;
  429|       |
  430|      4|    return ai->alg_oid;
  431|      4|}
sc_init:
  571|      2|{
  572|      2|    int             rval = SNMPERR_SUCCESS;
  ------------------
  |  |  184|      2|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
  573|       |
  574|      2|#if defined(NETSNMP_USE_OPENSSL)
  575|       |#if defined(HAVE_OPENSSL_PROVIDER_H)
  576|       |    if (!sc_initialized) {
  577|       |        sc_initialized = 1;
  578|       |        legacy_provider = OSSL_PROVIDER_load(NULL, "legacy");
  579|       |        if (legacy_provider == NULL)
  580|       |            snmp_log(LOG_WARNING, "Failed to load OpenSSL legacy provider\n");
  581|       |        default_provider = OSSL_PROVIDER_load(NULL, "default");
  582|       |        if (default_provider == NULL)
  583|       |            snmp_log(LOG_WARNING, "Failed to load OpenSSL default provider\n");
  584|       |        snmp_register_callback(SNMP_CALLBACK_LIBRARY,
  585|       |                               SNMP_CALLBACK_SHUTDOWN,
  586|       |                               sc_shutdown, NULL);
  587|       |    }
  588|       |#endif
  589|       |#else /* !NETSNMP_USE_OPENSSL */
  590|       |#if defined(NETSNMP_USE_INTERNAL_MD5) || defined(NETSNMP_USE_INTERNAL_CRYPTO)
  591|       |    struct timeval  tv;
  592|       |
  593|       |    DEBUGTRACE;
  594|       |
  595|       |    gettimeofday(&tv, (struct timezone *) 0);
  596|       |
  597|       |    netsnmp_srandom((unsigned)(tv.tv_sec ^ tv.tv_usec));
  598|       |#elif defined(NETSNMP_USE_PKCS11)
  599|       |    DEBUGTRACE;
  600|       |    rval = pkcs_init();
  601|       |#else
  602|       |    rval = SNMPERR_SC_NOT_CONFIGURED;
  603|       |#endif                           /* NETSNMP_USE_INTERNAL_MD5 */
  604|       |    /*
  605|       |     * XXX ogud: The only reason to do anything here with openssl is to 
  606|       |     * * XXX ogud: seed random number generator 
  607|       |     */
  608|       |#endif                          /* NETSNMP_USE_OPENSSL */
  609|       |
  610|      2|    return rval;
  611|      2|}                               /* end sc_init() */
sc_random:
  626|      6|{
  627|      6|    int             rval = SNMPERR_SUCCESS;
  ------------------
  |  |  184|      6|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
  628|       |#if !defined(NETSNMP_USE_OPENSSL) && !defined(NETSNMP_USE_PKCS11)
  629|       |    int             i;
  630|       |    int             rndval;
  631|       |    u_char         *ucp = buf;
  632|       |#endif
  633|       |
  634|      6|    DEBUGTRACE;
  ------------------
  |  |   63|      6|#define DEBUGTRACE         do {if (_DBG_IF_) {__DBGTRACE;} }while(0)
  |  |  ------------------
  |  |  |  |  144|      6|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 6]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGTRACE         do {if (_DBG_IF_) {__DBGTRACE;} }while(0)
  |  |  ------------------
  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  ------------------
  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  ------------------
  |  |  |  Branch (63:67): [Folded, False: 6]
  |  |  ------------------
  ------------------
  635|       |
  636|      6|#ifdef NETSNMP_USE_OPENSSL
  637|      6|    if (RAND_bytes(buf, *buflen) != 1)
  ------------------
  |  Branch (637:9): [True: 0, False: 6]
  ------------------
  638|      0|        return SNMPERR_GENERR;
  ------------------
  |  |  185|      0|#define SNMPERR_GENERR			(-1)
  ------------------
  639|      6|    MAKE_MEM_DEFINED(buf, *buflen);
  ------------------
  |  |    8|      6|#define MAKE_MEM_DEFINED(ptr, len) do { } while (0)
  |  |  ------------------
  |  |  |  Branch (8:50): [Folded, False: 6]
  |  |  ------------------
  ------------------
  640|       |#elif defined(NETSNMP_USE_PKCS11)  /* NETSNMP_USE_PKCS11 */
  641|       |    rval = pkcs_random(buf, *buflen);
  642|       |#else                           /* NETSNMP_USE_INTERNAL_MD5 */
  643|       |    /*
  644|       |     * fill the buffer with random integers.  Note that random()
  645|       |     * is defined in config.h and may not be truly the random()
  646|       |     * system call if something better existed 
  647|       |     */
  648|       |    rval = *buflen - *buflen % sizeof(rndval);
  649|       |    for (i = 0; i < rval; i += sizeof(rndval)) {
  650|       |        rndval = netsnmp_random();
  651|       |        memcpy(ucp, &rndval, sizeof(rndval));
  652|       |        ucp += sizeof(rndval);
  653|       |    }
  654|       |
  655|       |    rndval = netsnmp_random();
  656|       |    memcpy(ucp, &rndval, *buflen % sizeof(rndval));
  657|       |
  658|       |    rval = SNMPERR_SUCCESS;
  659|       |#endif                          /* NETSNMP_USE_OPENSSL */
  660|      6|    return rval;
  661|       |
  662|      6|}                               /* end sc_random() */
sc_get_openssl_hashfn:
  672|    743|{
  673|    743|    const EVP_MD   *hashfn = NULL;
  674|       |
  675|    743|    DEBUGTRACE;
  ------------------
  |  |   63|    743|#define DEBUGTRACE         do {if (_DBG_IF_) {__DBGTRACE;} }while(0)
  |  |  ------------------
  |  |  |  |  144|    743|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 743]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGTRACE         do {if (_DBG_IF_) {__DBGTRACE;} }while(0)
  |  |  ------------------
  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  ------------------
  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  ------------------
  |  |  |  Branch (63:67): [Folded, False: 743]
  |  |  ------------------
  ------------------
  676|       |
  677|    743|    switch (auth_type) {
  ------------------
  |  Branch (677:13): [True: 743, False: 0]
  ------------------
  678|      0|#ifndef NETSNMP_DISABLE_MD5
  679|    735|        case NETSNMP_USMAUTH_HMACMD5:
  ------------------
  |  |   21|    735|#define NETSNMP_USMAUTH_HMACMD5           2
  ------------------
  |  Branch (679:9): [True: 735, False: 8]
  ------------------
  680|    735|            hashfn = (const EVP_MD *) EVP_md5();
  681|    735|            break;
  682|      0|#endif
  683|      8|        case NETSNMP_USMAUTH_HMACSHA1:
  ------------------
  |  |   22|      8|#define NETSNMP_USMAUTH_HMACSHA1          3
  ------------------
  |  Branch (683:9): [True: 8, False: 735]
  ------------------
  684|      8|            hashfn = (const EVP_MD *) EVP_sha1();
  685|      8|            break;
  686|       |
  687|      0|#ifdef HAVE_EVP_SHA224
  688|      0|        case NETSNMP_USMAUTH_HMAC128SHA224:
  ------------------
  |  |   24|      0|#define NETSNMP_USMAUTH_HMAC128SHA224     4 /* RFC 7860; OPTIONAL */
  ------------------
  |  Branch (688:9): [True: 0, False: 743]
  ------------------
  689|      0|            hashfn = (const EVP_MD *) EVP_sha224();
  690|      0|            break;
  691|       |
  692|      0|        case NETSNMP_USMAUTH_HMAC192SHA256:
  ------------------
  |  |   25|      0|#define NETSNMP_USMAUTH_HMAC192SHA256     5 /* RFC 7860; MUST */
  ------------------
  |  Branch (692:9): [True: 0, False: 743]
  ------------------
  693|      0|            hashfn = (const EVP_MD *) EVP_sha256();
  694|      0|            break;
  695|      0|#endif /* HAVE_EVP_SHA224 */
  696|       |
  697|      0|#ifdef HAVE_EVP_SHA384
  698|      0|        case NETSNMP_USMAUTH_HMAC256SHA384:
  ------------------
  |  |   26|      0|#define NETSNMP_USMAUTH_HMAC256SHA384     6 /* RFC 7860; OPTIONAL */
  ------------------
  |  Branch (698:9): [True: 0, False: 743]
  ------------------
  699|      0|            hashfn = (const EVP_MD *) EVP_sha384();
  700|      0|            break;
  701|       |
  702|      0|        case NETSNMP_USMAUTH_HMAC384SHA512:
  ------------------
  |  |   27|      0|#define NETSNMP_USMAUTH_HMAC384SHA512     7 /* RFC 7860; SHOULD */
  ------------------
  |  Branch (702:9): [True: 0, False: 743]
  ------------------
  703|      0|            hashfn = (const EVP_MD *) EVP_sha512();
  704|      0|            break;
  705|    743|#endif /* HAVE_EVP_SHA384 */
  706|    743|    }
  707|       |
  708|    743|    return hashfn;
  709|    743|}
sc_hash:
  932|    735|{
  933|    735|    int auth_type;
  934|       |
  935|    735|    DEBUGTRACE;
  ------------------
  |  |   63|    735|#define DEBUGTRACE         do {if (_DBG_IF_) {__DBGTRACE;} }while(0)
  |  |  ------------------
  |  |  |  |  144|    735|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 735]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGTRACE         do {if (_DBG_IF_) {__DBGTRACE;} }while(0)
  |  |  ------------------
  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  ------------------
  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  ------------------
  |  |  |  Branch (63:67): [Folded, False: 735]
  |  |  ------------------
  ------------------
  936|       |
  937|    735|    if (hashtype == NULL)
  ------------------
  |  Branch (937:9): [True: 0, False: 735]
  ------------------
  938|      0|        return (SNMPERR_GENERR);
  ------------------
  |  |  185|      0|#define SNMPERR_GENERR			(-1)
  ------------------
  939|       |
  940|    735|    auth_type = sc_get_authtype(hashtype, hashtypelen);
  941|    735|    if (auth_type < 0 )
  ------------------
  |  Branch (941:9): [True: 0, False: 735]
  ------------------
  942|      0|        return (SNMPERR_GENERR);
  ------------------
  |  |  185|      0|#define SNMPERR_GENERR			(-1)
  ------------------
  943|       |
  944|    735|    return sc_hash_type(auth_type, buf, buf_len, MAC, MAC_len);
  945|    735|}
sc_hash_type:
  971|    735|{
  972|    735|#if defined(NETSNMP_USE_OPENSSL) || defined(NETSNMP_USE_PKCS11) || defined(NETSNMP_USE_INTERNAL_CRYPTO)
  973|    735|    int            rval = SNMPERR_SUCCESS;
  ------------------
  |  |  184|    735|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
  974|    735|#endif
  975|    735|#if defined(NETSNMP_USE_OPENSSL) || defined(NETSNMP_USE_PKCS11)
  976|    735|    unsigned int   tmp_len;
  977|    735|#endif
  978|    735|    int            ret;
  979|       |
  980|    735|#ifdef NETSNMP_USE_OPENSSL
  981|    735|    const EVP_MD   *hashfn;
  982|    735|    EVP_MD_CTX     *cptr;
  983|    735|#endif
  984|       |#ifdef NETSNMP_USE_INTERNAL_CRYPTO
  985|       |    MD5_CTX        cmd5;
  986|       |    SHA_CTX        csha1;
  987|       |#endif
  988|    735|    DEBUGTRACE;
  ------------------
  |  |   63|    735|#define DEBUGTRACE         do {if (_DBG_IF_) {__DBGTRACE;} }while(0)
  |  |  ------------------
  |  |  |  |  144|    735|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 735]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGTRACE         do {if (_DBG_IF_) {__DBGTRACE;} }while(0)
  |  |  ------------------
  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  ------------------
  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  ------------------
  |  |  |  Branch (63:67): [Folded, False: 735]
  |  |  ------------------
  ------------------
  989|       |
  990|    735|    if (buf == NULL || buf_len <= 0 || MAC == NULL || MAC_len == NULL )
  ------------------
  |  Branch (990:9): [True: 0, False: 735]
  |  Branch (990:24): [True: 0, False: 735]
  |  Branch (990:40): [True: 0, False: 735]
  |  Branch (990:55): [True: 0, False: 735]
  ------------------
  991|      0|        return (SNMPERR_GENERR);
  ------------------
  |  |  185|      0|#define SNMPERR_GENERR			(-1)
  ------------------
  992|       |
  993|    735|    ret = sc_get_proper_auth_length_bytype(auth_type);
  994|    735|    if (( ret < 0 ) || (*MAC_len < (size_t)ret ))
  ------------------
  |  Branch (994:9): [True: 0, False: 735]
  |  Branch (994:24): [True: 0, False: 735]
  ------------------
  995|      0|        return (SNMPERR_GENERR);
  ------------------
  |  |  185|      0|#define SNMPERR_GENERR			(-1)
  ------------------
  996|       |
  997|    735|#ifdef NETSNMP_USE_OPENSSL
  998|       |    /*
  999|       |     * Determine transform type.
 1000|       |     */
 1001|    735|    hashfn = sc_get_openssl_hashfn(auth_type);
 1002|    735|    if (NULL == hashfn)
  ------------------
  |  Branch (1002:9): [True: 0, False: 735]
  ------------------
 1003|      0|        return SNMPERR_GENERR;
  ------------------
  |  |  185|      0|#define SNMPERR_GENERR			(-1)
  ------------------
 1004|       |
 1005|       |/** initialize the pointer */
 1006|    735|#if defined(HAVE_EVP_MD_CTX_NEW)
 1007|    735|    cptr = EVP_MD_CTX_new();
 1008|       |#elif defined(HAVE_EVP_MD_CTX_CREATE)
 1009|       |    cptr = EVP_MD_CTX_create();
 1010|       |#else
 1011|       |    cptr = malloc(sizeof(*cptr));
 1012|       |#if defined(OLD_DES)
 1013|       |    if (cptr)
 1014|       |        memset(cptr, 0, sizeof(*cptr));
 1015|       |#else
 1016|       |    if (cptr)
 1017|       |        EVP_MD_CTX_init(cptr);
 1018|       |#endif
 1019|       |#endif
 1020|    735|    if (!cptr)
  ------------------
  |  Branch (1020:9): [True: 0, False: 735]
  ------------------
 1021|      0|        return SNMPERR_GENERR;
  ------------------
  |  |  185|      0|#define SNMPERR_GENERR			(-1)
  ------------------
 1022|    735|    if (!EVP_DigestInit(cptr, hashfn)) {
  ------------------
  |  Branch (1022:9): [True: 0, False: 735]
  ------------------
 1023|       |        /* requested hash function is not available */
 1024|      0|        rval = SNMPERR_SC_NOT_CONFIGURED;
  ------------------
  |  |  223|      0|#define SNMPERR_SC_NOT_CONFIGURED	(-39)
  ------------------
 1025|      0|        goto sc_hash_type_quit;
 1026|      0|    }
 1027|       |
 1028|       |/** pass the data and do the final pass */
 1029|    735|    if (!EVP_DigestUpdate(cptr, buf, buf_len) ||
  ------------------
  |  Branch (1029:9): [True: 0, False: 735]
  ------------------
 1030|    735|        !EVP_DigestFinal(cptr, MAC, &tmp_len)) {
  ------------------
  |  Branch (1030:9): [True: 0, False: 735]
  ------------------
 1031|      0|        rval = SNMPERR_GENERR;
  ------------------
  |  |  185|      0|#define SNMPERR_GENERR			(-1)
  ------------------
 1032|      0|        goto sc_hash_type_quit;
 1033|      0|    }
 1034|    735|    *MAC_len = tmp_len;
 1035|       |
 1036|    735|sc_hash_type_quit:
 1037|    735|#if defined(HAVE_EVP_MD_CTX_FREE)
 1038|    735|    EVP_MD_CTX_free(cptr);
 1039|       |#elif defined(HAVE_EVP_MD_CTX_DESTROY)
 1040|       |    EVP_MD_CTX_destroy(cptr);
 1041|       |#else
 1042|       |#if !defined(OLD_DES)
 1043|       |    EVP_MD_CTX_cleanup(cptr);
 1044|       |#endif
 1045|       |    free(cptr);
 1046|       |#endif
 1047|    735|    return (rval);
 1048|       |
 1049|       |#elif defined(NETSNMP_USE_INTERNAL_CRYPTO)
 1050|       |#ifndef NETSNMP_DISABLE_MD5
 1051|       |    if (NETSNMP_USMAUTH_HMACMD5 == auth_type) {
 1052|       |        if (*MAC_len < MD5_DIGEST_LENGTH)
 1053|       |            return (SNMPERR_GENERR);      /* the buffer isn't big enough */
 1054|       |        MD5_Init(&cmd5);
 1055|       |        ret = !MD5_Update(&cmd5, buf, buf_len);
 1056|       |        if (ret != 0)
 1057|       |            return SNMPERR_GENERR;
 1058|       |        MD5_Final(MAC, &cmd5);
 1059|       |        *MAC_len = MD5_DIGEST_LENGTH;
 1060|       |    } else 
 1061|       |#endif
 1062|       |    if (NETSNMP_USMAUTH_HMACSHA1 == auth_type) {
 1063|       |        if (*MAC_len < SHA_DIGEST_LENGTH)
 1064|       |            return (SNMPERR_GENERR);      /* the buffer isn't big enough */
 1065|       |        SHA1_Init(&csha1);
 1066|       |        ret = !SHA1_Update(&csha1, buf, buf_len);
 1067|       |        if (ret != 0)
 1068|       |            return SNMPERR_GENERR;
 1069|       |        SHA1_Final(MAC, &csha1);
 1070|       |        *MAC_len = SHA_DIGEST_LENGTH;
 1071|       |            
 1072|       |    } else {
 1073|       |        return (SNMPERR_GENERR);
 1074|       |    }
 1075|       |    return (rval);
 1076|       |#elif defined(NETSNMP_USE_PKCS11)        /* NETSNMP_USE_PKCS11 */
 1077|       |
 1078|       |#ifndef NETSNMP_DISABLE_MD5
 1079|       |    if (NETSNMP_USMAUTH_HMACMD5 == auth_type) {
 1080|       |        rval = pkcs_digest(CKM_MD5, buf, buf_len, MAC, &tmp_len);
 1081|       |        *MAC_len = tmp_len;
 1082|       |    } else
 1083|       |#endif
 1084|       |    if (NETSNMP_USMAUTH_HMACSHA1 == auth_type) {
 1085|       |       rval = pkcs_digest(CKM_SHA_1, buf, buf_len, MAC, &tmp_len);
 1086|       |        *MAC_len = tmp_len;
 1087|       |    } else {
 1088|       |        return (SNMPERR_GENERR);
 1089|       |    }
 1090|       |
 1091|       |     return (rval);
 1092|       |
 1093|       |#else                           /* NETSNMP_USE_INTERNAL_MD5 */
 1094|       |
 1095|       |    if (MDchecksum(buf, buf_len, MAC, *MAC_len)) {
 1096|       |        return SNMPERR_GENERR;
 1097|       |    }
 1098|       |    if (*MAC_len > 16)
 1099|       |        *MAC_len = 16;
 1100|       |    return SNMPERR_SUCCESS;
 1101|       |
 1102|       |#endif                          /* NETSNMP_USE_OPENSSL */
 1103|    735|}
sc_check_keyed_hash:
 1136|    528|{
 1137|    528|    int             rval = SNMPERR_SUCCESS, auth_type, auth_size;
  ------------------
  |  |  184|    528|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
 1138|    528|    size_t          buf_len = SNMP_MAXBUF_SMALL;
  ------------------
  |  |   45|    528|#define SNMP_MAXBUF_SMALL	512
  ------------------
 1139|       |
 1140|    528|    u_char          buf[SNMP_MAXBUF_SMALL];
 1141|       |
 1142|    528|    DEBUGTRACE;
  ------------------
  |  |   63|    528|#define DEBUGTRACE         do {if (_DBG_IF_) {__DBGTRACE;} }while(0)
  |  |  ------------------
  |  |  |  |  144|    528|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 528]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGTRACE         do {if (_DBG_IF_) {__DBGTRACE;} }while(0)
  |  |  ------------------
  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  ------------------
  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  ------------------
  |  |  |  Branch (63:67): [Folded, False: 528]
  |  |  ------------------
  ------------------
 1143|       |
 1144|       |#ifdef NETSNMP_ENABLE_TESTING_CODE
 1145|       |    {
 1146|       |        int             i;
 1147|       |        DEBUGMSG(("scapi", "sc_check_keyed_hash():    key=0x"));
 1148|       |        for (i = 0; i < keylen; i++)
 1149|       |            DEBUGMSG(("scapi", "%02x", key[i] & 0xff));
 1150|       |        DEBUGMSG(("scapi", " (%d)\n", keylen));
 1151|       |    }
 1152|       |#endif                          /* NETSNMP_ENABLE_TESTING_CODE */
 1153|       |
 1154|       |    /*
 1155|       |     * Sanity check.
 1156|       |     */
 1157|    528|    if (!authtypeOID || !key || !message || !MAC
  ------------------
  |  Branch (1157:9): [True: 0, False: 528]
  |  Branch (1157:25): [True: 528, False: 0]
  |  Branch (1157:33): [True: 0, False: 0]
  |  Branch (1157:45): [True: 0, False: 0]
  ------------------
 1158|    528|        || (keylen <= 0) || (msglen <= 0) || (maclen <= 0)) {
  ------------------
  |  Branch (1158:12): [True: 0, False: 0]
  |  Branch (1158:29): [True: 0, False: 0]
  |  Branch (1158:46): [True: 0, False: 0]
  ------------------
 1159|    528|        QUITFUN(SNMPERR_GENERR, sc_check_keyed_hash_quit);
  ------------------
  |  |  121|    528|#define QUITFUN(e, l) do {                              \
  |  |  122|    528|	if (e != SNMPERR_SUCCESS) {			\
  |  |  ------------------
  |  |  |  |  184|  1.05k|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  ------------------
  |  |  |  Branch (122:6): [True: 528, Folded]
  |  |  ------------------
  |  |  123|    528|		rval = SNMPERR_SC_GENERAL_FAILURE;	\
  |  |  ------------------
  |  |  |  |  222|    528|#define SNMPERR_SC_GENERAL_FAILURE	(-38)
  |  |  ------------------
  |  |  124|    528|		goto l ;				\
  |  |  125|    528|        }                                               \
  |  |  126|    528|    } while (0)
  |  |  ------------------
  |  |  |  Branch (126:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1160|    528|    }
 1161|       |
 1162|      0|    auth_type = sc_get_authtype(authtypeOID, authtypeOIDlen);
 1163|      0|    if (auth_type < 0 )
  ------------------
  |  Branch (1163:9): [True: 0, False: 0]
  ------------------
 1164|      0|        return (SNMPERR_GENERR);
  ------------------
  |  |  185|      0|#define SNMPERR_GENERR			(-1)
  ------------------
 1165|       |
 1166|      0|    auth_size = sc_get_auth_maclen(auth_type);
 1167|      0|    if (0 == auth_size || maclen != auth_size) {
  ------------------
  |  Branch (1167:9): [True: 0, False: 0]
  |  Branch (1167:27): [True: 0, False: 0]
  ------------------
 1168|      0|        QUITFUN(SNMPERR_GENERR, sc_check_keyed_hash_quit);
  ------------------
  |  |  121|      0|#define QUITFUN(e, l) do {                              \
  |  |  122|      0|	if (e != SNMPERR_SUCCESS) {			\
  |  |  ------------------
  |  |  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  ------------------
  |  |  |  Branch (122:6): [True: 0, Folded]
  |  |  ------------------
  |  |  123|      0|		rval = SNMPERR_SC_GENERAL_FAILURE;	\
  |  |  ------------------
  |  |  |  |  222|      0|#define SNMPERR_SC_GENERAL_FAILURE	(-38)
  |  |  ------------------
  |  |  124|      0|		goto l ;				\
  |  |  125|      0|        }                                               \
  |  |  126|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (126:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1169|      0|    }
 1170|       |
 1171|       |    /*
 1172|       |     * Generate a full hash of the message, then compare
 1173|       |     * the result with the given MAC which may be shorter than
 1174|       |     * the full hash length.
 1175|       |     */
 1176|      0|    rval = sc_generate_keyed_hash(authtypeOID, authtypeOIDlen, key, keylen,
 1177|      0|                                  message, msglen, buf, &buf_len);
 1178|      0|    QUITFUN(rval, sc_check_keyed_hash_quit);
  ------------------
  |  |  121|      0|#define QUITFUN(e, l) do {                              \
  |  |  122|      0|	if (e != SNMPERR_SUCCESS) {			\
  |  |  ------------------
  |  |  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  ------------------
  |  |  |  Branch (122:6): [True: 0, False: 0]
  |  |  ------------------
  |  |  123|      0|		rval = SNMPERR_SC_GENERAL_FAILURE;	\
  |  |  ------------------
  |  |  |  |  222|      0|#define SNMPERR_SC_GENERAL_FAILURE	(-38)
  |  |  ------------------
  |  |  124|      0|		goto l ;				\
  |  |  125|      0|        }                                               \
  |  |  126|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (126:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1179|       |
 1180|      0|    if (maclen > msglen) {
  ------------------
  |  Branch (1180:9): [True: 0, False: 0]
  ------------------
 1181|      0|        QUITFUN(SNMPERR_GENERR, sc_check_keyed_hash_quit);
  ------------------
  |  |  121|      0|#define QUITFUN(e, l) do {                              \
  |  |  122|      0|	if (e != SNMPERR_SUCCESS) {			\
  |  |  ------------------
  |  |  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  ------------------
  |  |  |  Branch (122:6): [True: 0, Folded]
  |  |  ------------------
  |  |  123|      0|		rval = SNMPERR_SC_GENERAL_FAILURE;	\
  |  |  ------------------
  |  |  |  |  222|      0|#define SNMPERR_SC_GENERAL_FAILURE	(-38)
  |  |  ------------------
  |  |  124|      0|		goto l ;				\
  |  |  125|      0|        }                                               \
  |  |  126|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (126:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1182|       |
 1183|      0|    } else if (memcmp(buf, MAC, maclen) != 0) {
  ------------------
  |  Branch (1183:16): [True: 0, False: 0]
  ------------------
 1184|      0|        QUITFUN(SNMPERR_GENERR, sc_check_keyed_hash_quit);
  ------------------
  |  |  121|      0|#define QUITFUN(e, l) do {                              \
  |  |  122|      0|	if (e != SNMPERR_SUCCESS) {			\
  |  |  ------------------
  |  |  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  ------------------
  |  |  |  Branch (122:6): [True: 0, Folded]
  |  |  ------------------
  |  |  123|      0|		rval = SNMPERR_SC_GENERAL_FAILURE;	\
  |  |  ------------------
  |  |  |  |  222|      0|#define SNMPERR_SC_GENERAL_FAILURE	(-38)
  |  |  ------------------
  |  |  124|      0|		goto l ;				\
  |  |  125|      0|        }                                               \
  |  |  126|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (126:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1185|      0|    }
 1186|       |
 1187|       |
 1188|    528|  sc_check_keyed_hash_quit:
 1189|    528|    memset(buf, 0, SNMP_MAXBUF_SMALL);
  ------------------
  |  |   45|    528|#define SNMP_MAXBUF_SMALL	512
  ------------------
 1190|       |
 1191|    528|    return rval;
 1192|       |
 1193|      0|}                               /* end sc_check_keyed_hash() */

snmp_parse_var_op:
  161|  1.63k|{
  162|  1.63k|    u_char          var_op_type;
  163|  1.63k|    size_t          var_op_len = *listlength;
  164|  1.63k|    u_char         *var_op_start = data;
  165|       |
  166|  1.63k|    data = asn_parse_sequence(data, &var_op_len, &var_op_type,
  167|  1.63k|                              (ASN_SEQUENCE | ASN_CONSTRUCTOR), "var_op");
  ------------------
  |  |   84|  1.63k|#define ASN_SEQUENCE	    0x10U
  ------------------
                                            (ASN_SEQUENCE | ASN_CONSTRUCTOR), "var_op");
  ------------------
  |  |   96|  1.63k|#define ASN_CONSTRUCTOR	    0x20U
  ------------------
  168|  1.63k|    if (data == NULL) {
  ------------------
  |  Branch (168:9): [True: 334, False: 1.29k]
  ------------------
  169|       |        /*
  170|       |         * msg detail is set 
  171|       |         */
  172|    334|        return NULL;
  173|    334|    }
  174|  1.29k|    DEBUGDUMPHEADER("recv", "Name");
  ------------------
  |  |   79|  1.29k|	do {if (_DBG_IF_) {__DBGDUMPHEADER(token,x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|  1.29k|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 1.29k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               	do {if (_DBG_IF_) {__DBGDUMPHEADER(token,x);} }while(0)
  |  |  ------------------
  |  |  |  |  178|      0|        __DBGPRINTINDENT("dumph_" token); \
  |  |  |  |  ------------------
  |  |  |  |  |  |  175|      0|#define __DBGPRINTINDENT(token) __DBGMSGTL((token, "%*s", __DBGINDENT(), ""))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  179|      0|        debugmsg("dumph_" token,x); \
  |  |  |  |  180|      0|        if (debug_is_token_registered("dumpx" token) == SNMPERR_SUCCESS ||    \
  |  |  |  |  ------------------
  |  |  |  |  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (180:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  181|      0|            debug_is_token_registered("dumpv" token) == SNMPERR_SUCCESS ||    \
  |  |  |  |  ------------------
  |  |  |  |  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (181:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  182|      0|            (debug_is_token_registered("dumpx_" token) != SNMPERR_SUCCESS &&  \
  |  |  |  |  ------------------
  |  |  |  |  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (182:14): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  183|      0|             debug_is_token_registered("dumpv_" token) != SNMPERR_SUCCESS)) { \
  |  |  |  |  ------------------
  |  |  |  |  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:14): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  184|      0|            debugmsg("dumph_" token,"\n"); \
  |  |  |  |  185|      0|        } else { \
  |  |  |  |  186|      0|            debugmsg("dumph_" token,"  "); \
  |  |  |  |  187|      0|        } \
  |  |  |  |  188|      0|        __DBGINDENTMORE()
  |  |  |  |  ------------------
  |  |  |  |  |  |  173|      0|#define __DBGINDENTMORE()  debug_indent_add(2)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (79:55): [Folded, False: 1.29k]
  |  |  ------------------
  ------------------
  175|  1.29k|    data =
  176|  1.29k|        asn_parse_objid(data, &var_op_len, &var_op_type, var_name,
  177|  1.29k|                        var_name_len);
  178|  1.29k|    DEBUGINDENTLESS();
  ------------------
  |  |   75|  1.29k|#define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  144|  1.29k|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 1.29k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  174|      0|#define __DBGINDENTLESS()  debug_indent_add(-2)
  |  |  ------------------
  |  |  |  Branch (75:74): [Folded, False: 1.29k]
  |  |  ------------------
  ------------------
  179|  1.29k|    if (data == NULL) {
  ------------------
  |  Branch (179:9): [True: 28, False: 1.26k]
  ------------------
  180|     28|        ERROR_MSG("No OID for variable");
  ------------------
  |  |  188|     28|#define ERROR_MSG(string)	snmp_set_detail(string)
  ------------------
  181|     28|        return NULL;
  182|     28|    }
  183|  1.26k|    if (var_op_type !=
  ------------------
  |  Branch (183:9): [True: 0, False: 1.26k]
  ------------------
  184|  1.26k|        (u_char) (ASN_UNIVERSAL | ASN_PRIMITIVE | ASN_OBJECT_ID))
  ------------------
  |  |   90|  1.26k|#define ASN_UNIVERSAL	    0x00U
  ------------------
                      (u_char) (ASN_UNIVERSAL | ASN_PRIMITIVE | ASN_OBJECT_ID))
  ------------------
  |  |   95|  1.26k|#define ASN_PRIMITIVE	    0x00U
  ------------------
                      (u_char) (ASN_UNIVERSAL | ASN_PRIMITIVE | ASN_OBJECT_ID))
  ------------------
  |  |   81|  1.26k|#define ASN_OBJECT_ID	    0x06U
  ------------------
  185|      0|        return NULL;
  186|  1.26k|    *var_val = data;            /* save pointer to this object */
  187|       |    /*
  188|       |     * find out what type of object this is 
  189|       |     */
  190|  1.26k|    data = asn_parse_header(data, &var_op_len, var_val_type);
  191|  1.26k|    if (data == NULL) {
  ------------------
  |  Branch (191:9): [True: 11, False: 1.25k]
  ------------------
  192|     11|        ERROR_MSG("No header for value");
  ------------------
  |  |  188|     11|#define ERROR_MSG(string)	snmp_set_detail(string)
  ------------------
  193|     11|        return NULL;
  194|     11|    }
  195|       |    /*
  196|       |     * XXX no check for type! 
  197|       |     */
  198|  1.25k|    *var_val_len = var_op_len;
  199|  1.25k|    data += var_op_len;
  200|  1.25k|    *listlength -= (int) (data - var_op_start);
  201|  1.25k|    return data;
  202|  1.26k|}

init_alarm_post_config:
   63|      2|{
   64|      2|    start_alarms = 1;
   65|      2|    set_an_alarm();
   66|      2|    return SNMPERR_SUCCESS;
  ------------------
  |  |  184|      2|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
   67|      2|}
init_snmp_alarm:
   71|      2|{
   72|      2|    start_alarms = 0;
   73|      2|    snmp_register_callback(SNMP_CALLBACK_LIBRARY,
  ------------------
  |  |   18|      2|#define SNMP_CALLBACK_LIBRARY     0
  ------------------
   74|      2|                           SNMP_CALLBACK_POST_READ_CONFIG,
  ------------------
  |  |   24|      2|#define SNMP_CALLBACK_POST_READ_CONFIG	        0
  ------------------
   75|       |                           init_alarm_post_config, NULL);
   76|      2|}
sa_find_next:
  169|      2|{
  170|      2|    struct snmp_alarm *a, *lowest = NULL;
  171|       |
  172|      2|    for (a = thealarms; a != NULL; a = a->next)
  ------------------
  |  Branch (172:25): [True: 0, False: 2]
  ------------------
  173|      0|        if (!(a->flags & SA_FIRED)
  ------------------
  |  |   29|      0|#define SA_FIRED 0x10          /* Being processed in run_alarms */
  ------------------
  |  Branch (173:13): [True: 0, False: 0]
  ------------------
  174|      0|            && (lowest == NULL || timercmp(&a->t_nextM, &lowest->t_nextM, <)))
  ------------------
  |  Branch (174:17): [True: 0, False: 0]
  |  Branch (174:35): [True: 0, False: 0]
  |  Branch (174:35): [True: 0, False: 0]
  ------------------
  175|      0|            lowest = a;
  176|       |
  177|      2|    return lowest;
  178|      2|}
netsnmp_get_next_alarm_time:
  253|      2|{
  254|      2|    struct snmp_alarm *sa_ptr;
  255|       |
  256|      2|    sa_ptr = sa_find_next();
  257|       |
  258|      2|    if (sa_ptr) {
  ------------------
  |  Branch (258:9): [True: 0, False: 2]
  ------------------
  259|      0|        netsnmp_assert(alarm_tm);
  ------------------
  |  |   47|      0|#      define netsnmp_assert(x)  do { \
  |  |   48|      0|              if ( x ) \
  |  |  ------------------
  |  |  |  Branch (48:20): [True: 0, False: 0]
  |  |  ------------------
  |  |   49|      0|                 ; \
  |  |   50|      0|              else \
  |  |   51|      0|                 snmp_log(LOG_ERR, \
  |  |   52|      0|                          "netsnmp_assert %s failed %s:%d" NETSNMP_FUNC_FMT, \
  |  |  ------------------
  |  |  |  |   40|      0|#          define NETSNMP_FUNC_FMT " %s()\n"
  |  |  ------------------
  |  |   53|      0|                          __STRING(x),__FILE__,__LINE__, \
  |  |   54|      0|                          NETSNMP_FUNC_PARAM); \
  |  |  ------------------
  |  |  |  |   41|      0|#          define NETSNMP_FUNC_PARAM NETSNMP_FUNCTION
  |  |  |  |  ------------------
  |  |  |  |  |  | 1727|      0|#define NETSNMP_FUNCTION __func__
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   55|      0|           }while(0)
  |  |  ------------------
  |  |  |  Branch (55:19): [Folded, False: 0]
  |  |  ------------------
  ------------------
  260|      0|        netsnmp_assert(timerisset(&sa_ptr->t_nextM));
  ------------------
  |  |   47|      0|#      define netsnmp_assert(x)  do { \
  |  |   48|      0|              if ( x ) \
  |  |  ------------------
  |  |  |  Branch (48:20): [True: 0, False: 0]
  |  |  ------------------
  |  |   49|      0|                 ; \
  |  |   50|      0|              else \
  |  |   51|      0|                 snmp_log(LOG_ERR, \
  |  |   52|      0|                          "netsnmp_assert %s failed %s:%d" NETSNMP_FUNC_FMT, \
  |  |  ------------------
  |  |  |  |   40|      0|#          define NETSNMP_FUNC_FMT " %s()\n"
  |  |  ------------------
  |  |   53|      0|                          __STRING(x),__FILE__,__LINE__, \
  |  |   54|      0|                          NETSNMP_FUNC_PARAM); \
  |  |  ------------------
  |  |  |  |   41|      0|#          define NETSNMP_FUNC_PARAM NETSNMP_FUNCTION
  |  |  |  |  ------------------
  |  |  |  |  |  | 1727|      0|#define NETSNMP_FUNCTION __func__
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   55|      0|           }while(0)
  |  |  ------------------
  |  |  |  Branch (55:19): [Folded, False: 0]
  |  |  ------------------
  ------------------
  261|      0|        if (timercmp(&sa_ptr->t_nextM, now, >))
  ------------------
  |  Branch (261:13): [True: 0, False: 0]
  |  Branch (261:13): [True: 0, False: 0]
  ------------------
  262|      0|            *alarm_tm = sa_ptr->t_nextM;
  263|      0|        else
  264|      0|            *alarm_tm = *now;
  265|      0|        return sa_ptr->clientreg;
  266|      2|    } else {
  267|      2|        return 0;
  268|      2|    }
  269|      2|}
get_next_alarm_delay_time:
  282|      2|{
  283|      2|    struct timeval t_now, alarm_tm;
  284|      2|    int res;
  285|       |
  286|      2|    netsnmp_get_monotonic_clock(&t_now);
  287|      2|    res = netsnmp_get_next_alarm_time(&alarm_tm, &t_now);
  288|      2|    if (res)
  ------------------
  |  Branch (288:9): [True: 0, False: 2]
  ------------------
  289|      0|        NETSNMP_TIMERSUB(&alarm_tm, &t_now, delta);
  ------------------
  |  |  173|      0|#define NETSNMP_TIMERSUB(a, b, res) do {                        \
  |  |  174|      0|    (res)->tv_sec  = (a)->tv_sec  - (b)->tv_sec - 1;            \
  |  |  175|      0|    (res)->tv_usec = (a)->tv_usec - (b)->tv_usec + 1000000L;    \
  |  |  176|      0|    if ((res)->tv_usec >= 1000000L) {                           \
  |  |  ------------------
  |  |  |  Branch (176:9): [True: 0, False: 0]
  |  |  ------------------
  |  |  177|      0|        (res)->tv_usec -= 1000000L;                             \
  |  |  178|      0|        (res)->tv_sec++;                                        \
  |  |  179|      0|    }                                                           \
  |  |  180|      0|} while (0)
  |  |  ------------------
  |  |  |  Branch (180:10): [Folded, False: 0]
  |  |  ------------------
  ------------------
  290|      2|    return res;
  291|      2|}
set_an_alarm:
  296|      2|{
  297|      2|    struct timeval  delta;
  298|      2|    int             nextalarm = get_next_alarm_delay_time(&delta);
  299|       |
  300|       |    /*
  301|       |     * We don't use signals if they asked us nicely not to.  It's expected
  302|       |     * they'll check the next alarm time and do their own calling of
  303|       |     * run_alarms().  
  304|       |     */
  305|       |
  306|      2|    if (nextalarm && !netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID,
  ------------------
  |  |   48|      0|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  |  Branch (306:9): [True: 0, False: 2]
  |  Branch (306:22): [True: 0, False: 0]
  ------------------
  307|      0|					NETSNMP_DS_LIB_ALARM_DONT_USE_SIG)) {
  ------------------
  |  |   71|      0|#define NETSNMP_DS_LIB_ALARM_DONT_USE_SIG  11   /* don't use the alarm() signal */
  ------------------
  308|      0|#if defined(HAVE_SETITIMER)
  309|      0|        struct itimerval it;
  310|       |
  311|      0|        it.it_value = delta;
  312|      0|        timerclear(&it.it_interval);
  313|       |
  314|      0|        signal(SIGALRM, alarm_handler);
  315|      0|        setitimer(ITIMER_REAL, &it, NULL);
  316|      0|        DEBUGMSGTL(("snmp_alarm", "schedule alarm %d in %ld.%03ld seconds\n",
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
  317|      0|                    nextalarm, (long) delta.tv_sec, (long)(delta.tv_usec / 1000)));
  318|       |#elif defined(SIGALRM)
  319|       |        signal(SIGALRM, alarm_handler);
  320|       |        alarm(delta.tv_sec);
  321|       |        DEBUGMSGTL(("snmp_alarm",
  322|       |                    "schedule alarm %d in roughly %ld seconds\n", nextalarm,
  323|       |                    delta.tv_sec));
  324|       |#endif
  325|      2|    } else {
  326|      2|        DEBUGMSGTL(("snmp_alarm", "no alarms found to schedule\n"));
  ------------------
  |  |   66|      2|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      2|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 2]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 2]
  |  |  ------------------
  ------------------
  327|      2|    }
  328|      2|}

snmp_get_next_transid:
  498|  3.01k|{
  499|  3.01k|    long            retVal;
  500|  3.01k|    snmp_res_lock(MT_LIBRARY_ID, MT_LIB_TRANSID);
  ------------------
  |  |   79|  3.01k|#define snmp_res_lock(x,y) do {} while (0)
  |  |  ------------------
  |  |  |  Branch (79:41): [Folded, False: 3.01k]
  |  |  ------------------
  ------------------
  501|  3.01k|    retVal = 1 + Transid;       /*MTCRITICAL_RESOURCE */
  502|  3.01k|    if (!retVal)
  ------------------
  |  Branch (502:9): [True: 0, False: 3.01k]
  ------------------
  503|      0|        retVal = 2;
  504|  3.01k|    Transid = retVal;
  505|  3.01k|    if (netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_16BIT_IDS))
  ------------------
  |  |   48|  3.01k|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
                  if (netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_16BIT_IDS))
  ------------------
  |  |   91|  3.01k|#define NETSNMP_DS_LIB_16BIT_IDS           31   /* restrict requestIDs, etc to 16-bit values */
  ------------------
  |  Branch (505:9): [True: 0, False: 3.01k]
  ------------------
  506|      0|        retVal &= 0x7fff;	/* mask to 15 bits */
  507|  3.01k|    else
  508|  3.01k|        retVal &= 0x7fffffff;	/* mask to 31 bits */
  509|       |
  510|  3.01k|    if (!retVal) {
  ------------------
  |  Branch (510:9): [True: 0, False: 3.01k]
  ------------------
  511|      0|        Transid = retVal = 2;
  512|      0|    }
  513|  3.01k|    snmp_res_unlock(MT_LIBRARY_ID, MT_LIB_TRANSID);
  ------------------
  |  |   80|  3.01k|#define snmp_res_unlock(x,y) do {} while (0)
  |  |  ------------------
  |  |  |  Branch (80:43): [Folded, False: 3.01k]
  |  |  ------------------
  ------------------
  514|  3.01k|    return retVal;
  515|  3.01k|}
snmp_set_detail:
  529|  10.1k|{
  530|  10.1k|    if (detail_string != NULL) {
  ------------------
  |  Branch (530:9): [True: 10.1k, False: 0]
  ------------------
  531|  10.1k|        strlcpy(snmp_detail, detail_string, sizeof(snmp_detail));
  532|  10.1k|        snmp_detail_f = 1;
  533|  10.1k|    }
  534|  10.1k|}
snmp_api_errstring:
  544|    586|{
  545|    586|    const char     *msg = "";
  546|    586|    static char     msg_buf[SPRINT_MAX_LEN];
  547|       |
  548|    586|    if (snmp_errnumber >= SNMPERR_MAX && snmp_errnumber <= SNMPERR_GENERR) {
  ------------------
  |  |  255|  1.17k|#define SNMPERR_MAX			(-69)
  ------------------
                  if (snmp_errnumber >= SNMPERR_MAX && snmp_errnumber <= SNMPERR_GENERR) {
  ------------------
  |  |  185|    586|#define SNMPERR_GENERR			(-1)
  ------------------
  |  Branch (548:9): [True: 586, False: 0]
  |  Branch (548:42): [True: 0, False: 586]
  ------------------
  549|      0|        msg = api_errors[-snmp_errnumber];
  550|    586|    } else if (snmp_errnumber != SNMPERR_SUCCESS) {
  ------------------
  |  |  184|    586|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
  |  Branch (550:16): [True: 0, False: 586]
  ------------------
  551|      0|        msg = NULL;
  552|      0|    }
  553|    586|    if (!msg) {
  ------------------
  |  Branch (553:9): [True: 0, False: 586]
  ------------------
  554|      0|	snprintf(msg_buf, sizeof(msg_buf), "Unknown error: %d", snmp_errnumber);
  555|      0|        msg_buf[sizeof(msg_buf)-1] = '\0';
  556|    586|    } else if (snmp_detail_f) {
  ------------------
  |  Branch (556:16): [True: 586, False: 0]
  ------------------
  557|    586|        snprintf(msg_buf, sizeof(msg_buf), "%s (%s)", msg, snmp_detail);
  558|    586|        msg_buf[sizeof(msg_buf)-1] = '\0';
  559|    586|        snmp_detail_f = 0;
  560|    586|    } else {
  561|      0|        strlcpy(msg_buf, msg, sizeof(msg_buf));
  562|      0|    }
  563|       |
  564|    586|    return (msg_buf);
  565|    586|}
netsnmp_random:
  652|      6|{
  653|      6|#if defined(HAVE_RANDOM)
  654|       |    /*
  655|       |     * The function random() is a more sophisticated random number generator
  656|       |     * which uses nonlinear feedback and an internal table that is 124 bytes
  657|       |     * (992 bits) long. The function returns random values that are 32 bits in
  658|       |     * length. All of the bits generated by random() are usable. The random()
  659|       |     * function is adequate for simulations and games, but should not be used
  660|       |     * for security related applications such as picking cryptographic keys or
  661|       |     * simulating one-time pads.
  662|       |     */
  663|      6|    return random();
  664|       |#elif defined(HAVE_LRAND48)
  665|       |    /*
  666|       |     * As with random(), lrand48() provides excellent random numbers for
  667|       |     * simulations and games, but should not be used for security-related
  668|       |     * applications such as picking cryptographic keys or simulating one-time
  669|       |     * pads; linear congruential algorithms are too easy to break.
  670|       |     */
  671|       |    return lrand48();
  672|       |#elif defined(HAVE_RAND)
  673|       |    /*
  674|       |     * The original UNIX random number generator, rand(), is not a very good
  675|       |     * random number generator. It uses a 32-bit seed and maintains a 32-bit
  676|       |     * internal state.
  677|       |     */
  678|       |    return rand();
  679|       |#else
  680|       |#error "Neither random(), nor lrand48() nor rand() are available"
  681|       |#endif
  682|      6|}
netsnmp_srandom:
  685|      2|{
  686|      2|#if defined(HAVE_SRANDOM)
  687|      2|    srandom(seed);
  688|       |#elif defined(HAVE_SRAND48)
  689|       |    srand48(seed);
  690|       |#elif defined(HAVE_SRAND)
  691|       |    srand(seed);
  692|       |#else
  693|       |#error "Neither srandom(), nor srand48() nor srand() are available"
  694|       |#endif
  695|      2|}
init_snmp:
  892|      2|{
  893|      2|    if (init_snmp_init_done) {
  ------------------
  |  Branch (893:9): [True: 0, False: 2]
  ------------------
  894|      0|        return;
  895|      0|    }
  896|       |
  897|      2|    init_snmp_init_done = 1;
  898|       |
  899|       |    /*
  900|       |     * make the type available everywhere else 
  901|       |     */
  902|      2|    if (type && !netsnmp_ds_get_string(NETSNMP_DS_LIBRARY_ID, 
  ------------------
  |  |   48|      2|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  |  Branch (902:9): [True: 2, False: 0]
  |  Branch (902:17): [True: 2, False: 0]
  ------------------
  903|      2|				       NETSNMP_DS_LIB_APPTYPE)) {
  ------------------
  |  |  157|      2|#define NETSNMP_DS_LIB_APPTYPE           6
  ------------------
  904|      2|        netsnmp_ds_set_string(NETSNMP_DS_LIBRARY_ID, 
  ------------------
  |  |   48|      2|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  905|      2|			      NETSNMP_DS_LIB_APPTYPE, type);
  ------------------
  |  |  157|      2|#define NETSNMP_DS_LIB_APPTYPE           6
  ------------------
  906|      2|    }
  907|       |
  908|      2|    _init_snmp();
  909|       |
  910|       |    /*
  911|       |     * set our current locale properly to initialize isprint() type functions 
  912|       |     *
  913|       |     * Do not use setlocale on qnx, it is buggy 
  914|       |     * https://www.qnx.com/developers/docs/7.1/#com.qnx.doc.neutrino.lib_ref/topic/s/setlocale.html
  915|       |     */
  916|      2|#if defined(HAVE_SETLOCALE) && !defined(__QNX__)
  917|      2|    setlocale(LC_CTYPE, "");
  918|      2|#endif
  919|       |
  920|      2|    snmp_debug_init();    /* should be done first, to turn on debugging ASAP */
  921|      2|    netsnmp_container_init_list();
  922|      2|    init_callbacks();
  923|      2|    init_snmp_logging();
  924|      2|    snmp_init_statistics();
  925|      2|    register_mib_handlers();
  926|      2|    register_default_handlers();
  927|      2|    init_snmp_transport();
  928|      2|    init_snmpv3(type);
  929|      2|    init_snmp_alarm();
  930|      2|    init_snmp_enum(type);
  931|      2|    init_vacm();
  932|      2|#if defined(NETSNMP_USE_OPENSSL) && defined(HAVE_LIBSSL) && NETSNMP_TRANSPORT_TLSBASE_DOMAIN
  933|      2|    netsnmp_certs_init();
  934|      2|#endif
  935|       |#ifdef DNSSEC_LOCAL_VALIDATION
  936|       |    netsnmp_ds_register_config(ASN_BOOLEAN, "snmp", "dnssecWarnOnly",
  937|       |                               NETSNMP_DS_LIBRARY_ID,
  938|       |                               NETSNMP_DS_LIB_DNSSEC_WARN_ONLY);
  939|       |#endif
  940|       |
  941|      2|    read_premib_configs();
  942|      2|#ifndef NETSNMP_DISABLE_MIB_LOADING
  943|      2|    netsnmp_init_mib();
  944|      2|#endif /* NETSNMP_DISABLE_MIB_LOADING */
  945|       |
  946|      2|    read_configs();
  947|       |
  948|      2|}                               /* end init_snmp() */
netsnmp_cleanup_session:
 2064|  3.01k|{
 2065|  3.01k|    free(s->localname);
 2066|  3.01k|    free(s->peername);
 2067|  3.01k|    free(s->community);
 2068|  3.01k|    free(s->contextEngineID);
 2069|  3.01k|    free(s->contextName);
 2070|  3.01k|    free(s->securityEngineID);
 2071|  3.01k|    free(s->securityName);
 2072|  3.01k|    free(s->securityAuthProto);
 2073|  3.01k|    free(s->securityAuthLocalKey);
 2074|  3.01k|    free(s->securityPrivProto);
 2075|  3.01k|    free(s->securityPrivLocalKey);
 2076|  3.01k|    free(s->paramName);
 2077|  3.01k|#ifndef NETSNMP_NO_TRAP_STATS
 2078|  3.01k|    free(s->trap_stats);
 2079|  3.01k|#endif /* NETSNMP_NO_TRAP_STATS */
 2080|  3.01k|    usm_free_user(s->sessUser);
 2081|  3.01k|    netsnmp_free_transport_config(s->transport_configuration);
 2082|  3.01k|    memset(s, 0, sizeof(*s));
 2083|  3.01k|}
snmpv3_parse:
 3896|  3.01k|{
 3897|  3.01k|    u_char          type, msg_flags;
 3898|  3.01k|    long            ver, msg_sec_model;
 3899|  3.01k|    size_t          max_size_response;
 3900|  3.01k|    u_char          tmp_buf[SNMP_MAX_MSG_SIZE];
 3901|  3.01k|    size_t          tmp_buf_len;
 3902|  3.01k|    u_char          pdu_buf[SNMP_MAX_MSG_SIZE];
 3903|  3.01k|    u_char         *mallocbuf = NULL;
 3904|  3.01k|    size_t          pdu_buf_len = SNMP_MAX_MSG_SIZE;
  ------------------
  |  |  109|  3.01k|#define SNMP_MAX_MSG_SIZE          1472 /* ethernet MTU minus IP/UDP header */
  ------------------
 3905|  3.01k|    u_char         *sec_params;
 3906|  3.01k|    u_char         *msg_data;
 3907|  3.01k|    u_char         *cp;
 3908|  3.01k|    size_t          asn_len, msg_len;
 3909|  3.01k|    int             ret, ret_val;
 3910|  3.01k|    struct snmp_secmod_def *sptr;
 3911|       |
 3912|       |
 3913|  3.01k|    msg_data = data;
 3914|  3.01k|    msg_len = *length;
 3915|       |
 3916|       |
 3917|       |    /*
 3918|       |     * message is an ASN.1 SEQUENCE  
 3919|       |     */
 3920|  3.01k|    DEBUGDUMPSECTION("recv", "SNMPv3 Message");
  ------------------
  |  |   81|  3.01k|	do {if (_DBG_IF_) {__DBGDUMPSECTION(token,x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|  3.01k|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 3.01k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               	do {if (_DBG_IF_) {__DBGDUMPSECTION(token,x);} }while(0)
  |  |  ------------------
  |  |  |  |  191|      0|        __DBGPRINTINDENT("dumph_" token); \
  |  |  |  |  ------------------
  |  |  |  |  |  |  175|      0|#define __DBGPRINTINDENT(token) __DBGMSGTL((token, "%*s", __DBGINDENT(), ""))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  192|      0|        debugmsg("dumph_" token,"%s\n",x);\
  |  |  |  |  193|      0|        __DBGINDENTMORE()
  |  |  |  |  ------------------
  |  |  |  |  |  |  173|      0|#define __DBGINDENTMORE()  debug_indent_add(2)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (81:56): [Folded, False: 3.01k]
  |  |  ------------------
  ------------------
 3921|  3.01k|    data = asn_parse_sequence(data, length, &type,
 3922|  3.01k|                              (ASN_SEQUENCE | ASN_CONSTRUCTOR), "message");
  ------------------
  |  |   84|  3.01k|#define ASN_SEQUENCE	    0x10U
  ------------------
                                            (ASN_SEQUENCE | ASN_CONSTRUCTOR), "message");
  ------------------
  |  |   96|  3.01k|#define ASN_CONSTRUCTOR	    0x20U
  ------------------
 3923|  3.01k|    if (data == NULL) {
  ------------------
  |  Branch (3923:9): [True: 290, False: 2.72k]
  ------------------
 3924|       |        /*
 3925|       |         * error msg detail is set 
 3926|       |         */
 3927|    290|        snmp_increment_statistic(STAT_SNMPINASNPARSEERRS);
  ------------------
  |  |  637|    290|#define  STAT_SNMPINASNPARSEERRS             14
  ------------------
 3928|    290|        DEBUGINDENTLESS();
  ------------------
  |  |   75|    290|#define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  144|    290|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 290]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  174|      0|#define __DBGINDENTLESS()  debug_indent_add(-2)
  |  |  ------------------
  |  |  |  Branch (75:74): [Folded, False: 290]
  |  |  ------------------
  ------------------
 3929|    290|        return SNMPERR_ASN_PARSE_ERR;
  ------------------
  |  |  213|    290|#define SNMPERR_ASN_PARSE_ERR           (-29)
  ------------------
 3930|    290|    }
 3931|       |
 3932|       |    /*
 3933|       |     * parse msgVersion  
 3934|       |     */
 3935|  2.72k|    DEBUGDUMPHEADER("recv", "SNMP Version Number");
  ------------------
  |  |   79|  2.72k|	do {if (_DBG_IF_) {__DBGDUMPHEADER(token,x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|  2.72k|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 2.72k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               	do {if (_DBG_IF_) {__DBGDUMPHEADER(token,x);} }while(0)
  |  |  ------------------
  |  |  |  |  178|      0|        __DBGPRINTINDENT("dumph_" token); \
  |  |  |  |  ------------------
  |  |  |  |  |  |  175|      0|#define __DBGPRINTINDENT(token) __DBGMSGTL((token, "%*s", __DBGINDENT(), ""))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  179|      0|        debugmsg("dumph_" token,x); \
  |  |  |  |  180|      0|        if (debug_is_token_registered("dumpx" token) == SNMPERR_SUCCESS ||    \
  |  |  |  |  ------------------
  |  |  |  |  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (180:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  181|      0|            debug_is_token_registered("dumpv" token) == SNMPERR_SUCCESS ||    \
  |  |  |  |  ------------------
  |  |  |  |  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (181:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  182|      0|            (debug_is_token_registered("dumpx_" token) != SNMPERR_SUCCESS &&  \
  |  |  |  |  ------------------
  |  |  |  |  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (182:14): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  183|      0|             debug_is_token_registered("dumpv_" token) != SNMPERR_SUCCESS)) { \
  |  |  |  |  ------------------
  |  |  |  |  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:14): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  184|      0|            debugmsg("dumph_" token,"\n"); \
  |  |  |  |  185|      0|        } else { \
  |  |  |  |  186|      0|            debugmsg("dumph_" token,"  "); \
  |  |  |  |  187|      0|        } \
  |  |  |  |  188|      0|        __DBGINDENTMORE()
  |  |  |  |  ------------------
  |  |  |  |  |  |  173|      0|#define __DBGINDENTMORE()  debug_indent_add(2)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (79:55): [Folded, False: 2.72k]
  |  |  ------------------
  ------------------
 3936|  2.72k|    data = asn_parse_int(data, length, &type, &ver, sizeof(ver));
 3937|  2.72k|    DEBUGINDENTLESS();
  ------------------
  |  |   75|  2.72k|#define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  144|  2.72k|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 2.72k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  174|      0|#define __DBGINDENTLESS()  debug_indent_add(-2)
  |  |  ------------------
  |  |  |  Branch (75:74): [Folded, False: 2.72k]
  |  |  ------------------
  ------------------
 3938|  2.72k|    if (data == NULL) {
  ------------------
  |  Branch (3938:9): [True: 152, False: 2.57k]
  ------------------
 3939|    152|        ERROR_MSG("bad parse of version");
  ------------------
  |  |  188|    152|#define ERROR_MSG(string)	snmp_set_detail(string)
  ------------------
 3940|    152|        snmp_increment_statistic(STAT_SNMPINASNPARSEERRS);
  ------------------
  |  |  637|    152|#define  STAT_SNMPINASNPARSEERRS             14
  ------------------
 3941|    152|        DEBUGINDENTLESS();
  ------------------
  |  |   75|    152|#define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  144|    152|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 152]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  174|      0|#define __DBGINDENTLESS()  debug_indent_add(-2)
  |  |  ------------------
  |  |  |  Branch (75:74): [Folded, False: 152]
  |  |  ------------------
  ------------------
 3942|    152|        return SNMPERR_ASN_PARSE_ERR;
  ------------------
  |  |  213|    152|#define SNMPERR_ASN_PARSE_ERR           (-29)
  ------------------
 3943|    152|    }
 3944|  2.57k|    pdu->version = ver;
 3945|       |
 3946|       |    /*
 3947|       |     * parse msgGlobalData sequence  
 3948|       |     */
 3949|  2.57k|    cp = data;
 3950|  2.57k|    asn_len = *length;
 3951|  2.57k|    DEBUGDUMPSECTION("recv", "msgGlobalData");
  ------------------
  |  |   81|  2.57k|	do {if (_DBG_IF_) {__DBGDUMPSECTION(token,x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|  2.57k|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 2.57k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               	do {if (_DBG_IF_) {__DBGDUMPSECTION(token,x);} }while(0)
  |  |  ------------------
  |  |  |  |  191|      0|        __DBGPRINTINDENT("dumph_" token); \
  |  |  |  |  ------------------
  |  |  |  |  |  |  175|      0|#define __DBGPRINTINDENT(token) __DBGMSGTL((token, "%*s", __DBGINDENT(), ""))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  192|      0|        debugmsg("dumph_" token,"%s\n",x);\
  |  |  |  |  193|      0|        __DBGINDENTMORE()
  |  |  |  |  ------------------
  |  |  |  |  |  |  173|      0|#define __DBGINDENTMORE()  debug_indent_add(2)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (81:56): [Folded, False: 2.57k]
  |  |  ------------------
  ------------------
 3952|  2.57k|    data = asn_parse_sequence(data, &asn_len, &type,
 3953|  2.57k|                              (ASN_SEQUENCE | ASN_CONSTRUCTOR),
  ------------------
  |  |   84|  2.57k|#define ASN_SEQUENCE	    0x10U
  ------------------
                                            (ASN_SEQUENCE | ASN_CONSTRUCTOR),
  ------------------
  |  |   96|  2.57k|#define ASN_CONSTRUCTOR	    0x20U
  ------------------
 3954|  2.57k|                              "msgGlobalData");
 3955|  2.57k|    if (data == NULL) {
  ------------------
  |  Branch (3955:9): [True: 167, False: 2.40k]
  ------------------
 3956|       |        /*
 3957|       |         * error msg detail is set 
 3958|       |         */
 3959|    167|        snmp_increment_statistic(STAT_SNMPINASNPARSEERRS);
  ------------------
  |  |  637|    167|#define  STAT_SNMPINASNPARSEERRS             14
  ------------------
 3960|    167|        DEBUGINDENTADD(-4);
  ------------------
  |  |   73|    167|#define DEBUGINDENTADD(x)  do {if (_DBG_IF_) {__DBGINDENTADD(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|    167|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 167]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGINDENTADD(x)  do {if (_DBG_IF_) {__DBGINDENTADD(x);} }while(0)
  |  |  ------------------
  |  |  |  |  172|      0|#define __DBGINDENTADD(x)  debug_indent_add(x)
  |  |  ------------------
  |  |  |  Branch (73:74): [Folded, False: 167]
  |  |  ------------------
  ------------------
 3961|    167|        return SNMPERR_ASN_PARSE_ERR;
  ------------------
  |  |  213|    167|#define SNMPERR_ASN_PARSE_ERR           (-29)
  ------------------
 3962|    167|    }
 3963|  2.40k|    *length -= data - cp;       /* subtract off the length of the header */
 3964|       |
 3965|       |    /*
 3966|       |     * msgID 
 3967|       |     */
 3968|  2.40k|    DEBUGDUMPHEADER("recv", "msgID");
  ------------------
  |  |   79|  2.40k|	do {if (_DBG_IF_) {__DBGDUMPHEADER(token,x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|  2.40k|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 2.40k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               	do {if (_DBG_IF_) {__DBGDUMPHEADER(token,x);} }while(0)
  |  |  ------------------
  |  |  |  |  178|      0|        __DBGPRINTINDENT("dumph_" token); \
  |  |  |  |  ------------------
  |  |  |  |  |  |  175|      0|#define __DBGPRINTINDENT(token) __DBGMSGTL((token, "%*s", __DBGINDENT(), ""))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  179|      0|        debugmsg("dumph_" token,x); \
  |  |  |  |  180|      0|        if (debug_is_token_registered("dumpx" token) == SNMPERR_SUCCESS ||    \
  |  |  |  |  ------------------
  |  |  |  |  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (180:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  181|      0|            debug_is_token_registered("dumpv" token) == SNMPERR_SUCCESS ||    \
  |  |  |  |  ------------------
  |  |  |  |  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (181:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  182|      0|            (debug_is_token_registered("dumpx_" token) != SNMPERR_SUCCESS &&  \
  |  |  |  |  ------------------
  |  |  |  |  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (182:14): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  183|      0|             debug_is_token_registered("dumpv_" token) != SNMPERR_SUCCESS)) { \
  |  |  |  |  ------------------
  |  |  |  |  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:14): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  184|      0|            debugmsg("dumph_" token,"\n"); \
  |  |  |  |  185|      0|        } else { \
  |  |  |  |  186|      0|            debugmsg("dumph_" token,"  "); \
  |  |  |  |  187|      0|        } \
  |  |  |  |  188|      0|        __DBGINDENTMORE()
  |  |  |  |  ------------------
  |  |  |  |  |  |  173|      0|#define __DBGINDENTMORE()  debug_indent_add(2)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (79:55): [Folded, False: 2.40k]
  |  |  ------------------
  ------------------
 3969|  2.40k|    data =
 3970|  2.40k|        asn_parse_int(data, length, &type, &pdu->msgid,
 3971|  2.40k|                      sizeof(pdu->msgid));
 3972|  2.40k|    DEBUGINDENTLESS();
  ------------------
  |  |   75|  2.40k|#define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  144|  2.40k|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 2.40k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  174|      0|#define __DBGINDENTLESS()  debug_indent_add(-2)
  |  |  ------------------
  |  |  |  Branch (75:74): [Folded, False: 2.40k]
  |  |  ------------------
  ------------------
 3973|  2.40k|    if (data == NULL || type != ASN_INTEGER) {
  ------------------
  |  |   75|  2.40k|#define ASN_INTEGER	    0x02U
  ------------------
  |  Branch (3973:9): [True: 3, False: 2.40k]
  |  Branch (3973:25): [True: 0, False: 2.40k]
  ------------------
 3974|      3|        ERROR_MSG("error parsing msgID");
  ------------------
  |  |  188|      3|#define ERROR_MSG(string)	snmp_set_detail(string)
  ------------------
 3975|      3|        DEBUGINDENTADD(-4);
  ------------------
  |  |   73|      3|#define DEBUGINDENTADD(x)  do {if (_DBG_IF_) {__DBGINDENTADD(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      3|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 3]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGINDENTADD(x)  do {if (_DBG_IF_) {__DBGINDENTADD(x);} }while(0)
  |  |  ------------------
  |  |  |  |  172|      0|#define __DBGINDENTADD(x)  debug_indent_add(x)
  |  |  ------------------
  |  |  |  Branch (73:74): [Folded, False: 3]
  |  |  ------------------
  ------------------
 3976|      3|        snmp_increment_statistic(STAT_SNMPINASNPARSEERRS);
  ------------------
  |  |  637|      3|#define  STAT_SNMPINASNPARSEERRS             14
  ------------------
 3977|      3|        return SNMPERR_ASN_PARSE_ERR;
  ------------------
  |  |  213|      3|#define SNMPERR_ASN_PARSE_ERR           (-29)
  ------------------
 3978|      3|    }
 3979|       |
 3980|       |    /*
 3981|       |     * Check the msgID we received is a legal value.  If not, then increment
 3982|       |     * snmpInASNParseErrs and return the appropriate error (see RFC 2572,
 3983|       |     * para. 7.2, section 2 -- note that a bad msgID means that the received
 3984|       |     * message is NOT a serialization of an SNMPv3Message, since the msgID
 3985|       |     * field is out of bounds).  
 3986|       |     */
 3987|       |
 3988|  2.40k|    if (pdu->msgid < 0 || pdu->msgid > SNMP_MAX_PACKET_LEN) {
  ------------------
  |  |   49|  2.35k|#define SNMP_MAX_PACKET_LEN (0x7fffffff)
  ------------------
  |  Branch (3988:9): [True: 45, False: 2.35k]
  |  Branch (3988:27): [True: 2, False: 2.35k]
  ------------------
 3989|     47|        snmp_log(LOG_ERR, "Received bad msgID (%ld %s %s).\n", pdu->msgid,
 3990|     47|                 (pdu->msgid < 0) ? "<" : ">",
  ------------------
  |  Branch (3990:18): [True: 45, False: 2]
  ------------------
 3991|     47|                 (pdu->msgid < 0) ? "0" : "2^31 - 1");
  ------------------
  |  Branch (3991:18): [True: 45, False: 2]
  ------------------
 3992|     47|        snmp_increment_statistic(STAT_SNMPINASNPARSEERRS);
  ------------------
  |  |  637|     47|#define  STAT_SNMPINASNPARSEERRS             14
  ------------------
 3993|     47|        DEBUGINDENTADD(-4);
  ------------------
  |  |   73|     47|#define DEBUGINDENTADD(x)  do {if (_DBG_IF_) {__DBGINDENTADD(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     47|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 47]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGINDENTADD(x)  do {if (_DBG_IF_) {__DBGINDENTADD(x);} }while(0)
  |  |  ------------------
  |  |  |  |  172|      0|#define __DBGINDENTADD(x)  debug_indent_add(x)
  |  |  ------------------
  |  |  |  Branch (73:74): [Folded, False: 47]
  |  |  ------------------
  ------------------
 3994|     47|        return SNMPERR_ASN_PARSE_ERR;
  ------------------
  |  |  213|     47|#define SNMPERR_ASN_PARSE_ERR           (-29)
  ------------------
 3995|     47|    }
 3996|       |
 3997|       |    /*
 3998|       |     * msgMaxSize 
 3999|       |     */
 4000|  2.35k|    DEBUGDUMPHEADER("recv:msgMaxSize", "msgMaxSize");
  ------------------
  |  |   79|  2.35k|	do {if (_DBG_IF_) {__DBGDUMPHEADER(token,x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|  2.35k|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 2.35k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               	do {if (_DBG_IF_) {__DBGDUMPHEADER(token,x);} }while(0)
  |  |  ------------------
  |  |  |  |  178|      0|        __DBGPRINTINDENT("dumph_" token); \
  |  |  |  |  ------------------
  |  |  |  |  |  |  175|      0|#define __DBGPRINTINDENT(token) __DBGMSGTL((token, "%*s", __DBGINDENT(), ""))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  179|      0|        debugmsg("dumph_" token,x); \
  |  |  |  |  180|      0|        if (debug_is_token_registered("dumpx" token) == SNMPERR_SUCCESS ||    \
  |  |  |  |  ------------------
  |  |  |  |  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (180:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  181|      0|            debug_is_token_registered("dumpv" token) == SNMPERR_SUCCESS ||    \
  |  |  |  |  ------------------
  |  |  |  |  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (181:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  182|      0|            (debug_is_token_registered("dumpx_" token) != SNMPERR_SUCCESS &&  \
  |  |  |  |  ------------------
  |  |  |  |  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (182:14): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  183|      0|             debug_is_token_registered("dumpv_" token) != SNMPERR_SUCCESS)) { \
  |  |  |  |  ------------------
  |  |  |  |  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:14): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  184|      0|            debugmsg("dumph_" token,"\n"); \
  |  |  |  |  185|      0|        } else { \
  |  |  |  |  186|      0|            debugmsg("dumph_" token,"  "); \
  |  |  |  |  187|      0|        } \
  |  |  |  |  188|      0|        __DBGINDENTMORE()
  |  |  |  |  ------------------
  |  |  |  |  |  |  173|      0|#define __DBGINDENTMORE()  debug_indent_add(2)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (79:55): [Folded, False: 2.35k]
  |  |  ------------------
  ------------------
 4001|  2.35k|    data = asn_parse_int(data, length, &type, &pdu->msgMaxSize,
 4002|  2.35k|                         sizeof(pdu->msgMaxSize));
 4003|  2.35k|    DEBUGINDENTLESS();
  ------------------
  |  |   75|  2.35k|#define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  144|  2.35k|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 2.35k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  174|      0|#define __DBGINDENTLESS()  debug_indent_add(-2)
  |  |  ------------------
  |  |  |  Branch (75:74): [Folded, False: 2.35k]
  |  |  ------------------
  ------------------
 4004|  2.35k|    if (data == NULL || type != ASN_INTEGER) {
  ------------------
  |  |   75|  2.30k|#define ASN_INTEGER	    0x02U
  ------------------
  |  Branch (4004:9): [True: 55, False: 2.30k]
  |  Branch (4004:25): [True: 0, False: 2.30k]
  ------------------
 4005|     55|        ERROR_MSG("error parsing msgMaxSize");
  ------------------
  |  |  188|     55|#define ERROR_MSG(string)	snmp_set_detail(string)
  ------------------
 4006|     55|        snmp_increment_statistic(STAT_SNMPINASNPARSEERRS);
  ------------------
  |  |  637|     55|#define  STAT_SNMPINASNPARSEERRS             14
  ------------------
 4007|     55|        DEBUGINDENTADD(-4);
  ------------------
  |  |   73|     55|#define DEBUGINDENTADD(x)  do {if (_DBG_IF_) {__DBGINDENTADD(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     55|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 55]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGINDENTADD(x)  do {if (_DBG_IF_) {__DBGINDENTADD(x);} }while(0)
  |  |  ------------------
  |  |  |  |  172|      0|#define __DBGINDENTADD(x)  debug_indent_add(x)
  |  |  ------------------
  |  |  |  Branch (73:74): [Folded, False: 55]
  |  |  ------------------
  ------------------
 4008|     55|        return SNMPERR_ASN_PARSE_ERR;
  ------------------
  |  |  213|     55|#define SNMPERR_ASN_PARSE_ERR           (-29)
  ------------------
 4009|     55|    }
 4010|       |
 4011|       |    /*
 4012|       |     * Check the msgMaxSize we received is a legal value.  If not, then
 4013|       |     * increment snmpInASNParseErrs and return the appropriate error (see RFC
 4014|       |     * 2572, para. 7.2, section 2 -- note that a bad msgMaxSize means that the
 4015|       |     * received message is NOT a serialization of an SNMPv3Message, since the
 4016|       |     * msgMaxSize field is out of bounds).
 4017|       |     */
 4018|       |
 4019|  2.30k|    if (pdu->msgMaxSize < SNMP_MIN_MAX_LEN) {
  ------------------
  |  |   48|  2.30k|#define SNMP_MIN_MAX_LEN    484 /* minimum maximum message size */
  ------------------
  |  Branch (4019:9): [True: 54, False: 2.24k]
  ------------------
 4020|     54|        snmp_log(LOG_ERR, "Received bad msgMaxSize (%lu < 484).\n",
 4021|     54|                 pdu->msgMaxSize);
 4022|     54|        snmp_increment_statistic(STAT_SNMPINASNPARSEERRS);
  ------------------
  |  |  637|     54|#define  STAT_SNMPINASNPARSEERRS             14
  ------------------
 4023|     54|        DEBUGINDENTADD(-4);
  ------------------
  |  |   73|     54|#define DEBUGINDENTADD(x)  do {if (_DBG_IF_) {__DBGINDENTADD(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     54|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 54]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGINDENTADD(x)  do {if (_DBG_IF_) {__DBGINDENTADD(x);} }while(0)
  |  |  ------------------
  |  |  |  |  172|      0|#define __DBGINDENTADD(x)  debug_indent_add(x)
  |  |  ------------------
  |  |  |  Branch (73:74): [Folded, False: 54]
  |  |  ------------------
  ------------------
 4024|     54|        return SNMPERR_ASN_PARSE_ERR;
  ------------------
  |  |  213|     54|#define SNMPERR_ASN_PARSE_ERR           (-29)
  ------------------
 4025|  2.24k|    } else if (pdu->msgMaxSize > SNMP_MAX_PACKET_LEN) {
  ------------------
  |  |   49|  2.24k|#define SNMP_MAX_PACKET_LEN (0x7fffffff)
  ------------------
  |  Branch (4025:16): [True: 4, False: 2.24k]
  ------------------
 4026|      4|        snmp_log(LOG_ERR, "Received bad msgMaxSize (%lu > 2^31 - 1).\n",
 4027|      4|                 pdu->msgMaxSize);
 4028|      4|        snmp_increment_statistic(STAT_SNMPINASNPARSEERRS);
  ------------------
  |  |  637|      4|#define  STAT_SNMPINASNPARSEERRS             14
  ------------------
 4029|      4|        DEBUGINDENTADD(-4);
  ------------------
  |  |   73|      4|#define DEBUGINDENTADD(x)  do {if (_DBG_IF_) {__DBGINDENTADD(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      4|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 4]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGINDENTADD(x)  do {if (_DBG_IF_) {__DBGINDENTADD(x);} }while(0)
  |  |  ------------------
  |  |  |  |  172|      0|#define __DBGINDENTADD(x)  debug_indent_add(x)
  |  |  ------------------
  |  |  |  Branch (73:74): [Folded, False: 4]
  |  |  ------------------
  ------------------
 4030|      4|        return SNMPERR_ASN_PARSE_ERR;
  ------------------
  |  |  213|      4|#define SNMPERR_ASN_PARSE_ERR           (-29)
  ------------------
 4031|  2.24k|    } else {
 4032|  2.24k|        DEBUGMSGTL(("snmpv3_parse:msgMaxSize", "msgMaxSize %lu received\n",
  ------------------
  |  |   66|  2.24k|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|  2.24k|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 2.24k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 2.24k]
  |  |  ------------------
  ------------------
 4033|  2.24k|                    pdu->msgMaxSize));
 4034|       |        /** don't increase max msg size if we've already got one */
 4035|  2.24k|        if (sess->sndMsgMaxSize < pdu->msgMaxSize) {
  ------------------
  |  Branch (4035:13): [True: 2.24k, False: 0]
  ------------------
 4036|  2.24k|            DEBUGMSGTL(("snmpv3_parse:msgMaxSize",
  ------------------
  |  |   66|  2.24k|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|  2.24k|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 2.24k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 2.24k]
  |  |  ------------------
  ------------------
 4037|  2.24k|                        "msgMaxSize %" NETSNMP_PRIz "d greater than session max %ld; reducing\n",
 4038|  2.24k|                        sess->sndMsgMaxSize, pdu->msgMaxSize));
 4039|  2.24k|            pdu->msgMaxSize = sess->sndMsgMaxSize;
 4040|  2.24k|        }
 4041|  2.24k|    }
 4042|       |
 4043|       |    /*
 4044|       |     * msgFlags 
 4045|       |     */
 4046|  2.24k|    tmp_buf_len = SNMP_MAX_MSG_SIZE;
  ------------------
  |  |  109|  2.24k|#define SNMP_MAX_MSG_SIZE          1472 /* ethernet MTU minus IP/UDP header */
  ------------------
 4047|  2.24k|    DEBUGDUMPHEADER("recv", "msgFlags");
  ------------------
  |  |   79|  2.24k|	do {if (_DBG_IF_) {__DBGDUMPHEADER(token,x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|  2.24k|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 2.24k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               	do {if (_DBG_IF_) {__DBGDUMPHEADER(token,x);} }while(0)
  |  |  ------------------
  |  |  |  |  178|      0|        __DBGPRINTINDENT("dumph_" token); \
  |  |  |  |  ------------------
  |  |  |  |  |  |  175|      0|#define __DBGPRINTINDENT(token) __DBGMSGTL((token, "%*s", __DBGINDENT(), ""))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  179|      0|        debugmsg("dumph_" token,x); \
  |  |  |  |  180|      0|        if (debug_is_token_registered("dumpx" token) == SNMPERR_SUCCESS ||    \
  |  |  |  |  ------------------
  |  |  |  |  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (180:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  181|      0|            debug_is_token_registered("dumpv" token) == SNMPERR_SUCCESS ||    \
  |  |  |  |  ------------------
  |  |  |  |  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (181:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  182|      0|            (debug_is_token_registered("dumpx_" token) != SNMPERR_SUCCESS &&  \
  |  |  |  |  ------------------
  |  |  |  |  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (182:14): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  183|      0|             debug_is_token_registered("dumpv_" token) != SNMPERR_SUCCESS)) { \
  |  |  |  |  ------------------
  |  |  |  |  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:14): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  184|      0|            debugmsg("dumph_" token,"\n"); \
  |  |  |  |  185|      0|        } else { \
  |  |  |  |  186|      0|            debugmsg("dumph_" token,"  "); \
  |  |  |  |  187|      0|        } \
  |  |  |  |  188|      0|        __DBGINDENTMORE()
  |  |  |  |  ------------------
  |  |  |  |  |  |  173|      0|#define __DBGINDENTMORE()  debug_indent_add(2)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (79:55): [Folded, False: 2.24k]
  |  |  ------------------
  ------------------
 4048|  2.24k|    data = asn_parse_string(data, length, &type, tmp_buf, &tmp_buf_len);
 4049|  2.24k|    DEBUGINDENTLESS();
  ------------------
  |  |   75|  2.24k|#define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  144|  2.24k|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 2.24k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  174|      0|#define __DBGINDENTLESS()  debug_indent_add(-2)
  |  |  ------------------
  |  |  |  Branch (75:74): [Folded, False: 2.24k]
  |  |  ------------------
  ------------------
 4050|  2.24k|    if (data == NULL || type != ASN_OCTET_STR || tmp_buf_len != 1) {
  ------------------
  |  |   78|  4.29k|#define ASN_OCTET_STR	    0x04U
  ------------------
  |  Branch (4050:9): [True: 187, False: 2.05k]
  |  Branch (4050:25): [True: 2, False: 2.05k]
  |  Branch (4050:50): [True: 8, False: 2.04k]
  ------------------
 4051|    197|        ERROR_MSG("error parsing msgFlags");
  ------------------
  |  |  188|    197|#define ERROR_MSG(string)	snmp_set_detail(string)
  ------------------
 4052|    197|        snmp_increment_statistic(STAT_SNMPINASNPARSEERRS);
  ------------------
  |  |  637|    197|#define  STAT_SNMPINASNPARSEERRS             14
  ------------------
 4053|    197|        DEBUGINDENTADD(-4);
  ------------------
  |  |   73|    197|#define DEBUGINDENTADD(x)  do {if (_DBG_IF_) {__DBGINDENTADD(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|    197|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 197]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGINDENTADD(x)  do {if (_DBG_IF_) {__DBGINDENTADD(x);} }while(0)
  |  |  ------------------
  |  |  |  |  172|      0|#define __DBGINDENTADD(x)  debug_indent_add(x)
  |  |  ------------------
  |  |  |  Branch (73:74): [Folded, False: 197]
  |  |  ------------------
  ------------------
 4054|    197|        return SNMPERR_ASN_PARSE_ERR;
  ------------------
  |  |  213|    197|#define SNMPERR_ASN_PARSE_ERR           (-29)
  ------------------
 4055|    197|    }
 4056|  2.04k|    msg_flags = *tmp_buf;
 4057|  2.04k|    if (msg_flags & SNMP_MSG_FLAG_RPRT_BIT)
  ------------------
  |  |  305|  2.04k|#define SNMP_MSG_FLAG_RPRT_BIT          0x04
  ------------------
  |  Branch (4057:9): [True: 340, False: 1.70k]
  ------------------
 4058|    340|        pdu->flags |= SNMP_MSG_FLAG_RPRT_BIT;
  ------------------
  |  |  305|    340|#define SNMP_MSG_FLAG_RPRT_BIT          0x04
  ------------------
 4059|  1.70k|    else
 4060|  1.70k|        pdu->flags &= (~SNMP_MSG_FLAG_RPRT_BIT);
  ------------------
  |  |  305|  1.70k|#define SNMP_MSG_FLAG_RPRT_BIT          0x04
  ------------------
 4061|       |
 4062|       |    /*
 4063|       |     * msgSecurityModel 
 4064|       |     */
 4065|  2.04k|    DEBUGDUMPHEADER("recv", "msgSecurityModel");
  ------------------
  |  |   79|  2.04k|	do {if (_DBG_IF_) {__DBGDUMPHEADER(token,x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|  2.04k|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 2.04k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               	do {if (_DBG_IF_) {__DBGDUMPHEADER(token,x);} }while(0)
  |  |  ------------------
  |  |  |  |  178|      0|        __DBGPRINTINDENT("dumph_" token); \
  |  |  |  |  ------------------
  |  |  |  |  |  |  175|      0|#define __DBGPRINTINDENT(token) __DBGMSGTL((token, "%*s", __DBGINDENT(), ""))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  179|      0|        debugmsg("dumph_" token,x); \
  |  |  |  |  180|      0|        if (debug_is_token_registered("dumpx" token) == SNMPERR_SUCCESS ||    \
  |  |  |  |  ------------------
  |  |  |  |  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (180:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  181|      0|            debug_is_token_registered("dumpv" token) == SNMPERR_SUCCESS ||    \
  |  |  |  |  ------------------
  |  |  |  |  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (181:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  182|      0|            (debug_is_token_registered("dumpx_" token) != SNMPERR_SUCCESS &&  \
  |  |  |  |  ------------------
  |  |  |  |  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (182:14): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  183|      0|             debug_is_token_registered("dumpv_" token) != SNMPERR_SUCCESS)) { \
  |  |  |  |  ------------------
  |  |  |  |  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:14): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  184|      0|            debugmsg("dumph_" token,"\n"); \
  |  |  |  |  185|      0|        } else { \
  |  |  |  |  186|      0|            debugmsg("dumph_" token,"  "); \
  |  |  |  |  187|      0|        } \
  |  |  |  |  188|      0|        __DBGINDENTMORE()
  |  |  |  |  ------------------
  |  |  |  |  |  |  173|      0|#define __DBGINDENTMORE()  debug_indent_add(2)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (79:55): [Folded, False: 2.04k]
  |  |  ------------------
  ------------------
 4066|  2.04k|    data = asn_parse_int(data, length, &type, &msg_sec_model,
 4067|  2.04k|                         sizeof(msg_sec_model));
 4068|  2.04k|    DEBUGINDENTADD(-4);         /* return from global data indent */
  ------------------
  |  |   73|  2.04k|#define DEBUGINDENTADD(x)  do {if (_DBG_IF_) {__DBGINDENTADD(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|  2.04k|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 2.04k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGINDENTADD(x)  do {if (_DBG_IF_) {__DBGINDENTADD(x);} }while(0)
  |  |  ------------------
  |  |  |  |  172|      0|#define __DBGINDENTADD(x)  debug_indent_add(x)
  |  |  ------------------
  |  |  |  Branch (73:74): [Folded, False: 2.04k]
  |  |  ------------------
  ------------------
 4069|  2.04k|    if (data == NULL || type != ASN_INTEGER ||
  ------------------
  |  |   75|  4.08k|#define ASN_INTEGER	    0x02U
  ------------------
  |  Branch (4069:9): [True: 4, False: 2.04k]
  |  Branch (4069:25): [True: 0, False: 2.04k]
  ------------------
 4070|  2.04k|        msg_sec_model < 1 || msg_sec_model > 0x7fffffff) {
  ------------------
  |  Branch (4070:9): [True: 46, False: 1.99k]
  |  Branch (4070:30): [True: 4, False: 1.99k]
  ------------------
 4071|     54|        ERROR_MSG("error parsing msgSecurityModel");
  ------------------
  |  |  188|     54|#define ERROR_MSG(string)	snmp_set_detail(string)
  ------------------
 4072|     54|        snmp_increment_statistic(STAT_SNMPINASNPARSEERRS);
  ------------------
  |  |  637|     54|#define  STAT_SNMPINASNPARSEERRS             14
  ------------------
 4073|     54|        DEBUGINDENTLESS();
  ------------------
  |  |   75|     54|#define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  144|     54|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 54]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  174|      0|#define __DBGINDENTLESS()  debug_indent_add(-2)
  |  |  ------------------
  |  |  |  Branch (75:74): [Folded, False: 54]
  |  |  ------------------
  ------------------
 4074|     54|        return SNMPERR_ASN_PARSE_ERR;
  ------------------
  |  |  213|     54|#define SNMPERR_ASN_PARSE_ERR           (-29)
  ------------------
 4075|     54|    }
 4076|  1.99k|    sptr = find_sec_mod(msg_sec_model);
 4077|  1.99k|    if (!sptr) {
  ------------------
  |  Branch (4077:9): [True: 65, False: 1.92k]
  ------------------
 4078|     65|        snmp_log(LOG_WARNING, "unknown security model: %ld\n",
 4079|     65|                 msg_sec_model);
 4080|     65|        snmp_increment_statistic(STAT_SNMPUNKNOWNSECURITYMODELS);
  ------------------
  |  |  611|     65|#define   STAT_SNMPUNKNOWNSECURITYMODELS     0
  ------------------
 4081|     65|        DEBUGINDENTLESS();
  ------------------
  |  |   75|     65|#define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  144|     65|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 65]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  174|      0|#define __DBGINDENTLESS()  debug_indent_add(-2)
  |  |  ------------------
  |  |  |  Branch (75:74): [Folded, False: 65]
  |  |  ------------------
  ------------------
 4082|     65|        return SNMPERR_UNKNOWN_SEC_MODEL;
  ------------------
  |  |  214|     65|#define SNMPERR_UNKNOWN_SEC_MODEL 	(-30)
  ------------------
 4083|     65|    }
 4084|  1.92k|    pdu->securityModel = msg_sec_model;
 4085|       |
 4086|  1.92k|    if (msg_flags & SNMP_MSG_FLAG_PRIV_BIT &&
  ------------------
  |  |  304|  3.85k|#define SNMP_MSG_FLAG_PRIV_BIT          0x02
  ------------------
  |  Branch (4086:9): [True: 161, False: 1.76k]
  ------------------
 4087|    161|        !(msg_flags & SNMP_MSG_FLAG_AUTH_BIT)) {
  ------------------
  |  |  303|    161|#define SNMP_MSG_FLAG_AUTH_BIT          0x01
  ------------------
  |  Branch (4087:9): [True: 1, False: 160]
  ------------------
 4088|      1|        ERROR_MSG("invalid message, illegal msgFlags");
  ------------------
  |  |  188|      1|#define ERROR_MSG(string)	snmp_set_detail(string)
  ------------------
 4089|      1|        snmp_increment_statistic(STAT_SNMPINVALIDMSGS);
  ------------------
  |  |  612|      1|#define   STAT_SNMPINVALIDMSGS               1
  ------------------
 4090|      1|        DEBUGINDENTLESS();
  ------------------
  |  |   75|      1|#define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  144|      1|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 1]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  174|      0|#define __DBGINDENTLESS()  debug_indent_add(-2)
  |  |  ------------------
  |  |  |  Branch (75:74): [Folded, False: 1]
  |  |  ------------------
  ------------------
 4091|      1|        return SNMPERR_INVALID_MSG;
  ------------------
  |  |  215|      1|#define SNMPERR_INVALID_MSG             (-31)
  ------------------
 4092|      1|    }
 4093|  1.92k|    pdu->securityLevel = ((msg_flags & SNMP_MSG_FLAG_AUTH_BIT)
  ------------------
  |  |  303|  1.92k|#define SNMP_MSG_FLAG_AUTH_BIT          0x01
  ------------------
  |  Branch (4093:27): [True: 941, False: 985]
  ------------------
 4094|  1.92k|                          ? ((msg_flags & SNMP_MSG_FLAG_PRIV_BIT)
  ------------------
  |  |  304|    941|#define SNMP_MSG_FLAG_PRIV_BIT          0x02
  ------------------
  |  Branch (4094:30): [True: 160, False: 781]
  ------------------
 4095|    941|                             ? SNMP_SEC_LEVEL_AUTHPRIV
  ------------------
  |  |  301|    160|#define SNMP_SEC_LEVEL_AUTHPRIV		3
  ------------------
 4096|    941|                             : SNMP_SEC_LEVEL_AUTHNOPRIV)
  ------------------
  |  |  300|    781|#define SNMP_SEC_LEVEL_AUTHNOPRIV	2
  ------------------
 4097|  1.92k|                          : SNMP_SEC_LEVEL_NOAUTH);
  ------------------
  |  |  299|    985|#define SNMP_SEC_LEVEL_NOAUTH		1
  ------------------
 4098|       |    /*
 4099|       |     * end of msgGlobalData 
 4100|       |     */
 4101|       |
 4102|       |    /*
 4103|       |     * securtityParameters OCTET STRING begins after msgGlobalData 
 4104|       |     */
 4105|  1.92k|    sec_params = data;
 4106|  1.92k|    SNMP_FREE(pdu->contextEngineID);
  ------------------
  |  |   62|  1.92k|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 0, False: 1.92k]
  |  |  |  Branch (62:66): [Folded, False: 1.92k]
  |  |  ------------------
  ------------------
 4107|  1.92k|    pdu->contextEngineID = calloc(1, SNMP_MAX_ENG_SIZE);
  ------------------
  |  |  111|  1.92k|#define SNMP_MAX_ENG_SIZE          32
  ------------------
 4108|  1.92k|    pdu->contextEngineIDLen = SNMP_MAX_ENG_SIZE;
  ------------------
  |  |  111|  1.92k|#define SNMP_MAX_ENG_SIZE          32
  ------------------
 4109|       |
 4110|       |    /*
 4111|       |     * Note: there is no length limit on the msgAuthoritativeEngineID field,
 4112|       |     * although we would EXPECT it to be limited to 32 (the SnmpEngineID TC
 4113|       |     * limit).  We'll use double that here to be on the safe side.  
 4114|       |     */
 4115|       |
 4116|  1.92k|    SNMP_FREE(pdu->securityEngineID);
  ------------------
  |  |   62|  1.92k|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 0, False: 1.92k]
  |  |  |  Branch (62:66): [Folded, False: 1.92k]
  |  |  ------------------
  ------------------
 4117|  1.92k|    pdu->securityEngineID = calloc(1, SNMP_MAX_ENG_SIZE * 2);
  ------------------
  |  |  111|  1.92k|#define SNMP_MAX_ENG_SIZE          32
  ------------------
 4118|  1.92k|    pdu->securityEngineIDLen = SNMP_MAX_ENG_SIZE * 2;
  ------------------
  |  |  111|  1.92k|#define SNMP_MAX_ENG_SIZE          32
  ------------------
 4119|  1.92k|    SNMP_FREE(pdu->securityName);
  ------------------
  |  |   62|  1.92k|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 0, False: 1.92k]
  |  |  |  Branch (62:66): [Folded, False: 1.92k]
  |  |  ------------------
  ------------------
 4120|  1.92k|    pdu->securityName = calloc(1, SNMP_MAX_SEC_NAME_SIZE);
  ------------------
  |  |  112|  1.92k|#define SNMP_MAX_SEC_NAME_SIZE     256
  ------------------
 4121|  1.92k|    pdu->securityNameLen = SNMP_MAX_SEC_NAME_SIZE;
  ------------------
  |  |  112|  1.92k|#define SNMP_MAX_SEC_NAME_SIZE     256
  ------------------
 4122|       |
 4123|  1.92k|    if ((pdu->securityName == NULL) ||
  ------------------
  |  Branch (4123:9): [True: 0, False: 1.92k]
  ------------------
 4124|  1.92k|        (pdu->securityEngineID == NULL) ||
  ------------------
  |  Branch (4124:9): [True: 0, False: 1.92k]
  ------------------
 4125|  1.92k|        (pdu->contextEngineID == NULL)) {
  ------------------
  |  Branch (4125:9): [True: 0, False: 1.92k]
  ------------------
 4126|      0|        return SNMPERR_MALLOC;
  ------------------
  |  |  246|      0|#define SNMPERR_MALLOC			(-62)
  ------------------
 4127|      0|    }
 4128|       |
 4129|  1.92k|    if (pdu_buf_len < msg_len
  ------------------
  |  Branch (4129:9): [True: 188, False: 1.73k]
  ------------------
 4130|    188|        && pdu->securityLevel == SNMP_SEC_LEVEL_AUTHPRIV) {
  ------------------
  |  |  301|    188|#define SNMP_SEC_LEVEL_AUTHPRIV		3
  ------------------
  |  Branch (4130:12): [True: 36, False: 152]
  ------------------
 4131|       |        /*
 4132|       |         * space needed is larger than we have in the default buffer 
 4133|       |         */
 4134|     36|        mallocbuf = calloc(1, msg_len);
 4135|     36|        if (mallocbuf == NULL)
  ------------------
  |  Branch (4135:13): [True: 0, False: 36]
  ------------------
 4136|      0|            return SNMPERR_MALLOC;
  ------------------
  |  |  246|      0|#define SNMPERR_MALLOC			(-62)
  ------------------
 4137|     36|        pdu_buf_len = msg_len;
 4138|     36|        cp = mallocbuf;
 4139|  1.89k|    } else {
 4140|  1.89k|        memset(pdu_buf, 0, pdu_buf_len);
 4141|  1.89k|        cp = pdu_buf;
 4142|  1.89k|    }
 4143|       |
 4144|  1.92k|    DEBUGDUMPSECTION("recv", "SM msgSecurityParameters");
  ------------------
  |  |   81|  1.92k|	do {if (_DBG_IF_) {__DBGDUMPSECTION(token,x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|  1.92k|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 1.92k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               	do {if (_DBG_IF_) {__DBGDUMPSECTION(token,x);} }while(0)
  |  |  ------------------
  |  |  |  |  191|      0|        __DBGPRINTINDENT("dumph_" token); \
  |  |  |  |  ------------------
  |  |  |  |  |  |  175|      0|#define __DBGPRINTINDENT(token) __DBGMSGTL((token, "%*s", __DBGINDENT(), ""))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  192|      0|        debugmsg("dumph_" token,"%s\n",x);\
  |  |  |  |  193|      0|        __DBGINDENTMORE()
  |  |  |  |  ------------------
  |  |  |  |  |  |  173|      0|#define __DBGINDENTMORE()  debug_indent_add(2)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (81:56): [Folded, False: 1.92k]
  |  |  ------------------
  ------------------
 4145|  1.92k|    if (sptr->decode) {
  ------------------
  |  Branch (4145:9): [True: 1.92k, False: 0]
  ------------------
 4146|  1.92k|        struct snmp_secmod_incoming_params parms;
 4147|  1.92k|        parms.msgProcModel = pdu->msgParseModel;
 4148|  1.92k|        parms.maxMsgSize = pdu->msgMaxSize;
 4149|  1.92k|        parms.secParams = sec_params;
 4150|  1.92k|        parms.secModel = msg_sec_model;
 4151|  1.92k|        parms.secLevel = pdu->securityLevel;
 4152|  1.92k|        parms.wholeMsg = msg_data;
 4153|  1.92k|        parms.wholeMsgLen = msg_len;
 4154|  1.92k|        parms.secEngineID = pdu->securityEngineID;
 4155|  1.92k|        parms.secEngineIDLen = &pdu->securityEngineIDLen;
 4156|  1.92k|        parms.secName = pdu->securityName;
 4157|  1.92k|        parms.secNameLen = &pdu->securityNameLen;
 4158|  1.92k|        parms.scopedPdu = &cp;
 4159|  1.92k|        parms.scopedPduLen = &pdu_buf_len;
 4160|  1.92k|        parms.maxSizeResponse = &max_size_response;
 4161|  1.92k|        parms.secStateRef = &pdu->securityStateRef;
 4162|  1.92k|        parms.sess = sess;
 4163|  1.92k|        parms.pdu = pdu;
 4164|  1.92k|        parms.msg_flags = msg_flags;
 4165|  1.92k|        ret_val = (*sptr->decode) (&parms);
 4166|  1.92k|    } else {
 4167|      0|        SNMP_FREE(mallocbuf);
  ------------------
  |  |   62|      0|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 0, False: 0]
  |  |  |  Branch (62:66): [Folded, False: 0]
  |  |  ------------------
  ------------------
 4168|      0|        DEBUGINDENTLESS();
  ------------------
  |  |   75|      0|#define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  174|      0|#define __DBGINDENTLESS()  debug_indent_add(-2)
  |  |  ------------------
  |  |  |  Branch (75:74): [Folded, False: 0]
  |  |  ------------------
  ------------------
 4169|      0|        snmp_log(LOG_WARNING, "security service %ld can't decode packets\n",
 4170|      0|                 msg_sec_model);
 4171|      0|        return (-1);
 4172|      0|    }
 4173|       |
 4174|  1.92k|    if (ret_val != SNMPERR_SUCCESS) {
  ------------------
  |  |  184|  1.92k|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
  |  Branch (4174:9): [True: 1.15k, False: 771]
  ------------------
 4175|  1.15k|        DEBUGDUMPSECTION("recv", "ScopedPDU");
  ------------------
  |  |   81|  1.15k|	do {if (_DBG_IF_) {__DBGDUMPSECTION(token,x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|  1.15k|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 1.15k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               	do {if (_DBG_IF_) {__DBGDUMPSECTION(token,x);} }while(0)
  |  |  ------------------
  |  |  |  |  191|      0|        __DBGPRINTINDENT("dumph_" token); \
  |  |  |  |  ------------------
  |  |  |  |  |  |  175|      0|#define __DBGPRINTINDENT(token) __DBGMSGTL((token, "%*s", __DBGINDENT(), ""))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  192|      0|        debugmsg("dumph_" token,"%s\n",x);\
  |  |  |  |  193|      0|        __DBGINDENTMORE()
  |  |  |  |  ------------------
  |  |  |  |  |  |  173|      0|#define __DBGINDENTMORE()  debug_indent_add(2)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (81:56): [Folded, False: 1.15k]
  |  |  ------------------
  ------------------
 4176|       |        /*
 4177|       |         * Parse as much as possible -- though I don't see the point? [jbpn].  
 4178|       |         */
 4179|  1.15k|        if (cp) {
  ------------------
  |  Branch (4179:13): [True: 1.15k, False: 0]
  ------------------
 4180|  1.15k|            cp = snmpv3_scopedPDU_parse(pdu, cp, &pdu_buf_len);
 4181|  1.15k|        }
 4182|  1.15k|        if (cp) {
  ------------------
  |  Branch (4182:13): [True: 586, False: 569]
  ------------------
 4183|    586|            DEBUGPRINTPDUTYPE("recv", *cp);
  ------------------
  |  |  431|    586|    DEBUGDUMPSECTION(token, snmp_pdu_type(type))
  |  |  ------------------
  |  |  |  |   81|    586|	do {if (_DBG_IF_) {__DBGDUMPSECTION(token,x);} }while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  |  144|    586|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (144:29): [True: 0, False: 586]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |               	do {if (_DBG_IF_) {__DBGDUMPSECTION(token,x);} }while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  |  191|      0|        __DBGPRINTINDENT("dumph_" token); \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  175|      0|#define __DBGPRINTINDENT(token) __DBGMSGTL((token, "%*s", __DBGINDENT(), ""))
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  192|      0|        debugmsg("dumph_" token,"%s\n",x);\
  |  |  |  |  |  |  193|      0|        __DBGINDENTMORE()
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  173|      0|#define __DBGINDENTMORE()  debug_indent_add(2)
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (81:56): [Folded, False: 586]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4184|    586|            snmp_pdu_parse(pdu, cp, &pdu_buf_len);
 4185|    586|            DEBUGINDENTADD(-8);
  ------------------
  |  |   73|    586|#define DEBUGINDENTADD(x)  do {if (_DBG_IF_) {__DBGINDENTADD(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|    586|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 586]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGINDENTADD(x)  do {if (_DBG_IF_) {__DBGINDENTADD(x);} }while(0)
  |  |  ------------------
  |  |  |  |  172|      0|#define __DBGINDENTADD(x)  debug_indent_add(x)
  |  |  ------------------
  |  |  |  Branch (73:74): [Folded, False: 586]
  |  |  ------------------
  ------------------
 4186|    586|        } else {
 4187|    569|            DEBUGINDENTADD(-4);
  ------------------
  |  |   73|    569|#define DEBUGINDENTADD(x)  do {if (_DBG_IF_) {__DBGINDENTADD(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|    569|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 569]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGINDENTADD(x)  do {if (_DBG_IF_) {__DBGINDENTADD(x);} }while(0)
  |  |  ------------------
  |  |  |  |  172|      0|#define __DBGINDENTADD(x)  debug_indent_add(x)
  |  |  ------------------
  |  |  |  Branch (73:74): [Folded, False: 569]
  |  |  ------------------
  ------------------
 4188|    569|        }
 4189|       |
 4190|  1.15k|        SNMP_FREE(mallocbuf);
  ------------------
  |  |   62|  1.15k|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 36, False: 1.11k]
  |  |  |  Branch (62:66): [Folded, False: 1.15k]
  |  |  ------------------
  ------------------
 4191|  1.15k|        return ret_val;
 4192|  1.15k|    }
 4193|       |
 4194|       |    /*
 4195|       |     * parse plaintext ScopedPDU sequence 
 4196|       |     */
 4197|    771|    *length = pdu_buf_len;
 4198|    771|    DEBUGDUMPSECTION("recv", "ScopedPDU");
  ------------------
  |  |   81|    771|	do {if (_DBG_IF_) {__DBGDUMPSECTION(token,x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|    771|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 771]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               	do {if (_DBG_IF_) {__DBGDUMPSECTION(token,x);} }while(0)
  |  |  ------------------
  |  |  |  |  191|      0|        __DBGPRINTINDENT("dumph_" token); \
  |  |  |  |  ------------------
  |  |  |  |  |  |  175|      0|#define __DBGPRINTINDENT(token) __DBGMSGTL((token, "%*s", __DBGINDENT(), ""))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  192|      0|        debugmsg("dumph_" token,"%s\n",x);\
  |  |  |  |  193|      0|        __DBGINDENTMORE()
  |  |  |  |  ------------------
  |  |  |  |  |  |  173|      0|#define __DBGINDENTMORE()  debug_indent_add(2)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (81:56): [Folded, False: 771]
  |  |  ------------------
  ------------------
 4199|    771|    data = snmpv3_scopedPDU_parse(pdu, cp, length);
 4200|    771|    if (data == NULL) {
  ------------------
  |  Branch (4200:9): [True: 104, False: 667]
  ------------------
 4201|    104|        snmp_log(LOG_WARNING, "security service %ld error parsing ScopedPDU\n",
 4202|    104|                 msg_sec_model);
 4203|    104|        ERROR_MSG("error parsing PDU");
  ------------------
  |  |  188|    104|#define ERROR_MSG(string)	snmp_set_detail(string)
  ------------------
 4204|    104|        snmp_increment_statistic(STAT_SNMPINASNPARSEERRS);
  ------------------
  |  |  637|    104|#define  STAT_SNMPINASNPARSEERRS             14
  ------------------
 4205|    104|        DEBUGINDENTADD(-4);
  ------------------
  |  |   73|    104|#define DEBUGINDENTADD(x)  do {if (_DBG_IF_) {__DBGINDENTADD(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|    104|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 104]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGINDENTADD(x)  do {if (_DBG_IF_) {__DBGINDENTADD(x);} }while(0)
  |  |  ------------------
  |  |  |  |  172|      0|#define __DBGINDENTADD(x)  debug_indent_add(x)
  |  |  ------------------
  |  |  |  Branch (73:74): [Folded, False: 104]
  |  |  ------------------
  ------------------
 4206|    104|        SNMP_FREE(mallocbuf);
  ------------------
  |  |   62|    104|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 0, False: 104]
  |  |  |  Branch (62:66): [Folded, False: 104]
  |  |  ------------------
  ------------------
 4207|    104|        return SNMPERR_ASN_PARSE_ERR;
  ------------------
  |  |  213|    104|#define SNMPERR_ASN_PARSE_ERR           (-29)
  ------------------
 4208|    104|    }
 4209|       |
 4210|       |    /*
 4211|       |     * parse the PDU.  
 4212|       |     */
 4213|    667|    if (after_header != NULL) {
  ------------------
  |  Branch (4213:9): [True: 0, False: 667]
  ------------------
 4214|      0|        *after_header = data;
 4215|      0|        tmp_buf_len = *length;
 4216|      0|    }
 4217|       |
 4218|    667|    DEBUGPRINTPDUTYPE("recv", *data);
  ------------------
  |  |  431|    667|    DEBUGDUMPSECTION(token, snmp_pdu_type(type))
  |  |  ------------------
  |  |  |  |   81|    667|	do {if (_DBG_IF_) {__DBGDUMPSECTION(token,x);} }while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  |  144|    667|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (144:29): [True: 0, False: 667]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |               	do {if (_DBG_IF_) {__DBGDUMPSECTION(token,x);} }while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  |  191|      0|        __DBGPRINTINDENT("dumph_" token); \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  175|      0|#define __DBGPRINTINDENT(token) __DBGMSGTL((token, "%*s", __DBGINDENT(), ""))
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  192|      0|        debugmsg("dumph_" token,"%s\n",x);\
  |  |  |  |  |  |  193|      0|        __DBGINDENTMORE()
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  173|      0|#define __DBGINDENTMORE()  debug_indent_add(2)
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (81:56): [Folded, False: 667]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4219|    667|    ret = snmp_pdu_parse(pdu, data, length);
 4220|    667|    DEBUGINDENTADD(-8);
  ------------------
  |  |   73|    667|#define DEBUGINDENTADD(x)  do {if (_DBG_IF_) {__DBGINDENTADD(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|    667|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 667]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGINDENTADD(x)  do {if (_DBG_IF_) {__DBGINDENTADD(x);} }while(0)
  |  |  ------------------
  |  |  |  |  172|      0|#define __DBGINDENTADD(x)  debug_indent_add(x)
  |  |  ------------------
  |  |  |  Branch (73:74): [Folded, False: 667]
  |  |  ------------------
  ------------------
 4221|       |
 4222|    667|    if (after_header != NULL) {
  ------------------
  |  Branch (4222:9): [True: 0, False: 667]
  ------------------
 4223|      0|        *length = tmp_buf_len;
 4224|      0|    }
 4225|       |
 4226|    667|    if (ret != SNMPERR_SUCCESS) {
  ------------------
  |  |  184|    667|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
  |  Branch (4226:9): [True: 543, False: 124]
  ------------------
 4227|    543|        snmp_log(LOG_WARNING, "security service %ld error parsing ScopedPDU\n",
 4228|    543|                 msg_sec_model);
 4229|    543|        ERROR_MSG("error parsing PDU");
  ------------------
  |  |  188|    543|#define ERROR_MSG(string)	snmp_set_detail(string)
  ------------------
 4230|    543|        snmp_increment_statistic(STAT_SNMPINASNPARSEERRS);
  ------------------
  |  |  637|    543|#define  STAT_SNMPINASNPARSEERRS             14
  ------------------
 4231|    543|        SNMP_FREE(mallocbuf);
  ------------------
  |  |   62|    543|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 0, False: 543]
  |  |  |  Branch (62:66): [Folded, False: 543]
  |  |  ------------------
  ------------------
 4232|    543|        return SNMPERR_ASN_PARSE_ERR;
  ------------------
  |  |  213|    543|#define SNMPERR_ASN_PARSE_ERR           (-29)
  ------------------
 4233|    543|    }
 4234|       |
 4235|    124|    SNMP_FREE(mallocbuf);
  ------------------
  |  |   62|    124|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 0, False: 124]
  |  |  |  Branch (62:66): [Folded, False: 124]
  |  |  ------------------
  ------------------
 4236|    124|    return SNMPERR_SUCCESS;
  ------------------
  |  |  184|    124|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
 4237|    667|}                               /* end snmpv3_parse() */
snmp_parse:
 4776|  3.01k|{
 4777|  3.01k|    int             rc;
 4778|       |
 4779|  3.01k|    rc = _snmp_parse(slp, pss, pdu, data, length);
 4780|  3.01k|    if (rc) {
  ------------------
  |  Branch (4780:9): [True: 2.92k, False: 89]
  ------------------
 4781|  2.92k|        if (!pss->s_snmp_errno) {
  ------------------
  |  Branch (4781:13): [True: 35, False: 2.89k]
  ------------------
 4782|     35|            pss->s_snmp_errno = SNMPERR_BAD_PARSE;
  ------------------
  |  |  197|     35|#define SNMPERR_BAD_PARSE		(-13)
  ------------------
 4783|     35|        }
 4784|  2.92k|        SET_SNMP_ERROR(pss->s_snmp_errno);
  ------------------
  |  |   43|  2.92k|#define SET_SNMP_ERROR(x) snmp_errno=(x)
  ------------------
 4785|  2.92k|    }
 4786|       |
 4787|  3.01k|    return rc;
 4788|  3.01k|}
snmp_pdu_parse:
 4792|  1.25k|{
 4793|  1.25k|    u_char          type;
 4794|  1.25k|    u_char          msg_type;
 4795|  1.25k|    u_char         *var_val;
 4796|  1.25k|    size_t          len;
 4797|  1.25k|    size_t          four;
 4798|  1.25k|    netsnmp_variable_list *vp = NULL, *vplast = NULL;
 4799|  1.25k|    oid             objid[MAX_OID_LEN];
 4800|  1.25k|    u_char         *p;
 4801|       |
 4802|       |    /*
 4803|       |     * Get the PDU type 
 4804|       |     */
 4805|  1.25k|    data = asn_parse_header(data, length, &msg_type);
 4806|  1.25k|    if (data == NULL)
  ------------------
  |  Branch (4806:9): [True: 0, False: 1.25k]
  ------------------
 4807|      0|        return -1;
 4808|  1.25k|    DEBUGMSGTL(("dumpv_recv","    Command %s\n", snmp_pdu_type(msg_type)));
  ------------------
  |  |   66|  1.25k|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|  1.25k|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 1.25k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 1.25k]
  |  |  ------------------
  ------------------
 4809|  1.25k|    pdu->command = msg_type;
 4810|  1.25k|    pdu->flags &= (~UCD_MSG_FLAG_RESPONSE_PDU);
  ------------------
  |  |  311|  1.25k|#define UCD_MSG_FLAG_RESPONSE_PDU            0x100
  ------------------
 4811|       |
 4812|       |    /*
 4813|       |     * get the fields in the PDU preceding the variable-bindings sequence
 4814|       |     */
 4815|  1.25k|    switch (pdu->command) {
 4816|    602|    case SNMP_MSG_TRAP:
  ------------------
  |  |  135|    602|#define SNMP_MSG_TRAP       (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x4) /* a4=164 */
  |  |  ------------------
  |  |  |  |   92|    602|#define ASN_CONTEXT	    0x80U
  |  |  ------------------
  |  |               #define SNMP_MSG_TRAP       (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x4) /* a4=164 */
  |  |  ------------------
  |  |  |  |   96|    602|#define ASN_CONSTRUCTOR	    0x20U
  |  |  ------------------
  ------------------
  |  Branch (4816:5): [True: 602, False: 651]
  ------------------
 4817|       |        /*
 4818|       |         * enterprise 
 4819|       |         */
 4820|    602|        pdu->enterprise_length = MAX_OID_LEN;
  ------------------
  |  |  120|    602|#define MAX_OID_LEN	    128 /* max subid's in an oid */
  ------------------
 4821|    602|        data = asn_parse_objid(data, length, &type, objid,
 4822|    602|                               &pdu->enterprise_length);
 4823|    602|        if (data == NULL)
  ------------------
  |  Branch (4823:13): [True: 221, False: 381]
  ------------------
 4824|    221|            return -1;
 4825|    381|        SNMP_FREE(pdu->enterprise);
  ------------------
  |  |   62|    381|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 0, False: 381]
  |  |  |  Branch (62:66): [Folded, False: 381]
  |  |  ------------------
  ------------------
 4826|    381|        pdu->enterprise = netsnmp_memdup(objid,
 4827|    381|                                         pdu->enterprise_length * sizeof(oid));
 4828|    381|        if (pdu->enterprise == NULL) {
  ------------------
  |  Branch (4828:13): [True: 0, False: 381]
  ------------------
 4829|      0|            return -1;
 4830|      0|        }
 4831|       |
 4832|       |        /*
 4833|       |         * agent-addr 
 4834|       |         */
 4835|    381|        four = 4;
 4836|    381|        data = asn_parse_string(data, length, &type,
 4837|    381|                                (u_char *) pdu->agent_addr, &four);
 4838|    381|        if (data == NULL)
  ------------------
  |  Branch (4838:13): [True: 84, False: 297]
  ------------------
 4839|     84|            return -1;
 4840|       |
 4841|       |        /*
 4842|       |         * generic trap 
 4843|       |         */
 4844|    297|        data = asn_parse_int(data, length, &type, (long *) &pdu->trap_type,
 4845|    297|                             sizeof(pdu->trap_type));
 4846|    297|        if (data == NULL)
  ------------------
  |  Branch (4846:13): [True: 3, False: 294]
  ------------------
 4847|      3|            return -1;
 4848|       |        /*
 4849|       |         * specific trap 
 4850|       |         */
 4851|    294|        data =
 4852|    294|            asn_parse_int(data, length, &type,
 4853|    294|                          (long *) &pdu->specific_type,
 4854|    294|                          sizeof(pdu->specific_type));
 4855|    294|        if (data == NULL)
  ------------------
  |  Branch (4855:13): [True: 1, False: 293]
  ------------------
 4856|      1|            return -1;
 4857|       |
 4858|       |        /*
 4859|       |         * timestamp  
 4860|       |         */
 4861|    293|        data = asn_parse_unsigned_int(data, length, &type, &pdu->time,
 4862|    293|                                      sizeof(pdu->time));
 4863|    293|        if (data == NULL)
  ------------------
  |  Branch (4863:13): [True: 192, False: 101]
  ------------------
 4864|    192|            return -1;
 4865|       |
 4866|    101|        break;
 4867|       |
 4868|    101|    case SNMP_MSG_RESPONSE:
  ------------------
  |  |  127|     41|#define SNMP_MSG_RESPONSE   (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x2) /* a2=162 */
  |  |  ------------------
  |  |  |  |   92|     41|#define ASN_CONTEXT	    0x80U
  |  |  ------------------
  |  |               #define SNMP_MSG_RESPONSE   (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x2) /* a2=162 */
  |  |  ------------------
  |  |  |  |   96|     41|#define ASN_CONSTRUCTOR	    0x20U
  |  |  ------------------
  ------------------
  |  Branch (4868:5): [True: 41, False: 1.21k]
  ------------------
 4869|     55|    case SNMP_MSG_REPORT:
  ------------------
  |  |  147|     55|#define SNMP_MSG_REPORT     (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x8) /* a8=168 */
  |  |  ------------------
  |  |  |  |   92|     55|#define ASN_CONTEXT	    0x80U
  |  |  ------------------
  |  |               #define SNMP_MSG_REPORT     (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x8) /* a8=168 */
  |  |  ------------------
  |  |  |  |   96|     55|#define ASN_CONSTRUCTOR	    0x20U
  |  |  ------------------
  ------------------
  |  Branch (4869:5): [True: 14, False: 1.23k]
  ------------------
 4870|     55|        pdu->flags |= UCD_MSG_FLAG_RESPONSE_PDU;
  ------------------
  |  |  311|     55|#define UCD_MSG_FLAG_RESPONSE_PDU            0x100
  ------------------
 4871|     55|        NETSNMP_FALLTHROUGH;
  ------------------
  |  | 2443|     55|#    define NETSNMP_FALLTHROUGH __attribute__((__fallthrough__))
  ------------------
 4872|       |
 4873|     67|    case SNMP_MSG_TRAP2:
  ------------------
  |  |  142|     67|#define SNMP_MSG_TRAP2      (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x7) /* a7=167 */
  |  |  ------------------
  |  |  |  |   92|     67|#define ASN_CONTEXT	    0x80U
  |  |  ------------------
  |  |               #define SNMP_MSG_TRAP2      (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x7) /* a7=167 */
  |  |  ------------------
  |  |  |  |   96|     67|#define ASN_CONSTRUCTOR	    0x20U
  |  |  ------------------
  ------------------
  |  Branch (4873:5): [True: 12, False: 1.24k]
  ------------------
 4874|    137|    case SNMP_MSG_INFORM:
  ------------------
  |  |  141|    137|#define SNMP_MSG_INFORM     (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x6) /* a6=166 */
  |  |  ------------------
  |  |  |  |   92|    137|#define ASN_CONTEXT	    0x80U
  |  |  ------------------
  |  |               #define SNMP_MSG_INFORM     (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x6) /* a6=166 */
  |  |  ------------------
  |  |  |  |   96|    137|#define ASN_CONSTRUCTOR	    0x20U
  |  |  ------------------
  ------------------
  |  Branch (4874:5): [True: 70, False: 1.18k]
  ------------------
 4875|    137|#ifndef NETSNMP_NOTIFY_ONLY
 4876|    207|    case SNMP_MSG_GET:
  ------------------
  |  |  125|    207|#define SNMP_MSG_GET        (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x0) /* a0=160 */
  |  |  ------------------
  |  |  |  |   92|    207|#define ASN_CONTEXT	    0x80U
  |  |  ------------------
  |  |               #define SNMP_MSG_GET        (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x0) /* a0=160 */
  |  |  ------------------
  |  |  |  |   96|    207|#define ASN_CONSTRUCTOR	    0x20U
  |  |  ------------------
  ------------------
  |  Branch (4876:5): [True: 70, False: 1.18k]
  ------------------
 4877|    576|    case SNMP_MSG_GETNEXT:
  ------------------
  |  |  126|    576|#define SNMP_MSG_GETNEXT    (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x1) /* a1=161 */
  |  |  ------------------
  |  |  |  |   92|    576|#define ASN_CONTEXT	    0x80U
  |  |  ------------------
  |  |               #define SNMP_MSG_GETNEXT    (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x1) /* a1=161 */
  |  |  ------------------
  |  |  |  |   96|    576|#define ASN_CONSTRUCTOR	    0x20U
  |  |  ------------------
  ------------------
  |  Branch (4877:5): [True: 369, False: 884]
  ------------------
 4878|    589|    case SNMP_MSG_GETBULK:
  ------------------
  |  |  140|    589|#define SNMP_MSG_GETBULK    (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x5) /* a5=165 */
  |  |  ------------------
  |  |  |  |   92|    589|#define ASN_CONTEXT	    0x80U
  |  |  ------------------
  |  |               #define SNMP_MSG_GETBULK    (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x5) /* a5=165 */
  |  |  ------------------
  |  |  |  |   96|    589|#define ASN_CONSTRUCTOR	    0x20U
  |  |  ------------------
  ------------------
  |  Branch (4878:5): [True: 13, False: 1.24k]
  ------------------
 4879|    589|#endif /* ! NETSNMP_NOTIFY_ONLY */
 4880|    589|#ifndef NETSNMP_NO_WRITE_SUPPORT
 4881|    636|    case SNMP_MSG_SET:
  ------------------
  |  |  129|    636|#define SNMP_MSG_SET        (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x3) /* a3=163 */
  |  |  ------------------
  |  |  |  |   92|    636|#define ASN_CONTEXT	    0x80U
  |  |  ------------------
  |  |               #define SNMP_MSG_SET        (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x3) /* a3=163 */
  |  |  ------------------
  |  |  |  |   96|    636|#define ASN_CONSTRUCTOR	    0x20U
  |  |  ------------------
  ------------------
  |  Branch (4881:5): [True: 47, False: 1.20k]
  ------------------
 4882|    636|#endif /* !NETSNMP_NO_WRITE_SUPPORT */
 4883|       |        /*
 4884|       |         * PDU is not an SNMPv1 TRAP 
 4885|       |         */
 4886|       |
 4887|       |        /*
 4888|       |         * request id 
 4889|       |         */
 4890|    636|        DEBUGDUMPHEADER("recv", "request_id");
  ------------------
  |  |   79|    636|	do {if (_DBG_IF_) {__DBGDUMPHEADER(token,x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|    636|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 636]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               	do {if (_DBG_IF_) {__DBGDUMPHEADER(token,x);} }while(0)
  |  |  ------------------
  |  |  |  |  178|      0|        __DBGPRINTINDENT("dumph_" token); \
  |  |  |  |  ------------------
  |  |  |  |  |  |  175|      0|#define __DBGPRINTINDENT(token) __DBGMSGTL((token, "%*s", __DBGINDENT(), ""))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  179|      0|        debugmsg("dumph_" token,x); \
  |  |  |  |  180|      0|        if (debug_is_token_registered("dumpx" token) == SNMPERR_SUCCESS ||    \
  |  |  |  |  ------------------
  |  |  |  |  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (180:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  181|      0|            debug_is_token_registered("dumpv" token) == SNMPERR_SUCCESS ||    \
  |  |  |  |  ------------------
  |  |  |  |  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (181:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  182|      0|            (debug_is_token_registered("dumpx_" token) != SNMPERR_SUCCESS &&  \
  |  |  |  |  ------------------
  |  |  |  |  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (182:14): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  183|      0|             debug_is_token_registered("dumpv_" token) != SNMPERR_SUCCESS)) { \
  |  |  |  |  ------------------
  |  |  |  |  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:14): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  184|      0|            debugmsg("dumph_" token,"\n"); \
  |  |  |  |  185|      0|        } else { \
  |  |  |  |  186|      0|            debugmsg("dumph_" token,"  "); \
  |  |  |  |  187|      0|        } \
  |  |  |  |  188|      0|        __DBGINDENTMORE()
  |  |  |  |  ------------------
  |  |  |  |  |  |  173|      0|#define __DBGINDENTMORE()  debug_indent_add(2)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (79:55): [Folded, False: 636]
  |  |  ------------------
  ------------------
 4891|    636|        data = asn_parse_int(data, length, &type, &pdu->reqid,
 4892|    636|                             sizeof(pdu->reqid));
 4893|    636|        DEBUGINDENTLESS();
  ------------------
  |  |   75|    636|#define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  144|    636|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 636]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  174|      0|#define __DBGINDENTLESS()  debug_indent_add(-2)
  |  |  ------------------
  |  |  |  Branch (75:74): [Folded, False: 636]
  |  |  ------------------
  ------------------
 4894|    636|        if (data == NULL) {
  ------------------
  |  Branch (4894:13): [True: 10, False: 626]
  ------------------
 4895|     10|            return -1;
 4896|     10|        }
 4897|       |
 4898|       |        /*
 4899|       |         * error status (getbulk non-repeaters) 
 4900|       |         */
 4901|    626|        DEBUGDUMPHEADER("recv", "error status");
  ------------------
  |  |   79|    626|	do {if (_DBG_IF_) {__DBGDUMPHEADER(token,x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|    626|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 626]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               	do {if (_DBG_IF_) {__DBGDUMPHEADER(token,x);} }while(0)
  |  |  ------------------
  |  |  |  |  178|      0|        __DBGPRINTINDENT("dumph_" token); \
  |  |  |  |  ------------------
  |  |  |  |  |  |  175|      0|#define __DBGPRINTINDENT(token) __DBGMSGTL((token, "%*s", __DBGINDENT(), ""))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  179|      0|        debugmsg("dumph_" token,x); \
  |  |  |  |  180|      0|        if (debug_is_token_registered("dumpx" token) == SNMPERR_SUCCESS ||    \
  |  |  |  |  ------------------
  |  |  |  |  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (180:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  181|      0|            debug_is_token_registered("dumpv" token) == SNMPERR_SUCCESS ||    \
  |  |  |  |  ------------------
  |  |  |  |  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (181:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  182|      0|            (debug_is_token_registered("dumpx_" token) != SNMPERR_SUCCESS &&  \
  |  |  |  |  ------------------
  |  |  |  |  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (182:14): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  183|      0|             debug_is_token_registered("dumpv_" token) != SNMPERR_SUCCESS)) { \
  |  |  |  |  ------------------
  |  |  |  |  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:14): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  184|      0|            debugmsg("dumph_" token,"\n"); \
  |  |  |  |  185|      0|        } else { \
  |  |  |  |  186|      0|            debugmsg("dumph_" token,"  "); \
  |  |  |  |  187|      0|        } \
  |  |  |  |  188|      0|        __DBGINDENTMORE()
  |  |  |  |  ------------------
  |  |  |  |  |  |  173|      0|#define __DBGINDENTMORE()  debug_indent_add(2)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (79:55): [Folded, False: 626]
  |  |  ------------------
  ------------------
 4902|    626|        data = asn_parse_int(data, length, &type, &pdu->errstat,
 4903|    626|                             sizeof(pdu->errstat));
 4904|    626|        DEBUGINDENTLESS();
  ------------------
  |  |   75|    626|#define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  144|    626|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 626]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  174|      0|#define __DBGINDENTLESS()  debug_indent_add(-2)
  |  |  ------------------
  |  |  |  Branch (75:74): [Folded, False: 626]
  |  |  ------------------
  ------------------
 4905|    626|        if (data == NULL) {
  ------------------
  |  Branch (4905:13): [True: 1, False: 625]
  ------------------
 4906|      1|            return -1;
 4907|      1|        }
 4908|       |
 4909|       |        /*
 4910|       |         * error index (getbulk max-repetitions) 
 4911|       |         */
 4912|    625|        DEBUGDUMPHEADER("recv", "error index");
  ------------------
  |  |   79|    625|	do {if (_DBG_IF_) {__DBGDUMPHEADER(token,x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|    625|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 625]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               	do {if (_DBG_IF_) {__DBGDUMPHEADER(token,x);} }while(0)
  |  |  ------------------
  |  |  |  |  178|      0|        __DBGPRINTINDENT("dumph_" token); \
  |  |  |  |  ------------------
  |  |  |  |  |  |  175|      0|#define __DBGPRINTINDENT(token) __DBGMSGTL((token, "%*s", __DBGINDENT(), ""))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  179|      0|        debugmsg("dumph_" token,x); \
  |  |  |  |  180|      0|        if (debug_is_token_registered("dumpx" token) == SNMPERR_SUCCESS ||    \
  |  |  |  |  ------------------
  |  |  |  |  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (180:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  181|      0|            debug_is_token_registered("dumpv" token) == SNMPERR_SUCCESS ||    \
  |  |  |  |  ------------------
  |  |  |  |  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (181:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  182|      0|            (debug_is_token_registered("dumpx_" token) != SNMPERR_SUCCESS &&  \
  |  |  |  |  ------------------
  |  |  |  |  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (182:14): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  183|      0|             debug_is_token_registered("dumpv_" token) != SNMPERR_SUCCESS)) { \
  |  |  |  |  ------------------
  |  |  |  |  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:14): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  184|      0|            debugmsg("dumph_" token,"\n"); \
  |  |  |  |  185|      0|        } else { \
  |  |  |  |  186|      0|            debugmsg("dumph_" token,"  "); \
  |  |  |  |  187|      0|        } \
  |  |  |  |  188|      0|        __DBGINDENTMORE()
  |  |  |  |  ------------------
  |  |  |  |  |  |  173|      0|#define __DBGINDENTMORE()  debug_indent_add(2)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (79:55): [Folded, False: 625]
  |  |  ------------------
  ------------------
 4913|    625|        data = asn_parse_int(data, length, &type, &pdu->errindex,
 4914|    625|                             sizeof(pdu->errindex));
 4915|    625|        DEBUGINDENTLESS();
  ------------------
  |  |   75|    625|#define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  144|    625|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 625]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  174|      0|#define __DBGINDENTLESS()  debug_indent_add(-2)
  |  |  ------------------
  |  |  |  Branch (75:74): [Folded, False: 625]
  |  |  ------------------
  ------------------
 4916|    625|        if (data == NULL) {
  ------------------
  |  Branch (4916:13): [True: 3, False: 622]
  ------------------
 4917|      3|            return -1;
 4918|      3|        }
 4919|    622|	break;
 4920|       |
 4921|    622|    default:
  ------------------
  |  Branch (4921:5): [True: 15, False: 1.23k]
  ------------------
 4922|     15|        snmp_log(LOG_ERR, "Bad PDU type received: 0x%.2x\n", pdu->command);
 4923|     15|        snmp_increment_statistic(STAT_SNMPINASNPARSEERRS);
  ------------------
  |  |  637|     15|#define  STAT_SNMPINASNPARSEERRS             14
  ------------------
 4924|     15|        return -1;
 4925|  1.25k|    }
 4926|       |
 4927|       |    /*
 4928|       |     * get header for variable-bindings sequence 
 4929|       |     */
 4930|    723|    DEBUGDUMPSECTION("recv", "VarBindList");
  ------------------
  |  |   81|    723|	do {if (_DBG_IF_) {__DBGDUMPSECTION(token,x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|    723|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 723]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               	do {if (_DBG_IF_) {__DBGDUMPSECTION(token,x);} }while(0)
  |  |  ------------------
  |  |  |  |  191|      0|        __DBGPRINTINDENT("dumph_" token); \
  |  |  |  |  ------------------
  |  |  |  |  |  |  175|      0|#define __DBGPRINTINDENT(token) __DBGMSGTL((token, "%*s", __DBGINDENT(), ""))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  192|      0|        debugmsg("dumph_" token,"%s\n",x);\
  |  |  |  |  193|      0|        __DBGINDENTMORE()
  |  |  |  |  ------------------
  |  |  |  |  |  |  173|      0|#define __DBGINDENTMORE()  debug_indent_add(2)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (81:56): [Folded, False: 723]
  |  |  ------------------
  ------------------
 4931|    723|    data = asn_parse_sequence(data, length, &type,
 4932|    723|                              (ASN_SEQUENCE | ASN_CONSTRUCTOR),
  ------------------
  |  |   84|    723|#define ASN_SEQUENCE	    0x10U
  ------------------
                                            (ASN_SEQUENCE | ASN_CONSTRUCTOR),
  ------------------
  |  |   96|    723|#define ASN_CONSTRUCTOR	    0x20U
  ------------------
 4933|    723|                              "varbinds");
 4934|    723|    if (data == NULL)
  ------------------
  |  Branch (4934:9): [True: 99, False: 624]
  ------------------
 4935|     99|        goto fail;
 4936|       |
 4937|    624|    snmp_free_varbind(pdu->variables);
 4938|    624|    pdu->variables = NULL;
 4939|       |
 4940|       |    /*
 4941|       |     * get each varBind sequence 
 4942|       |     */
 4943|  1.76k|    while ((int) *length > 0) {
  ------------------
  |  Branch (4943:12): [True: 1.63k, False: 137]
  ------------------
 4944|  1.63k|        vp = SNMP_MALLOC_TYPEDEF(netsnmp_variable_list);
  ------------------
  |  |   73|  1.63k|#define SNMP_MALLOC_TYPEDEF(td)  (td *) calloc(1, sizeof(td))
  ------------------
 4945|  1.63k|        if (NULL == vp)
  ------------------
  |  Branch (4945:13): [True: 0, False: 1.63k]
  ------------------
 4946|      0|            goto fail;
 4947|       |
 4948|  1.63k|        vp->name_length = MAX_OID_LEN;
  ------------------
  |  |  120|  1.63k|#define MAX_OID_LEN	    128 /* max subid's in an oid */
  ------------------
 4949|  1.63k|        DEBUGDUMPSECTION("recv", "VarBind");
  ------------------
  |  |   81|  1.63k|	do {if (_DBG_IF_) {__DBGDUMPSECTION(token,x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|  1.63k|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 1.63k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               	do {if (_DBG_IF_) {__DBGDUMPSECTION(token,x);} }while(0)
  |  |  ------------------
  |  |  |  |  191|      0|        __DBGPRINTINDENT("dumph_" token); \
  |  |  |  |  ------------------
  |  |  |  |  |  |  175|      0|#define __DBGPRINTINDENT(token) __DBGMSGTL((token, "%*s", __DBGINDENT(), ""))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  192|      0|        debugmsg("dumph_" token,"%s\n",x);\
  |  |  |  |  193|      0|        __DBGINDENTMORE()
  |  |  |  |  ------------------
  |  |  |  |  |  |  173|      0|#define __DBGINDENTMORE()  debug_indent_add(2)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (81:56): [Folded, False: 1.63k]
  |  |  ------------------
  ------------------
 4950|  1.63k|        data = snmp_parse_var_op(data, objid, &vp->name_length, &vp->type,
 4951|  1.63k|                                 &vp->val_len, &var_val, length);
 4952|  1.63k|        if (data == NULL)
  ------------------
  |  Branch (4952:13): [True: 373, False: 1.25k]
  ------------------
 4953|    373|            goto fail;
 4954|  1.25k|        if (snmp_set_var_objid(vp, objid, vp->name_length))
  ------------------
  |  Branch (4954:13): [True: 0, False: 1.25k]
  ------------------
 4955|      0|            goto fail;
 4956|       |
 4957|  1.25k|        len = SNMP_MAX_PACKET_LEN;
  ------------------
  |  |   49|  1.25k|#define SNMP_MAX_PACKET_LEN (0x7fffffff)
  ------------------
 4958|  1.25k|        DEBUGDUMPHEADER("recv", "Value");
  ------------------
  |  |   79|  1.25k|	do {if (_DBG_IF_) {__DBGDUMPHEADER(token,x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|  1.25k|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 1.25k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               	do {if (_DBG_IF_) {__DBGDUMPHEADER(token,x);} }while(0)
  |  |  ------------------
  |  |  |  |  178|      0|        __DBGPRINTINDENT("dumph_" token); \
  |  |  |  |  ------------------
  |  |  |  |  |  |  175|      0|#define __DBGPRINTINDENT(token) __DBGMSGTL((token, "%*s", __DBGINDENT(), ""))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  179|      0|        debugmsg("dumph_" token,x); \
  |  |  |  |  180|      0|        if (debug_is_token_registered("dumpx" token) == SNMPERR_SUCCESS ||    \
  |  |  |  |  ------------------
  |  |  |  |  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (180:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  181|      0|            debug_is_token_registered("dumpv" token) == SNMPERR_SUCCESS ||    \
  |  |  |  |  ------------------
  |  |  |  |  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (181:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  182|      0|            (debug_is_token_registered("dumpx_" token) != SNMPERR_SUCCESS &&  \
  |  |  |  |  ------------------
  |  |  |  |  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (182:14): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  183|      0|             debug_is_token_registered("dumpv_" token) != SNMPERR_SUCCESS)) { \
  |  |  |  |  ------------------
  |  |  |  |  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:14): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  184|      0|            debugmsg("dumph_" token,"\n"); \
  |  |  |  |  185|      0|        } else { \
  |  |  |  |  186|      0|            debugmsg("dumph_" token,"  "); \
  |  |  |  |  187|      0|        } \
  |  |  |  |  188|      0|        __DBGINDENTMORE()
  |  |  |  |  ------------------
  |  |  |  |  |  |  173|      0|#define __DBGINDENTMORE()  debug_indent_add(2)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (79:55): [Folded, False: 1.25k]
  |  |  ------------------
  ------------------
 4959|  1.25k|        switch ((short) vp->type) {
 4960|     95|        case ASN_INTEGER:
  ------------------
  |  |   75|     95|#define ASN_INTEGER	    0x02U
  ------------------
  |  Branch (4960:9): [True: 95, False: 1.16k]
  ------------------
 4961|     95|            vp->val.integer = (long *) vp->buf;
 4962|     95|            vp->val_len = sizeof(long);
 4963|     95|            p = asn_parse_int(var_val, &len, &vp->type,
 4964|     95|                          (long *) vp->val.integer,
 4965|     95|                          sizeof(*vp->val.integer));
 4966|     95|            if (!p)
  ------------------
  |  Branch (4966:17): [True: 4, False: 91]
  ------------------
 4967|      4|                goto fail;
 4968|     91|            break;
 4969|     91|        case ASN_COUNTER:
  ------------------
  |  |   89|     41|#define ASN_COUNTER	(ASN_APPLICATION | 1)
  |  |  ------------------
  |  |  |  |   91|     41|#define ASN_APPLICATION     0x40U
  |  |  ------------------
  ------------------
  |  Branch (4969:9): [True: 41, False: 1.21k]
  ------------------
 4970|     71|        case ASN_GAUGE:
  ------------------
  |  |   90|     71|#define ASN_GAUGE	(ASN_APPLICATION | 2)
  |  |  ------------------
  |  |  |  |   91|     71|#define ASN_APPLICATION     0x40U
  |  |  ------------------
  ------------------
  |  Branch (4970:9): [True: 30, False: 1.22k]
  ------------------
 4971|    102|        case ASN_TIMETICKS:
  ------------------
  |  |   92|    102|#define ASN_TIMETICKS   (ASN_APPLICATION | 3)
  |  |  ------------------
  |  |  |  |   91|    102|#define ASN_APPLICATION     0x40U
  |  |  ------------------
  ------------------
  |  Branch (4971:9): [True: 31, False: 1.22k]
  ------------------
 4972|    135|        case ASN_UINTEGER:
  ------------------
  |  |  100|    135|#define ASN_UINTEGER    (ASN_APPLICATION | 7)   /* historic - don't use */
  |  |  ------------------
  |  |  |  |   91|    135|#define ASN_APPLICATION     0x40U
  |  |  ------------------
  ------------------
  |  Branch (4972:9): [True: 33, False: 1.22k]
  ------------------
 4973|    135|            vp->val.integer = (long *) vp->buf;
 4974|    135|            vp->val_len = sizeof(u_long);
 4975|    135|            p = asn_parse_unsigned_int(var_val, &len, &vp->type,
 4976|    135|                                   (u_long *) vp->val.integer,
 4977|    135|                                   vp->val_len);
 4978|    135|            if (!p)
  ------------------
  |  Branch (4978:17): [True: 8, False: 127]
  ------------------
 4979|      8|                goto fail;
 4980|    127|            break;
 4981|    127|#ifdef NETSNMP_WITH_OPAQUE_SPECIAL_TYPES
 4982|    127|        case ASN_OPAQUE_COUNTER64:
  ------------------
  |  |  156|     23|#define ASN_OPAQUE_COUNTER64 (ASN_OPAQUE_TAG2 + ASN_APP_COUNTER64)
  |  |  ------------------
  |  |  |  |  136|     23|#define ASN_OPAQUE_TAG2 0x30U
  |  |  ------------------
  |  |               #define ASN_OPAQUE_COUNTER64 (ASN_OPAQUE_TAG2 + ASN_APP_COUNTER64)
  |  |  ------------------
  |  |  |  |  146|     23|#define ASN_APP_COUNTER64 (ASN_APPLICATION | 6)
  |  |  |  |  ------------------
  |  |  |  |  |  |   91|     23|#define ASN_APPLICATION     0x40U
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (4982:9): [True: 23, False: 1.23k]
  ------------------
 4983|     55|        case ASN_OPAQUE_U64:
  ------------------
  |  |  192|     55|#define ASN_OPAQUE_U64 (ASN_OPAQUE_TAG2 + ASN_APP_U64)
  |  |  ------------------
  |  |  |  |  136|     55|#define ASN_OPAQUE_TAG2 0x30U
  |  |  ------------------
  |  |               #define ASN_OPAQUE_U64 (ASN_OPAQUE_TAG2 + ASN_APP_U64)
  |  |  ------------------
  |  |  |  |  150|     55|#define ASN_APP_U64 (ASN_APPLICATION | 11)
  |  |  |  |  ------------------
  |  |  |  |  |  |   91|     55|#define ASN_APPLICATION     0x40U
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (4983:9): [True: 32, False: 1.22k]
  ------------------
 4984|     55|#endif                          /* NETSNMP_WITH_OPAQUE_SPECIAL_TYPES */
 4985|    244|        case ASN_COUNTER64:
  ------------------
  |  |   99|    244|#define ASN_COUNTER64   (ASN_APPLICATION | 6)
  |  |  ------------------
  |  |  |  |   91|    244|#define ASN_APPLICATION     0x40U
  |  |  ------------------
  ------------------
  |  Branch (4985:9): [True: 189, False: 1.06k]
  ------------------
 4986|    244|            vp->val.counter64 = (struct counter64 *) vp->buf;
 4987|    244|            vp->val_len = sizeof(struct counter64);
 4988|    244|            p = asn_parse_unsigned_int64(var_val, &len, &vp->type,
 4989|    244|                                     (struct counter64 *) vp->val.
 4990|    244|                                     counter64, vp->val_len);
 4991|    244|            if (!p)
  ------------------
  |  Branch (4991:17): [True: 19, False: 225]
  ------------------
 4992|     19|                goto fail;
 4993|    225|            break;
 4994|    225|#ifdef NETSNMP_WITH_OPAQUE_SPECIAL_TYPES
 4995|    225|        case ASN_OPAQUE_FLOAT:
  ------------------
  |  |  165|     50|#define ASN_OPAQUE_FLOAT (ASN_OPAQUE_TAG2 + ASN_APP_FLOAT)
  |  |  ------------------
  |  |  |  |  136|     50|#define ASN_OPAQUE_TAG2 0x30U
  |  |  ------------------
  |  |               #define ASN_OPAQUE_FLOAT (ASN_OPAQUE_TAG2 + ASN_APP_FLOAT)
  |  |  ------------------
  |  |  |  |  147|     50|#define ASN_APP_FLOAT (ASN_APPLICATION | 8)
  |  |  |  |  ------------------
  |  |  |  |  |  |   91|     50|#define ASN_APPLICATION     0x40U
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (4995:9): [True: 50, False: 1.20k]
  ------------------
 4996|     50|            vp->val.floatVal = (float *) vp->buf;
 4997|     50|            vp->val_len = sizeof(float);
 4998|     50|            p = asn_parse_float(var_val, &len, &vp->type,
 4999|     50|                            vp->val.floatVal, vp->val_len);
 5000|     50|            if (!p)
  ------------------
  |  Branch (5000:17): [True: 18, False: 32]
  ------------------
 5001|     18|                goto fail;
 5002|     32|            break;
 5003|     57|        case ASN_OPAQUE_DOUBLE:
  ------------------
  |  |  174|     57|#define ASN_OPAQUE_DOUBLE (ASN_OPAQUE_TAG2 + ASN_APP_DOUBLE)
  |  |  ------------------
  |  |  |  |  136|     57|#define ASN_OPAQUE_TAG2 0x30U
  |  |  ------------------
  |  |               #define ASN_OPAQUE_DOUBLE (ASN_OPAQUE_TAG2 + ASN_APP_DOUBLE)
  |  |  ------------------
  |  |  |  |  148|     57|#define ASN_APP_DOUBLE (ASN_APPLICATION | 9)
  |  |  |  |  ------------------
  |  |  |  |  |  |   91|     57|#define ASN_APPLICATION     0x40U
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (5003:9): [True: 57, False: 1.20k]
  ------------------
 5004|     57|            vp->val.doubleVal = (double *) vp->buf;
 5005|     57|            vp->val_len = sizeof(double);
 5006|     57|            p = asn_parse_double(var_val, &len, &vp->type,
 5007|     57|                             vp->val.doubleVal, vp->val_len);
 5008|     57|            if (!p)
  ------------------
  |  Branch (5008:17): [True: 29, False: 28]
  ------------------
 5009|     29|                goto fail;
 5010|     28|            break;
 5011|     69|        case ASN_OPAQUE_I64:
  ------------------
  |  |  183|     69|#define ASN_OPAQUE_I64 (ASN_OPAQUE_TAG2 + ASN_APP_I64)
  |  |  ------------------
  |  |  |  |  136|     69|#define ASN_OPAQUE_TAG2 0x30U
  |  |  ------------------
  |  |               #define ASN_OPAQUE_I64 (ASN_OPAQUE_TAG2 + ASN_APP_I64)
  |  |  ------------------
  |  |  |  |  149|     69|#define ASN_APP_I64 (ASN_APPLICATION | 10)
  |  |  |  |  ------------------
  |  |  |  |  |  |   91|     69|#define ASN_APPLICATION     0x40U
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (5011:9): [True: 69, False: 1.18k]
  ------------------
 5012|     69|            vp->val.counter64 = (struct counter64 *) vp->buf;
 5013|     69|            vp->val_len = sizeof(struct counter64);
 5014|     69|            p = asn_parse_signed_int64(var_val, &len, &vp->type,
 5015|     69|                                   (struct counter64 *) vp->val.counter64,
 5016|     69|                                   sizeof(*vp->val.counter64));
 5017|       |
 5018|     69|            if (!p)
  ------------------
  |  Branch (5018:17): [True: 15, False: 54]
  ------------------
 5019|     15|                goto fail;
 5020|     54|            break;
 5021|     54|#endif                          /* NETSNMP_WITH_OPAQUE_SPECIAL_TYPES */
 5022|     54|        case ASN_IPADDRESS:
  ------------------
  |  |   88|     25|#define ASN_IPADDRESS   (ASN_APPLICATION | 0)
  |  |  ------------------
  |  |  |  |   91|     25|#define ASN_APPLICATION     0x40U
  |  |  ------------------
  ------------------
  |  Branch (5022:9): [True: 25, False: 1.23k]
  ------------------
 5023|     25|            if (vp->val_len != 4)
  ------------------
  |  Branch (5023:17): [True: 7, False: 18]
  ------------------
 5024|      7|                goto fail;
 5025|     18|            NETSNMP_FALLTHROUGH;
  ------------------
  |  | 2443|     18|#    define NETSNMP_FALLTHROUGH __attribute__((__fallthrough__))
  ------------------
 5026|    144|        case ASN_OCTET_STR:
  ------------------
  |  |   78|    144|#define ASN_OCTET_STR	    0x04U
  ------------------
  |  Branch (5026:9): [True: 126, False: 1.13k]
  ------------------
 5027|    214|        case ASN_OPAQUE:
  ------------------
  |  |   93|    214|#define ASN_OPAQUE	(ASN_APPLICATION | 4)   /* changed so no conflict with other includes */
  |  |  ------------------
  |  |  |  |   91|    214|#define ASN_APPLICATION     0x40U
  |  |  ------------------
  ------------------
  |  Branch (5027:9): [True: 70, False: 1.18k]
  ------------------
 5028|    251|        case ASN_NSAP:
  ------------------
  |  |   98|    251|#define ASN_NSAP	(ASN_APPLICATION | 5)   /* historic - don't use */
  |  |  ------------------
  |  |  |  |   91|    251|#define ASN_APPLICATION     0x40U
  |  |  ------------------
  ------------------
  |  Branch (5028:9): [True: 37, False: 1.22k]
  ------------------
 5029|    251|            if (vp->val_len < sizeof(vp->buf)) {
  ------------------
  |  Branch (5029:17): [True: 249, False: 2]
  ------------------
 5030|    249|                vp->val.string = (u_char *) vp->buf;
 5031|    249|            } else {
 5032|      2|                vp->val.string = (u_char *) malloc(vp->val_len);
 5033|      2|            }
 5034|    251|            if (vp->val.string == NULL) {
  ------------------
  |  Branch (5034:17): [True: 0, False: 251]
  ------------------
 5035|      0|                goto fail;
 5036|      0|            }
 5037|    251|            p = asn_parse_string(var_val, &len, &vp->type, vp->val.string,
 5038|    251|                             &vp->val_len);
 5039|    251|            if (!p)
  ------------------
  |  Branch (5039:17): [True: 0, False: 251]
  ------------------
 5040|      0|                goto fail;
 5041|    251|            break;
 5042|    251|        case ASN_OBJECT_ID:
  ------------------
  |  |   81|    119|#define ASN_OBJECT_ID	    0x06U
  ------------------
  |  Branch (5042:9): [True: 119, False: 1.13k]
  ------------------
 5043|    119|            vp->val_len = MAX_OID_LEN;
  ------------------
  |  |  120|    119|#define MAX_OID_LEN	    128 /* max subid's in an oid */
  ------------------
 5044|    119|            p = asn_parse_objid(var_val, &len, &vp->type, objid, &vp->val_len);
 5045|    119|            if (!p)
  ------------------
  |  Branch (5045:17): [True: 1, False: 118]
  ------------------
 5046|      1|                goto fail;
 5047|    118|            vp->val_len *= sizeof(oid);
 5048|    118|            vp->val.objid = netsnmp_memdup(objid, vp->val_len);
 5049|    118|            if (vp->val.objid == NULL)
  ------------------
  |  Branch (5049:17): [True: 0, False: 118]
  ------------------
 5050|      0|                goto fail;
 5051|    118|            break;
 5052|    118|        case SNMP_NOSUCHOBJECT:
  ------------------
  |  |  201|     65|#define SNMP_NOSUCHOBJECT    (ASN_CONTEXT | ASN_PRIMITIVE | 0x0) /* 80=128 */
  |  |  ------------------
  |  |  |  |   92|     65|#define ASN_CONTEXT	    0x80U
  |  |  ------------------
  |  |               #define SNMP_NOSUCHOBJECT    (ASN_CONTEXT | ASN_PRIMITIVE | 0x0) /* 80=128 */
  |  |  ------------------
  |  |  |  |   95|     65|#define ASN_PRIMITIVE	    0x00U
  |  |  ------------------
  ------------------
  |  Branch (5052:9): [True: 65, False: 1.19k]
  ------------------
 5053|    100|        case SNMP_NOSUCHINSTANCE:
  ------------------
  |  |  202|    100|#define SNMP_NOSUCHINSTANCE  (ASN_CONTEXT | ASN_PRIMITIVE | 0x1) /* 81=129 */
  |  |  ------------------
  |  |  |  |   92|    100|#define ASN_CONTEXT	    0x80U
  |  |  ------------------
  |  |               #define SNMP_NOSUCHINSTANCE  (ASN_CONTEXT | ASN_PRIMITIVE | 0x1) /* 81=129 */
  |  |  ------------------
  |  |  |  |   95|    100|#define ASN_PRIMITIVE	    0x00U
  |  |  ------------------
  ------------------
  |  Branch (5053:9): [True: 35, False: 1.22k]
  ------------------
 5054|    122|        case SNMP_ENDOFMIBVIEW:
  ------------------
  |  |  203|    122|#define SNMP_ENDOFMIBVIEW    (ASN_CONTEXT | ASN_PRIMITIVE | 0x2) /* 82=130 */
  |  |  ------------------
  |  |  |  |   92|    122|#define ASN_CONTEXT	    0x80U
  |  |  ------------------
  |  |               #define SNMP_ENDOFMIBVIEW    (ASN_CONTEXT | ASN_PRIMITIVE | 0x2) /* 82=130 */
  |  |  ------------------
  |  |  |  |   95|    122|#define ASN_PRIMITIVE	    0x00U
  |  |  ------------------
  ------------------
  |  Branch (5054:9): [True: 22, False: 1.23k]
  ------------------
 5055|    162|        case ASN_NULL:
  ------------------
  |  |   79|    162|#define ASN_NULL	    0x05U
  ------------------
  |  Branch (5055:9): [True: 40, False: 1.21k]
  ------------------
 5056|    162|            break;
 5057|     64|        case ASN_BIT_STR:
  ------------------
  |  |   77|     64|#define ASN_BIT_STR	    0x03U
  ------------------
  |  Branch (5057:9): [True: 64, False: 1.19k]
  ------------------
 5058|     64|            vp->val.bitstring = (u_char *) malloc(vp->val_len);
 5059|     64|            if (vp->val.bitstring == NULL) {
  ------------------
  |  Branch (5059:17): [True: 0, False: 64]
  ------------------
 5060|      0|                goto fail;
 5061|      0|            }
 5062|     64|            p = asn_parse_bitstring(var_val, &len, &vp->type,
 5063|     64|                                vp->val.bitstring, &vp->val_len);
 5064|     64|            if (!p)
  ------------------
  |  Branch (5064:17): [True: 8, False: 56]
  ------------------
 5065|      8|                goto fail;
 5066|     56|            break;
 5067|     56|        default:
  ------------------
  |  Branch (5067:9): [True: 5, False: 1.25k]
  ------------------
 5068|      5|            snmp_log(LOG_ERR, "bad type returned (%x)\n", vp->type);
 5069|      5|            goto fail;
 5070|      0|            break;
 5071|  1.25k|        }
 5072|  1.14k|        DEBUGINDENTADD(-4);
  ------------------
  |  |   73|  1.14k|#define DEBUGINDENTADD(x)  do {if (_DBG_IF_) {__DBGINDENTADD(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|  1.14k|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 1.14k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGINDENTADD(x)  do {if (_DBG_IF_) {__DBGINDENTADD(x);} }while(0)
  |  |  ------------------
  |  |  |  |  172|      0|#define __DBGINDENTADD(x)  debug_indent_add(x)
  |  |  ------------------
  |  |  |  Branch (73:74): [Folded, False: 1.14k]
  |  |  ------------------
  ------------------
 5073|       |
 5074|  1.14k|        if (NULL == vplast) {
  ------------------
  |  Branch (5074:13): [True: 513, False: 631]
  ------------------
 5075|    513|            pdu->variables = vp;
 5076|    631|        } else {
 5077|    631|            vplast->next_variable = vp;
 5078|    631|        }
 5079|  1.14k|        vplast = vp;
 5080|  1.14k|        vp = NULL;
 5081|  1.14k|    }
 5082|    137|    return 0;
 5083|       |
 5084|    586|  fail:
 5085|    586|    {
 5086|    586|        const char *errstr = snmp_api_errstring(SNMPERR_SUCCESS);
  ------------------
  |  |  184|    586|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
 5087|    586|        DEBUGMSGTL(("recv", "error while parsing VarBindList:%s\n", errstr));
  ------------------
  |  |   66|    586|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|    586|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 586]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 586]
  |  |  ------------------
  ------------------
 5088|    586|    }
 5089|       |    /** if we were parsing a var, remove it from the pdu and free it */
 5090|    586|    if (vp)
  ------------------
  |  Branch (5090:9): [True: 487, False: 99]
  ------------------
 5091|    487|        snmp_free_var(vp);
 5092|       |
 5093|    586|    return -1;
 5094|    624|}
snmpv3_scopedPDU_parse:
 5105|  4.94k|{
 5106|  4.94k|    u_char          tmp_buf[SNMP_MAX_MSG_SIZE];
 5107|  4.94k|    size_t          tmp_buf_len;
 5108|  4.94k|    u_char          type;
 5109|  4.94k|    size_t          asn_len;
 5110|  4.94k|    u_char         *data;
 5111|       |
 5112|  4.94k|    pdu->command = 0;           /* initialize so we know if it got parsed */
 5113|  4.94k|    asn_len = *length;
 5114|  4.94k|    data = asn_parse_sequence(cp, &asn_len, &type,
 5115|  4.94k|                              (ASN_SEQUENCE | ASN_CONSTRUCTOR),
  ------------------
  |  |   84|  4.94k|#define ASN_SEQUENCE	    0x10U
  ------------------
                                            (ASN_SEQUENCE | ASN_CONSTRUCTOR),
  ------------------
  |  |   96|  4.94k|#define ASN_CONSTRUCTOR	    0x20U
  ------------------
 5116|  4.94k|                              "plaintext scopedPDU");
 5117|  4.94k|    if (data == NULL) {
  ------------------
  |  Branch (5117:9): [True: 818, False: 4.12k]
  ------------------
 5118|    818|        return NULL;
 5119|    818|    }
 5120|  4.12k|    *length -= data - cp;
 5121|       |
 5122|       |    /*
 5123|       |     * contextEngineID from scopedPdu  
 5124|       |     */
 5125|  4.12k|    DEBUGDUMPHEADER("recv", "contextEngineID");
  ------------------
  |  |   79|  4.12k|	do {if (_DBG_IF_) {__DBGDUMPHEADER(token,x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|  4.12k|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 4.12k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               	do {if (_DBG_IF_) {__DBGDUMPHEADER(token,x);} }while(0)
  |  |  ------------------
  |  |  |  |  178|      0|        __DBGPRINTINDENT("dumph_" token); \
  |  |  |  |  ------------------
  |  |  |  |  |  |  175|      0|#define __DBGPRINTINDENT(token) __DBGMSGTL((token, "%*s", __DBGINDENT(), ""))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  179|      0|        debugmsg("dumph_" token,x); \
  |  |  |  |  180|      0|        if (debug_is_token_registered("dumpx" token) == SNMPERR_SUCCESS ||    \
  |  |  |  |  ------------------
  |  |  |  |  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (180:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  181|      0|            debug_is_token_registered("dumpv" token) == SNMPERR_SUCCESS ||    \
  |  |  |  |  ------------------
  |  |  |  |  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (181:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  182|      0|            (debug_is_token_registered("dumpx_" token) != SNMPERR_SUCCESS &&  \
  |  |  |  |  ------------------
  |  |  |  |  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (182:14): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  183|      0|             debug_is_token_registered("dumpv_" token) != SNMPERR_SUCCESS)) { \
  |  |  |  |  ------------------
  |  |  |  |  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:14): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  184|      0|            debugmsg("dumph_" token,"\n"); \
  |  |  |  |  185|      0|        } else { \
  |  |  |  |  186|      0|            debugmsg("dumph_" token,"  "); \
  |  |  |  |  187|      0|        } \
  |  |  |  |  188|      0|        __DBGINDENTMORE()
  |  |  |  |  ------------------
  |  |  |  |  |  |  173|      0|#define __DBGINDENTMORE()  debug_indent_add(2)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (79:55): [Folded, False: 4.12k]
  |  |  ------------------
  ------------------
 5126|  4.12k|    data = asn_parse_string(data, length, &type, pdu->contextEngineID,
 5127|  4.12k|                            &pdu->contextEngineIDLen);
 5128|  4.12k|    DEBUGINDENTLESS();
  ------------------
  |  |   75|  4.12k|#define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  144|  4.12k|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 4.12k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  174|      0|#define __DBGINDENTLESS()  debug_indent_add(-2)
  |  |  ------------------
  |  |  |  Branch (75:74): [Folded, False: 4.12k]
  |  |  ------------------
  ------------------
 5129|  4.12k|    if (data == NULL) {
  ------------------
  |  Branch (5129:9): [True: 2.78k, False: 1.33k]
  ------------------
 5130|  2.78k|        ERROR_MSG("error parsing contextEngineID from scopedPdu");
  ------------------
  |  |  188|  2.78k|#define ERROR_MSG(string)	snmp_set_detail(string)
  ------------------
 5131|  2.78k|        return NULL;
 5132|  2.78k|    }
 5133|       |
 5134|       |    /*
 5135|       |     * parse contextName from scopedPdu
 5136|       |     */
 5137|  1.33k|    tmp_buf_len = SNMP_MAX_CONTEXT_SIZE;
  ------------------
  |  |  113|  1.33k|#define SNMP_MAX_CONTEXT_SIZE      256
  ------------------
 5138|  1.33k|    DEBUGDUMPHEADER("recv", "contextName");
  ------------------
  |  |   79|  1.33k|	do {if (_DBG_IF_) {__DBGDUMPHEADER(token,x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|  1.33k|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 1.33k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               	do {if (_DBG_IF_) {__DBGDUMPHEADER(token,x);} }while(0)
  |  |  ------------------
  |  |  |  |  178|      0|        __DBGPRINTINDENT("dumph_" token); \
  |  |  |  |  ------------------
  |  |  |  |  |  |  175|      0|#define __DBGPRINTINDENT(token) __DBGMSGTL((token, "%*s", __DBGINDENT(), ""))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  179|      0|        debugmsg("dumph_" token,x); \
  |  |  |  |  180|      0|        if (debug_is_token_registered("dumpx" token) == SNMPERR_SUCCESS ||    \
  |  |  |  |  ------------------
  |  |  |  |  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (180:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  181|      0|            debug_is_token_registered("dumpv" token) == SNMPERR_SUCCESS ||    \
  |  |  |  |  ------------------
  |  |  |  |  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (181:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  182|      0|            (debug_is_token_registered("dumpx_" token) != SNMPERR_SUCCESS &&  \
  |  |  |  |  ------------------
  |  |  |  |  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (182:14): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  183|      0|             debug_is_token_registered("dumpv_" token) != SNMPERR_SUCCESS)) { \
  |  |  |  |  ------------------
  |  |  |  |  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:14): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  184|      0|            debugmsg("dumph_" token,"\n"); \
  |  |  |  |  185|      0|        } else { \
  |  |  |  |  186|      0|            debugmsg("dumph_" token,"  "); \
  |  |  |  |  187|      0|        } \
  |  |  |  |  188|      0|        __DBGINDENTMORE()
  |  |  |  |  ------------------
  |  |  |  |  |  |  173|      0|#define __DBGINDENTMORE()  debug_indent_add(2)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (79:55): [Folded, False: 1.33k]
  |  |  ------------------
  ------------------
 5139|  1.33k|    data = asn_parse_string(data, length, &type, tmp_buf, &tmp_buf_len);
 5140|  1.33k|    DEBUGINDENTLESS();
  ------------------
  |  |   75|  1.33k|#define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  144|  1.33k|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 1.33k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  174|      0|#define __DBGINDENTLESS()  debug_indent_add(-2)
  |  |  ------------------
  |  |  |  Branch (75:74): [Folded, False: 1.33k]
  |  |  ------------------
  ------------------
 5141|  1.33k|    if (data == NULL) {
  ------------------
  |  Branch (5141:9): [True: 65, False: 1.27k]
  ------------------
 5142|     65|        ERROR_MSG("error parsing contextName from scopedPdu");
  ------------------
  |  |  188|     65|#define ERROR_MSG(string)	snmp_set_detail(string)
  ------------------
 5143|     65|        return NULL;
 5144|     65|    }
 5145|       |
 5146|  1.27k|    SNMP_FREE(pdu->contextName);
  ------------------
  |  |   62|  1.27k|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 0, False: 1.27k]
  |  |  |  Branch (62:66): [Folded, False: 1.27k]
  |  |  ------------------
  ------------------
 5147|  1.27k|    pdu->contextName = netsnmp_memdup_nt(tmp_buf, tmp_buf_len,
 5148|  1.27k|                                         &pdu->contextNameLen);
 5149|  1.27k|    if (pdu->contextName == NULL) {
  ------------------
  |  Branch (5149:9): [True: 0, False: 1.27k]
  ------------------
 5150|      0|        ERROR_MSG("error copying contextName from scopedPdu");
  ------------------
  |  |  188|      0|#define ERROR_MSG(string)	snmp_set_detail(string)
  ------------------
 5151|      0|        return NULL;
 5152|      0|    }
 5153|       |
 5154|       |    /*
 5155|       |     * Get the PDU type 
 5156|       |     */
 5157|  1.27k|    asn_len = *length;
 5158|  1.27k|    cp = asn_parse_header(data, &asn_len, &type);
 5159|  1.27k|    if (cp == NULL)
  ------------------
  |  Branch (5159:9): [True: 17, False: 1.25k]
  ------------------
 5160|     17|        return NULL;
 5161|       |
 5162|  1.25k|    pdu->command = type;
 5163|       |
 5164|  1.25k|    return data;
 5165|  1.27k|}
snmp_sess_send:
 5461|     24|{
 5462|     24|    return snmp_sess_async_send(slp, pdu, NULL, NULL);
 5463|     24|}
snmp_sess_async_send:
 5678|     24|{
 5679|       |
 5680|     24|    return snmp_sess_async_send_cp(slp, pdu, callback, cb_data, 0);
 5681|     24|}
snmp_sess_async_send_cp:
 5687|     24|{
 5688|     24|    int             rc;
 5689|       |
 5690|     24|    if (slp == NULL) {
  ------------------
  |  Branch (5690:9): [True: 24, False: 0]
  ------------------
 5691|     24|        snmp_errno = SNMPERR_BAD_SESSION;       /*MTCRITICAL_RESOURCE */
  ------------------
  |  |  188|     24|#define SNMPERR_BAD_SESSION		(-4)
  ------------------
 5692|     24|        return (0);
 5693|     24|    }
 5694|       |    /*
 5695|       |     * send pdu
 5696|       |     */
 5697|       |
 5698|      0|    rc = _sess_async_send(slp, pdu, callback, cb_data, cp_inc);
 5699|      0|    if (rc == 0)
  ------------------
  |  Branch (5699:9): [True: 0, False: 0]
  ------------------
 5700|      0|        SET_SNMP_ERROR(slp->session->s_snmp_errno);
  ------------------
  |  |   43|      0|#define SET_SNMP_ERROR(x) snmp_errno=(x)
  ------------------
 5701|      0|    return rc;
 5702|     24|}
snmp_free_var_internals:
 5710|  1.67k|{
 5711|  1.67k|    if (!var)
  ------------------
  |  Branch (5711:9): [True: 0, False: 1.67k]
  ------------------
 5712|      0|        return;
 5713|       |
 5714|  1.67k|    if (var->name != var->name_loc)
  ------------------
  |  Branch (5714:9): [True: 373, False: 1.30k]
  ------------------
 5715|    373|        SNMP_FREE(var->name);
  ------------------
  |  |   62|    373|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 0, False: 373]
  |  |  |  Branch (62:66): [Folded, False: 373]
  |  |  ------------------
  ------------------
 5716|  1.67k|    if (var->val.string != var->buf)
  ------------------
  |  Branch (5716:9): [True: 737, False: 942]
  ------------------
 5717|    737|        SNMP_FREE(var->val.string);
  ------------------
  |  |   62|    737|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 187, False: 550]
  |  |  |  Branch (62:66): [Folded, False: 737]
  |  |  ------------------
  ------------------
 5718|  1.67k|    if (var->data) {
  ------------------
  |  Branch (5718:9): [True: 0, False: 1.67k]
  ------------------
 5719|      0|        if (var->dataFreeHook) {
  ------------------
  |  Branch (5719:13): [True: 0, False: 0]
  ------------------
 5720|      0|            var->dataFreeHook(var->data);
 5721|      0|            var->data = NULL;
 5722|      0|        } else {
 5723|       |            SNMP_FREE(var->data);
  ------------------
  |  |   62|      0|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 0, False: 0]
  |  |  |  Branch (62:66): [Folded, False: 0]
  |  |  ------------------
  ------------------
 5724|      0|        }
 5725|      0|    }
 5726|  1.67k|}
snmp_free_var:
 5730|  1.67k|{
 5731|  1.67k|    snmp_free_var_internals(var);
 5732|  1.67k|    free(var);
 5733|  1.67k|}
snmp_free_varbind:
 5737|  6.70k|{
 5738|  6.70k|    netsnmp_variable_list *ptr;
 5739|  7.89k|    while (var) {
  ------------------
  |  Branch (5739:12): [True: 1.19k, False: 6.70k]
  ------------------
 5740|  1.19k|        ptr = var->next_variable;
 5741|  1.19k|        snmp_free_var(var);
 5742|  1.19k|        var = ptr;
 5743|  1.19k|    }
 5744|  6.70k|}
snmp_free_pdu:
 5751|  6.05k|{
 5752|  6.05k|    struct snmp_secmod_def *sptr;
 5753|       |
 5754|  6.05k|    if (!pdu)
  ------------------
  |  Branch (5754:9): [True: 0, False: 6.05k]
  ------------------
 5755|      0|        return;
 5756|       |
 5757|  6.05k|    free_securityStateRef(pdu);
 5758|       |
 5759|  6.05k|    sptr = find_sec_mod(pdu->securityModel);
 5760|  6.05k|    if (sptr && sptr->pdu_free)
  ------------------
  |  Branch (5760:9): [True: 1.95k, False: 4.10k]
  |  Branch (5760:17): [True: 96, False: 1.85k]
  ------------------
 5761|     96|        (*sptr->pdu_free)(pdu);
 5762|       |
 5763|  6.05k|    snmp_free_varbind(pdu->variables);
 5764|  6.05k|    free(pdu->enterprise);
 5765|  6.05k|    free(pdu->community);
 5766|  6.05k|    free(pdu->contextEngineID);
 5767|  6.05k|    free(pdu->securityEngineID);
 5768|  6.05k|    free(pdu->contextName);
 5769|  6.05k|    free(pdu->securityName);
 5770|  6.05k|    free(pdu->transport_data);
 5771|  6.05k|    free(pdu);
 5772|  6.05k|}
snmp_oid_compare:
 7391|  2.35k|{
 7392|  2.35k|    register int    len;
 7393|  2.35k|    register const oid *name1 = in_name1;
 7394|  2.35k|    register const oid *name2 = in_name2;
 7395|       |
 7396|       |    /*
 7397|       |     * len = minimum of len1 and len2 
 7398|       |     */
 7399|  2.35k|    if (len1 < len2)
  ------------------
  |  Branch (7399:9): [True: 59, False: 2.29k]
  ------------------
 7400|     59|        len = len1;
 7401|  2.29k|    else
 7402|  2.29k|        len = len2;
 7403|       |    /*
 7404|       |     * find first non-matching OID 
 7405|       |     */
 7406|  23.6k|    while (len-- > 0) {
  ------------------
  |  Branch (7406:12): [True: 22.8k, False: 768]
  ------------------
 7407|       |        /*
 7408|       |         * these must be done in separate comparisons, since
 7409|       |         * subtracting them and using that result has problems with
 7410|       |         * subids > 2^31. 
 7411|       |         */
 7412|  22.8k|        if (*(name1) != *(name2)) {
  ------------------
  |  Branch (7412:13): [True: 1.58k, False: 21.3k]
  ------------------
 7413|  1.58k|            if (*(name1) < *(name2))
  ------------------
  |  Branch (7413:17): [True: 822, False: 765]
  ------------------
 7414|    822|                return -1;
 7415|    765|            return 1;
 7416|  1.58k|        }
 7417|  21.3k|        name1++;
 7418|  21.3k|        name2++;
 7419|  21.3k|    }
 7420|       |    /*
 7421|       |     * both OIDs equal up to length of shorter OID 
 7422|       |     */
 7423|    768|    if (len1 < len2)
  ------------------
  |  Branch (7423:9): [True: 3, False: 765]
  ------------------
 7424|      3|        return -1;
 7425|    765|    if (len2 < len1)
  ------------------
  |  Branch (7425:9): [True: 8, False: 757]
  ------------------
 7426|      8|        return 1;
 7427|    757|    return 0;
 7428|    765|}
netsnmp_oid_equals:
 7528|    662|{
 7529|    662|    register const oid *name1 = in_name1;
 7530|    662|    register const oid *name2 = in_name2;
 7531|    662|    register int    len = len1;
 7532|       |
 7533|       |    /*
 7534|       |     * len = minimum of len1 and len2 
 7535|       |     */
 7536|    662|    if (len1 != len2)
  ------------------
  |  Branch (7536:9): [True: 88, False: 574]
  ------------------
 7537|     88|        return 1;
 7538|       |    /*
 7539|       |     * Handle 'null' OIDs
 7540|       |     */
 7541|    574|    if (len1 == 0)
  ------------------
  |  Branch (7541:9): [True: 0, False: 574]
  ------------------
 7542|      0|        return 0;   /* Two null OIDs are (trivially) the same */
 7543|    574|    if (!name1 || !name2)
  ------------------
  |  Branch (7543:9): [True: 0, False: 574]
  |  Branch (7543:19): [True: 0, False: 574]
  ------------------
 7544|      0|        return 1;   /* Otherwise something's wrong, so report a non-match */
 7545|       |    /*
 7546|       |     * find first non-matching OID 
 7547|       |     */
 7548|  5.67k|    while (len-- > 0) {
  ------------------
  |  Branch (7548:12): [True: 5.67k, False: 0]
  ------------------
 7549|       |        /*
 7550|       |         * these must be done in separate comparisons, since
 7551|       |         * subtracting them and using that result has problems with
 7552|       |         * subids > 2^31. 
 7553|       |         */
 7554|  5.67k|        if (*(name1++) != *(name2++))
  ------------------
  |  Branch (7554:13): [True: 574, False: 5.10k]
  ------------------
 7555|    574|            return 1;
 7556|  5.67k|    }
 7557|      0|    return 0;
 7558|    574|}
snmp_pdu_add_variable:
 7670|     24|{
 7671|     24|    return snmp_varlist_add_variable(&pdu->variables, name, name_length,
 7672|     24|                                     type, value, len);
 7673|     24|}
snmp_varlist_add_variable:
 7684|     24|{
 7685|     24|    netsnmp_variable_list *vars, *vtmp;
 7686|     24|    int rc;
 7687|       |
 7688|     24|    if (varlist == NULL)
  ------------------
  |  Branch (7688:9): [True: 0, False: 24]
  ------------------
 7689|      0|        return NULL;
 7690|       |
 7691|     24|    vars = SNMP_MALLOC_TYPEDEF(netsnmp_variable_list);
  ------------------
  |  |   73|     24|#define SNMP_MALLOC_TYPEDEF(td)  (td *) calloc(1, sizeof(td))
  ------------------
 7692|     24|    if (vars == NULL)
  ------------------
  |  Branch (7692:9): [True: 0, False: 24]
  ------------------
 7693|      0|        return NULL;
 7694|       |
 7695|     24|    vars->type = type;
 7696|       |
 7697|     24|    rc = snmp_set_var_value( vars, value, len );
 7698|     24|    if (( 0 != rc ) ||
  ------------------
  |  Branch (7698:9): [True: 0, False: 24]
  ------------------
 7699|     24|        (name != NULL && snmp_set_var_objid(vars, name, name_length))) {
  ------------------
  |  Branch (7699:10): [True: 24, False: 0]
  |  Branch (7699:26): [True: 0, False: 24]
  ------------------
 7700|      0|        snmp_free_var(vars);
 7701|      0|        return NULL;
 7702|      0|    }
 7703|       |
 7704|       |    /*
 7705|       |     * put only qualified variable onto varlist 
 7706|       |     */
 7707|     24|    if (*varlist == NULL) {
  ------------------
  |  Branch (7707:9): [True: 24, False: 0]
  ------------------
 7708|     24|        *varlist = vars;
 7709|     24|    } else {
 7710|      0|        for (vtmp = *varlist; vtmp->next_variable;
  ------------------
  |  Branch (7710:31): [True: 0, False: 0]
  ------------------
 7711|      0|             vtmp = vtmp->next_variable);
 7712|       |
 7713|      0|        vtmp->next_variable = vars;
 7714|      0|    }
 7715|       |
 7716|     24|    return vars;
 7717|     24|}
snmp_duplicate_objid:
 8395|     28|{
 8396|     28|    oid            *returnOid;
 8397|     28|    if (objToCopy != NULL && objToCopyLen != 0) {
  ------------------
  |  Branch (8397:9): [True: 28, False: 0]
  |  Branch (8397:30): [True: 28, False: 0]
  ------------------
 8398|     28|        returnOid = (oid *) malloc(objToCopyLen * sizeof(oid));
 8399|     28|        if (returnOid) {
  ------------------
  |  Branch (8399:13): [True: 28, False: 0]
  ------------------
 8400|     28|            memcpy(returnOid, objToCopy, objToCopyLen * sizeof(oid));
 8401|     28|        }
 8402|     28|    } else
 8403|      0|        returnOid = NULL;
 8404|     28|    return returnOid;
 8405|     28|}
snmp_increment_statistic:
 8415|  2.87k|{
 8416|  2.87k|    if (which >= 0 && which < NETSNMP_STAT_MAX_STATS) {
  ------------------
  |  |  710|  2.87k|#define  NETSNMP_STAT_MAX_STATS              (STAT_TLSTM_STATS_END+1)
  |  |  ------------------
  |  |  |  |  706|  2.87k|#define  STAT_TLSTM_STATS_END          STAT_TLSTM_SNMPTLSTMSESSIONINVALIDCACHES
  |  |  |  |  ------------------
  |  |  |  |  |  |  703|  2.87k|#define  STAT_TLSTM_SNMPTLSTMSESSIONINVALIDCACHES              56
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (8416:9): [True: 2.87k, False: 0]
  |  Branch (8416:23): [True: 2.87k, False: 0]
  ------------------
 8417|  2.87k|        statistics[which]++;
 8418|  2.87k|        return statistics[which];
 8419|  2.87k|    }
 8420|      0|    return 0;
 8421|  2.87k|}
snmp_init_statistics:
 8443|      2|{
 8444|      2|    memset(statistics, 0, sizeof(statistics));
 8445|      2|}
snmp_api.c:_init_snmp:
  710|      2|{
  711|       |
  712|      2|    struct timeval  tv;
  713|      2|    long            tmpReqid, tmpMsgid;
  714|       |
  715|      2|    if (_init_snmp_init_done)
  ------------------
  |  Branch (715:9): [True: 0, False: 2]
  ------------------
  716|      0|        return;
  717|      2|    _init_snmp_init_done = 1;
  718|      2|    Reqid = 1;
  719|       |
  720|      2|    snmp_res_init();            /* initialize the mt locking structures */
  ------------------
  |  |   78|      2|#define snmp_res_init() do {} while (0)
  |  |  ------------------
  |  |  |  Branch (78:38): [Folded, False: 2]
  |  |  ------------------
  ------------------
  721|      2|#ifndef NETSNMP_DISABLE_MIB_LOADING
  722|      2|    netsnmp_init_mib_internals();
  723|      2|#endif /* NETSNMP_DISABLE_MIB_LOADING */
  724|      2|    netsnmp_tdomain_init();
  725|       |
  726|      2|    gettimeofday(&tv, (struct timezone *) 0);
  727|       |    /*
  728|       |     * Now = tv;
  729|       |     */
  730|       |
  731|       |    /*
  732|       |     * get pseudo-random values for request ID and message ID 
  733|       |     */
  734|      2|    netsnmp_srandom((unsigned)(tv.tv_sec ^ tv.tv_usec));
  735|      2|    tmpReqid = netsnmp_random();
  736|      2|    tmpMsgid = netsnmp_random();
  737|       |
  738|       |    /*
  739|       |     * don't allow zero value to repeat init 
  740|       |     */
  741|      2|    if (tmpReqid == 0)
  ------------------
  |  Branch (741:9): [True: 0, False: 2]
  ------------------
  742|      0|        tmpReqid = 1;
  743|      2|    if (tmpMsgid == 0)
  ------------------
  |  Branch (743:9): [True: 0, False: 2]
  ------------------
  744|      0|        tmpMsgid = 1;
  745|      2|    Reqid = tmpReqid;
  746|      2|    Msgid = tmpMsgid;
  747|       |
  748|      2|    netsnmp_register_default_domain("snmp", "udp udp6");
  749|      2|    netsnmp_register_default_domain("snmptrap", "udp udp6");
  750|       |
  751|      2|    netsnmp_register_default_target("snmp", "udp", ":161");
  752|      2|    netsnmp_register_default_target("snmp", "tcp", ":161");
  753|      2|    netsnmp_register_default_target("snmp", "udp6", ":161");
  754|      2|    netsnmp_register_default_target("snmp", "tcp6", ":161");
  755|      2|    netsnmp_register_default_target("snmp", "dtlsudp", ":10161");
  756|      2|    netsnmp_register_default_target("snmp", "tlstcp", ":10161");
  757|      2|    netsnmp_register_default_target("snmp", "ipx", "/36879");
  758|       |
  759|      2|    netsnmp_register_default_target("snmptrap", "udp", ":162");
  760|      2|    netsnmp_register_default_target("snmptrap", "tcp", ":162");
  761|      2|    netsnmp_register_default_target("snmptrap", "udp6", ":162");
  762|      2|    netsnmp_register_default_target("snmptrap", "tcp6", ":162");
  763|      2|    netsnmp_register_default_target("snmptrap", "dtlsudp", ":10162");
  764|      2|    netsnmp_register_default_target("snmptrap", "tlstcp", ":10162");
  765|      2|    netsnmp_register_default_target("snmptrap", "ipx", "/36880");
  766|       |
  767|      2|    netsnmp_ds_set_int(NETSNMP_DS_LIBRARY_ID, 
  ------------------
  |  |   48|      2|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  768|      2|                       NETSNMP_DS_LIB_HEX_OUTPUT_LENGTH, 16);
  ------------------
  |  |  121|      2|#define NETSNMP_DS_LIB_HEX_OUTPUT_LENGTH    6
  ------------------
  769|      2|    netsnmp_ds_set_int(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_RETRIES,
  ------------------
  |  |   48|      2|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
                  netsnmp_ds_set_int(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_RETRIES,
  ------------------
  |  |  131|      2|#define NETSNMP_DS_LIB_RETRIES             15
  ------------------
  770|      2|                       DEFAULT_RETRIES);
  ------------------
  |  |  191|      2|#define DEFAULT_RETRIES	    5
  ------------------
  771|      2|    netsnmp_ds_set_boolean(NETSNMP_DS_LIBRARY_ID, 
  ------------------
  |  |   48|      2|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  772|      2|			   NETSNMP_DS_LIB_MIB_ERRORS, 1);
  ------------------
  |  |   59|      2|#define NETSNMP_DS_LIB_MIB_ERRORS          0
  ------------------
  773|       |
  774|      2|#ifdef NETSNMP_USE_REVERSE_ASNENCODING
  775|      2|    netsnmp_ds_set_boolean(NETSNMP_DS_LIBRARY_ID, 
  ------------------
  |  |   48|      2|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  776|      2|			   NETSNMP_DS_LIB_REVERSE_ENCODE,
  ------------------
  |  |   80|      2|#define NETSNMP_DS_LIB_REVERSE_ENCODE      20   /* encode packets from back to front */
  ------------------
  777|      2|			   NETSNMP_DEFAULT_ASNENCODING_DIRECTION);
  ------------------
  |  | 2027|      2|#define NETSNMP_DEFAULT_ASNENCODING_DIRECTION 1 /* 1 = reverse, 0 = forwards */
  ------------------
  778|      2|#endif
  779|      2|}
snmp_api.c:register_default_handlers:
  808|      2|{
  809|      2|    netsnmp_ds_register_config(ASN_BOOLEAN, "snmp", "dumpPacket",
  ------------------
  |  |   72|      2|#define ASN_BOOLEAN	    0x01U
  ------------------
  810|      2|		      NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_DUMP_PACKET);
  ------------------
  |  |   48|      2|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
              		      NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_DUMP_PACKET);
  ------------------
  |  |   63|      2|#define NETSNMP_DS_LIB_DUMP_PACKET         4
  ------------------
  811|      2|    netsnmp_ds_register_config(ASN_BOOLEAN, "snmp", "reverseEncodeBER",
  ------------------
  |  |   72|      2|#define ASN_BOOLEAN	    0x01U
  ------------------
  812|      2|		      NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_REVERSE_ENCODE);
  ------------------
  |  |   48|      2|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
              		      NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_REVERSE_ENCODE);
  ------------------
  |  |   80|      2|#define NETSNMP_DS_LIB_REVERSE_ENCODE      20   /* encode packets from back to front */
  ------------------
  813|      2|    netsnmp_ds_register_config(ASN_INTEGER, "snmp", "defaultPort",
  ------------------
  |  |   75|      2|#define ASN_INTEGER	    0x02U
  ------------------
  814|      2|		      NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_DEFAULT_PORT);
  ------------------
  |  |   48|      2|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
              		      NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_DEFAULT_PORT);
  ------------------
  |  |  117|      2|#define NETSNMP_DS_LIB_DEFAULT_PORT         3
  ------------------
  815|      2|#ifndef NETSNMP_FEATURE_REMOVE_RUNTIME_DISABLE_VERSION
  816|      2|    netsnmp_ds_register_config(ASN_BOOLEAN, "snmp", "disableSNMPv3",
  ------------------
  |  |   72|      2|#define ASN_BOOLEAN	    0x01U
  ------------------
  817|      2|                      NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_DISABLE_V3);
  ------------------
  |  |   48|      2|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
                                    NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_DISABLE_V3);
  ------------------
  |  |  105|      2|#define NETSNMP_DS_LIB_DISABLE_V3          45 /* disable SNMPv3 */
  ------------------
  818|      2|#endif /* NETSNMP_FEATURE_REMOVE_RUNTIME_DISABLE_VERSION */
  819|      2|#if !defined(NETSNMP_DISABLE_SNMPV1) || !defined(NETSNMP_DISABLE_SNMPV2C)
  820|      2|#ifndef NETSNMP_FEATURE_REMOVE_RUNTIME_DISABLE_VERSION
  821|      2|#if !defined(NETSNMP_DISABLE_SNMPV1)
  822|      2|    netsnmp_ds_register_config(ASN_BOOLEAN, "snmp", "disableSNMPv1",
  ------------------
  |  |   72|      2|#define ASN_BOOLEAN	    0x01U
  ------------------
  823|      2|                      NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_DISABLE_V1);
  ------------------
  |  |   48|      2|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
                                    NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_DISABLE_V1);
  ------------------
  |  |  103|      2|#define NETSNMP_DS_LIB_DISABLE_V1          43 /* disable SNMPv1 */
  ------------------
  824|      2|#endif
  825|      2|#if !defined(NETSNMP_DISABLE_SNMPV2C)
  826|      2|    netsnmp_ds_register_config(ASN_BOOLEAN, "snmp", "disableSNMPv2c",
  ------------------
  |  |   72|      2|#define ASN_BOOLEAN	    0x01U
  ------------------
  827|      2|                      NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_DISABLE_V2c);
  ------------------
  |  |   48|      2|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
                                    NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_DISABLE_V2c);
  ------------------
  |  |  104|      2|#define NETSNMP_DS_LIB_DISABLE_V2c         44 /* disable SNMPv2c */
  ------------------
  828|      2|#endif
  829|      2|#endif /* NETSNMP_FEATURE_REMOVE_RUNTIME_DISABLE_VERSION */
  830|      2|    netsnmp_ds_register_config(ASN_OCTET_STR, "snmp", "defCommunity",
  ------------------
  |  |   78|      2|#define ASN_OCTET_STR	    0x04U
  ------------------
  831|      2|                      NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_COMMUNITY);
  ------------------
  |  |   48|      2|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
                                    NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_COMMUNITY);
  ------------------
  |  |  158|      2|#define NETSNMP_DS_LIB_COMMUNITY         7
  ------------------
  832|      2|#endif /* !defined(NETSNMP_DISABLE_SNMPV1) || !defined(NETSNMP_DISABLE_SNMPV2C) */
  833|      2|    netsnmp_ds_register_premib(ASN_BOOLEAN, "snmp", "noTokenWarnings",
  ------------------
  |  |   72|      2|#define ASN_BOOLEAN	    0x01U
  ------------------
  834|      2|                      NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_NO_TOKEN_WARNINGS);
  ------------------
  |  |   48|      2|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
                                    NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_NO_TOKEN_WARNINGS);
  ------------------
  |  |   77|      2|#define NETSNMP_DS_LIB_NO_TOKEN_WARNINGS   17   /* no warn about unknown config tokens */
  ------------------
  835|      2|    netsnmp_ds_register_config(ASN_BOOLEAN, "snmp", "noRangeCheck",
  ------------------
  |  |   72|      2|#define ASN_BOOLEAN	    0x01U
  ------------------
  836|      2|		      NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_DONT_CHECK_RANGE);
  ------------------
  |  |   48|      2|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
              		      NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_DONT_CHECK_RANGE);
  ------------------
  |  |   76|      2|#define NETSNMP_DS_LIB_DONT_CHECK_RANGE    16   /* don't check values for ranges on send */
  ------------------
  837|      2|    netsnmp_ds_register_premib(ASN_OCTET_STR, "snmp", "persistentDir",
  ------------------
  |  |   78|      2|#define ASN_OCTET_STR	    0x04U
  ------------------
  838|      2|	              NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_PERSISTENT_DIR);
  ------------------
  |  |   48|      2|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
              	              NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_PERSISTENT_DIR);
  ------------------
  |  |  159|      2|#define NETSNMP_DS_LIB_PERSISTENT_DIR    8
  ------------------
  839|      2|    netsnmp_ds_register_config(ASN_OCTET_STR, "snmp", "tempFilePattern",
  ------------------
  |  |   78|      2|#define ASN_OCTET_STR	    0x04U
  ------------------
  840|      2|	              NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_TEMP_FILE_PATTERN);
  ------------------
  |  |   48|      2|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
              	              NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_TEMP_FILE_PATTERN);
  ------------------
  |  |  166|      2|#define NETSNMP_DS_LIB_TEMP_FILE_PATTERN 15
  ------------------
  841|      2|    netsnmp_ds_register_config(ASN_BOOLEAN, "snmp", "noDisplayHint",
  ------------------
  |  |   72|      2|#define ASN_BOOLEAN	    0x01U
  ------------------
  842|      2|	              NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_NO_DISPLAY_HINT);
  ------------------
  |  |   48|      2|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
              	              NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_NO_DISPLAY_HINT);
  ------------------
  |  |   90|      2|#define NETSNMP_DS_LIB_NO_DISPLAY_HINT     30 /* don't apply DISPLAY-HINTs */
  ------------------
  843|      2|    netsnmp_ds_register_config(ASN_BOOLEAN, "snmp", "16bitIDs",
  ------------------
  |  |   72|      2|#define ASN_BOOLEAN	    0x01U
  ------------------
  844|      2|	              NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_16BIT_IDS);
  ------------------
  |  |   48|      2|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
              	              NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_16BIT_IDS);
  ------------------
  |  |   91|      2|#define NETSNMP_DS_LIB_16BIT_IDS           31   /* restrict requestIDs, etc to 16-bit values */
  ------------------
  845|      2|    netsnmp_ds_register_premib(ASN_OCTET_STR, "snmp", "clientaddr",
  ------------------
  |  |   78|      2|#define ASN_OCTET_STR	    0x04U
  ------------------
  846|      2|                      NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_CLIENT_ADDR);
  ------------------
  |  |   48|      2|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
                                    NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_CLIENT_ADDR);
  ------------------
  |  |  165|      2|#define NETSNMP_DS_LIB_CLIENT_ADDR       14
  ------------------
  847|      2|    netsnmp_ds_register_premib(ASN_BOOLEAN, "snmp", "clientaddrUsesPort",
  ------------------
  |  |   72|      2|#define ASN_BOOLEAN	    0x01U
  ------------------
  848|      2|                      NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_CLIENT_ADDR_USES_PORT);
  ------------------
  |  |   48|      2|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
                                    NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_CLIENT_ADDR_USES_PORT);
  ------------------
  |  |  102|      2|#define NETSNMP_DS_LIB_CLIENT_ADDR_USES_PORT 42 /* NETSNMP_DS_LIB_CLIENT_ADDR includes address and also port */
  ------------------
  849|      2|    netsnmp_ds_register_config(ASN_INTEGER, "snmp", "serverSendBuf",
  ------------------
  |  |   75|      2|#define ASN_INTEGER	    0x02U
  ------------------
  850|      2|		      NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_SERVERSENDBUF);
  ------------------
  |  |   48|      2|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
              		      NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_SERVERSENDBUF);
  ------------------
  |  |  122|      2|#define NETSNMP_DS_LIB_SERVERSENDBUF        7 /* send buffer (server) */
  ------------------
  851|      2|    netsnmp_ds_register_config(ASN_INTEGER, "snmp", "serverRecvBuf",
  ------------------
  |  |   75|      2|#define ASN_INTEGER	    0x02U
  ------------------
  852|      2|		      NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_SERVERRECVBUF);
  ------------------
  |  |   48|      2|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
              		      NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_SERVERRECVBUF);
  ------------------
  |  |  123|      2|#define NETSNMP_DS_LIB_SERVERRECVBUF        8 /* receive buffer (server) */
  ------------------
  853|      2|    netsnmp_ds_register_config(ASN_INTEGER, "snmp", "clientSendBuf",
  ------------------
  |  |   75|      2|#define ASN_INTEGER	    0x02U
  ------------------
  854|      2|		      NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_CLIENTSENDBUF);
  ------------------
  |  |   48|      2|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
              		      NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_CLIENTSENDBUF);
  ------------------
  |  |  124|      2|#define NETSNMP_DS_LIB_CLIENTSENDBUF        9 /* send buffer (client) */
  ------------------
  855|      2|    netsnmp_ds_register_config(ASN_INTEGER, "snmp", "clientRecvBuf",
  ------------------
  |  |   75|      2|#define ASN_INTEGER	    0x02U
  ------------------
  856|      2|		      NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_CLIENTRECVBUF);
  ------------------
  |  |   48|      2|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
              		      NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_CLIENTRECVBUF);
  ------------------
  |  |  125|      2|#define NETSNMP_DS_LIB_CLIENTRECVBUF       10 /* receive buffer (client) */
  ------------------
  857|      2|    netsnmp_ds_register_config(ASN_INTEGER, "snmp", "sendMessageMaxSize",
  ------------------
  |  |   75|      2|#define ASN_INTEGER	    0x02U
  ------------------
  858|      2|                               NETSNMP_DS_LIBRARY_ID,
  ------------------
  |  |   48|      2|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  859|      2|                               NETSNMP_DS_LIB_MSG_SEND_MAX);
  ------------------
  |  |  132|      2|#define NETSNMP_DS_LIB_MSG_SEND_MAX        16 /* global max response size */
  ------------------
  860|      2|    netsnmp_ds_register_config(ASN_BOOLEAN, "snmp", "noPersistentLoad",
  ------------------
  |  |   72|      2|#define ASN_BOOLEAN	    0x01U
  ------------------
  861|      2|		      NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_DISABLE_PERSISTENT_LOAD);
  ------------------
  |  |   48|      2|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
              		      NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_DISABLE_PERSISTENT_LOAD);
  ------------------
  |  |   95|      2|#define NETSNMP_DS_LIB_DISABLE_PERSISTENT_LOAD  35 /* don't load persistent file */
  ------------------
  862|      2|    netsnmp_ds_register_config(ASN_BOOLEAN, "snmp", "noPersistentSave",
  ------------------
  |  |   72|      2|#define ASN_BOOLEAN	    0x01U
  ------------------
  863|      2|		      NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_DISABLE_PERSISTENT_SAVE);
  ------------------
  |  |   48|      2|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
              		      NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_DISABLE_PERSISTENT_SAVE);
  ------------------
  |  |   96|      2|#define NETSNMP_DS_LIB_DISABLE_PERSISTENT_SAVE  36 /* don't save persistent file */
  ------------------
  864|      2|    netsnmp_ds_register_config(ASN_BOOLEAN, "snmp",
  ------------------
  |  |   72|      2|#define ASN_BOOLEAN	    0x01U
  ------------------
  865|      2|                               "noContextEngineIDDiscovery",
  866|      2|                               NETSNMP_DS_LIBRARY_ID,
  ------------------
  |  |   48|      2|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  867|      2|                               NETSNMP_DS_LIB_NO_DISCOVERY);
  ------------------
  |  |   98|      2|#define NETSNMP_DS_LIB_NO_DISCOVERY        38 /* don't support RFC5343 contextEngineID discovery */
  ------------------
  868|      2|    netsnmp_ds_register_config(ASN_INTEGER, "snmp", "timeout",
  ------------------
  |  |   75|      2|#define ASN_INTEGER	    0x02U
  ------------------
  869|      2|		               NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_TIMEOUT);
  ------------------
  |  |   48|      2|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
              		               NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_TIMEOUT);
  ------------------
  |  |  130|      2|#define NETSNMP_DS_LIB_TIMEOUT             14
  ------------------
  870|      2|    netsnmp_ds_register_config(ASN_INTEGER, "snmp", "retries",
  ------------------
  |  |   75|      2|#define ASN_INTEGER	    0x02U
  ------------------
  871|      2|		               NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_RETRIES);
  ------------------
  |  |   48|      2|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
              		               NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_RETRIES);
  ------------------
  |  |  131|      2|#define NETSNMP_DS_LIB_RETRIES             15
  ------------------
  872|      2|    netsnmp_ds_register_config(ASN_OCTET_STR, "snmp", "outputPrecision",
  ------------------
  |  |   78|      2|#define ASN_OCTET_STR	    0x04U
  ------------------
  873|      2|                               NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_OUTPUT_PRECISION);
  ------------------
  |  |   48|      2|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
                                             NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_OUTPUT_PRECISION);
  ------------------
  |  |  186|      2|#define NETSNMP_DS_LIB_OUTPUT_PRECISION  35
  ------------------
  874|       |
  875|       |
  876|      2|    netsnmp_register_service_handlers();
  877|      2|}
snmp_api.c:netsnmp_free_transport_config:
 2054|  3.01k|{
 2055|  3.01k|    if (!tc)
  ------------------
  |  Branch (2055:9): [True: 3.01k, False: 0]
  ------------------
 2056|  3.01k|        return;
 2057|       |
 2058|      0|    CONTAINER_CLEAR(tc, netsnmp_free_one_tr_cfg, NULL);
 2059|      0|    CONTAINER_FREE(tc);
 2060|      0|}
snmp_api.c:free_securityStateRef:
 4241|  8.98k|{
 4242|  8.98k|    struct snmp_secmod_def *sptr;
 4243|       |
 4244|  8.98k|    if (!pdu->securityStateRef)
  ------------------
  |  Branch (4244:9): [True: 8.20k, False: 779]
  ------------------
 4245|  8.20k|        return;
 4246|       |
 4247|    779|    sptr = find_sec_mod(pdu->securityModel);
 4248|    779|    if (sptr) {
  ------------------
  |  Branch (4248:9): [True: 779, False: 0]
  ------------------
 4249|    779|        if (sptr->pdu_free_state_ref) {
  ------------------
  |  Branch (4249:13): [True: 779, False: 0]
  ------------------
 4250|    779|            (*sptr->pdu_free_state_ref) (pdu->securityStateRef);
 4251|    779|        } else {
 4252|      0|            snmp_log(LOG_ERR,
 4253|      0|                     "Security Model %d can't free state references\n",
 4254|      0|                     pdu->securityModel);
 4255|      0|	}
 4256|    779|    } else {
 4257|      0|	snmp_log(LOG_ERR,
 4258|      0|		 "Can't find security model to free ptr: %d\n",
 4259|      0|		 pdu->securityModel);
 4260|      0|    }
 4261|       |    pdu->securityStateRef = NULL;
 4262|    779|}
snmp_api.c:_snmp_parse:
 4470|  3.01k|{
 4471|  3.01k|#if !defined(NETSNMP_DISABLE_SNMPV1) || !defined(NETSNMP_DISABLE_SNMPV2C)
 4472|  3.01k|    u_char          community[COMMUNITY_MAX_LEN];
 4473|  3.01k|    size_t          community_length = COMMUNITY_MAX_LEN;
  ------------------
  |  |   41|  3.01k|#define COMMUNITY_MAX_LEN	256
  ------------------
 4474|  3.01k|#endif
 4475|  3.01k|    int             result = -1;
 4476|       |
 4477|  3.01k|    static const oid snmpEngineIDoid[]   = { 1,3,6,1,6,3,10,2,1,1,0};
 4478|  3.01k|    static size_t   snmpEngineIDoid_len = 11;
 4479|       |
 4480|  3.01k|    static char     ourEngineID[SNMP_SEC_PARAM_BUF_SIZE];
 4481|  3.01k|    static size_t   ourEngineID_len = sizeof(ourEngineID);
 4482|       |
 4483|  3.01k|    netsnmp_pdu    *pdu2 = NULL;
 4484|       |
 4485|  3.01k|    session->s_snmp_errno = 0;
 4486|  3.01k|    session->s_errno = 0;
 4487|       |
 4488|       |    /*
 4489|       |     * Ensure all incoming PDUs have a unique means of identification 
 4490|       |     * (This is not restricted to AgentX handling,
 4491|       |     * though that is where the need becomes visible)   
 4492|       |     */
 4493|  3.01k|    pdu->transid = snmp_get_next_transid();
 4494|       |
 4495|  3.01k|    if (session->version != SNMP_DEFAULT_VERSION) {
  ------------------
  |  |   90|  3.01k|#define SNMP_DEFAULT_VERSION	    -1
  ------------------
  |  Branch (4495:9): [True: 3.01k, False: 0]
  ------------------
 4496|  3.01k|        pdu->version = session->version;
 4497|  3.01k|    } else {
 4498|      0|        pdu->version = snmp_parse_version(data, length);
 4499|      0|    }
 4500|       |
 4501|  3.01k|    switch (pdu->version) {
 4502|      0|#if !defined(NETSNMP_DISABLE_SNMPV1) || !defined(NETSNMP_DISABLE_SNMPV2C)
 4503|      0|#ifndef NETSNMP_DISABLE_SNMPV1
 4504|      0|    case SNMP_VERSION_1:
  ------------------
  |  |  107|      0|#define SNMP_VERSION_1	   0
  ------------------
  |  Branch (4504:5): [True: 0, False: 3.01k]
  ------------------
 4505|      0|#endif
 4506|      0|#ifndef NETSNMP_DISABLE_SNMPV2C
 4507|      0|    case SNMP_VERSION_2c:
  ------------------
  |  |  110|      0|#define SNMP_VERSION_2c    1
  ------------------
  |  Branch (4507:5): [True: 0, False: 3.01k]
  ------------------
 4508|      0|#endif
 4509|      0|        NETSNMP_RUNTIME_PROTOCOL_CHECK_V1V2(pdu->version,unsupported_version);
  ------------------
  |  |  220|      0|#define NETSNMP_RUNTIME_PROTOCOL_CHECK_V1V2(pc_ver, pc_target) do {    \
  |  |  221|      0|        if (NETSNMP_RUNTIME_PROTOCOL_SKIP_V1(pc_ver) ||                \
  |  |  ------------------
  |  |  |  |  205|      0|    ((pc_ver) == SNMP_VERSION_1 &&                                      \
  |  |  |  |  ------------------
  |  |  |  |  |  |  107|      0|#define SNMP_VERSION_1	   0
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (205:6): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  206|      0|     netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID,                      \
  |  |  |  |  ------------------
  |  |  |  |  |  |   48|      0|#define NETSNMP_DS_LIBRARY_ID     0
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (206:6): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  207|      0|                            NETSNMP_DS_LIB_DISABLE_V1))
  |  |  |  |  ------------------
  |  |  |  |  |  |  103|      0|#define NETSNMP_DS_LIB_DISABLE_V1          43 /* disable SNMPv1 */
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  222|      0|            NETSNMP_RUNTIME_PROTOCOL_SKIP_V2(pc_ver)) {                \
  |  |  ------------------
  |  |  |  |  215|      0|    ((pc_ver) == SNMP_VERSION_2c &&                                     \
  |  |  |  |  ------------------
  |  |  |  |  |  |  110|      0|#define SNMP_VERSION_2c    1
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (215:6): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  216|      0|     netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID,                      \
  |  |  |  |  ------------------
  |  |  |  |  |  |   48|      0|#define NETSNMP_DS_LIBRARY_ID     0
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (216:6): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  217|      0|                            NETSNMP_DS_LIB_DISABLE_V2c))
  |  |  |  |  ------------------
  |  |  |  |  |  |  104|      0|#define NETSNMP_DS_LIB_DISABLE_V2c         44 /* disable SNMPv2c */
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  223|      0|            DEBUGMSGTL(("snmp:protocol:disabled", "enforced\n"));      \
  |  |  ------------------
  |  |  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  224|      0|            goto pc_target;                                            \
  |  |  225|      0|        }                                                              \
  |  |  226|      0|    } while(0)
  |  |  ------------------
  |  |  |  Branch (226:13): [Folded, False: 0]
  |  |  ------------------
  ------------------
 4510|      0|        DEBUGMSGTL(("snmp_api", "Parsing SNMPv%ld message...\n",
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
 4511|      0|                    (1 + pdu->version)));
 4512|       |
 4513|       |        /*
 4514|       |         * authenticates message and returns length if valid 
 4515|       |         */
 4516|      0|#ifndef NETSNMP_DISABLE_SNMPV1
 4517|      0|        if (pdu->version == SNMP_VERSION_1) {
  ------------------
  |  |  107|      0|#define SNMP_VERSION_1	   0
  ------------------
  |  Branch (4517:13): [True: 0, False: 0]
  ------------------
 4518|      0|            DEBUGDUMPSECTION("recv", "SNMPv1 message\n");
  ------------------
  |  |   81|      0|	do {if (_DBG_IF_) {__DBGDUMPSECTION(token,x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               	do {if (_DBG_IF_) {__DBGDUMPSECTION(token,x);} }while(0)
  |  |  ------------------
  |  |  |  |  191|      0|        __DBGPRINTINDENT("dumph_" token); \
  |  |  |  |  ------------------
  |  |  |  |  |  |  175|      0|#define __DBGPRINTINDENT(token) __DBGMSGTL((token, "%*s", __DBGINDENT(), ""))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  192|      0|        debugmsg("dumph_" token,"%s\n",x);\
  |  |  |  |  193|      0|        __DBGINDENTMORE()
  |  |  |  |  ------------------
  |  |  |  |  |  |  173|      0|#define __DBGINDENTMORE()  debug_indent_add(2)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (81:56): [Folded, False: 0]
  |  |  ------------------
  ------------------
 4519|      0|        } else {
 4520|      0|#endif
 4521|      0|            DEBUGDUMPSECTION("recv", "SNMPv2c message\n");
  ------------------
  |  |   81|      0|	do {if (_DBG_IF_) {__DBGDUMPSECTION(token,x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               	do {if (_DBG_IF_) {__DBGDUMPSECTION(token,x);} }while(0)
  |  |  ------------------
  |  |  |  |  191|      0|        __DBGPRINTINDENT("dumph_" token); \
  |  |  |  |  ------------------
  |  |  |  |  |  |  175|      0|#define __DBGPRINTINDENT(token) __DBGMSGTL((token, "%*s", __DBGINDENT(), ""))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  192|      0|        debugmsg("dumph_" token,"%s\n",x);\
  |  |  |  |  193|      0|        __DBGINDENTMORE()
  |  |  |  |  ------------------
  |  |  |  |  |  |  173|      0|#define __DBGINDENTMORE()  debug_indent_add(2)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (81:56): [Folded, False: 0]
  |  |  ------------------
  ------------------
 4522|      0|#ifndef NETSNMP_DISABLE_SNMPV1
 4523|      0|        }
 4524|      0|#endif
 4525|      0|        data = snmp_comstr_parse(data, &length,
 4526|      0|                                 community, &community_length,
 4527|      0|                                 &pdu->version);
 4528|      0|        if (data == NULL)
  ------------------
  |  Branch (4528:13): [True: 0, False: 0]
  ------------------
 4529|      0|            return -1;
 4530|       |
 4531|      0|        if (pdu->version != session->version &&
  ------------------
  |  Branch (4531:13): [True: 0, False: 0]
  ------------------
 4532|      0|            session->version != SNMP_DEFAULT_VERSION) {
  ------------------
  |  |   90|      0|#define SNMP_DEFAULT_VERSION	    -1
  ------------------
  |  Branch (4532:13): [True: 0, False: 0]
  ------------------
 4533|      0|            session->s_snmp_errno = SNMPERR_BAD_VERSION;
  ------------------
  |  |  198|      0|#define SNMPERR_BAD_VERSION		(-14)
  ------------------
 4534|      0|            return -1;
 4535|      0|        }
 4536|       |
 4537|       |        /*
 4538|       |         * maybe get the community string. 
 4539|       |         */
 4540|      0|        pdu->securityLevel = SNMP_SEC_LEVEL_NOAUTH;
  ------------------
  |  |  299|      0|#define SNMP_SEC_LEVEL_NOAUTH		1
  ------------------
 4541|      0|        pdu->securityModel = 
 4542|      0|#ifndef NETSNMP_DISABLE_SNMPV1
 4543|      0|            (pdu->version == SNMP_VERSION_1) ? SNMP_SEC_MODEL_SNMPv1 : 
  ------------------
  |  |  107|      0|#define SNMP_VERSION_1	   0
  ------------------
                          (pdu->version == SNMP_VERSION_1) ? SNMP_SEC_MODEL_SNMPv1 : 
  ------------------
  |  |  293|      0|#define SNMP_SEC_MODEL_SNMPv1		1
  ------------------
  |  Branch (4543:13): [True: 0, False: 0]
  ------------------
 4544|      0|#endif
 4545|      0|                                               SNMP_SEC_MODEL_SNMPv2c;
  ------------------
  |  |  294|      0|#define SNMP_SEC_MODEL_SNMPv2c		2
  ------------------
 4546|      0|        SNMP_FREE(pdu->community);
  ------------------
  |  |   62|      0|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 0, False: 0]
  |  |  |  Branch (62:66): [Folded, False: 0]
  |  |  ------------------
  ------------------
 4547|      0|        pdu->community_len = 0;
 4548|      0|        pdu->community = (u_char *) 0;
 4549|      0|        if (community_length) {
  ------------------
  |  Branch (4549:13): [True: 0, False: 0]
  ------------------
 4550|      0|            pdu->community_len = community_length;
 4551|      0|            pdu->community = netsnmp_memdup(community, community_length);
 4552|      0|            if (pdu->community == NULL) {
  ------------------
  |  Branch (4552:17): [True: 0, False: 0]
  ------------------
 4553|      0|                session->s_snmp_errno = SNMPERR_MALLOC;
  ------------------
  |  |  246|      0|#define SNMPERR_MALLOC			(-62)
  ------------------
 4554|      0|                return -1;
 4555|      0|            }
 4556|      0|        }
 4557|      0|        if (session->authenticator) {
  ------------------
  |  Branch (4557:13): [True: 0, False: 0]
  ------------------
 4558|      0|            data = session->authenticator(data, &length,
 4559|      0|                                          community, community_length);
 4560|      0|            if (data == NULL) {
  ------------------
  |  Branch (4560:17): [True: 0, False: 0]
  ------------------
 4561|      0|                session->s_snmp_errno = SNMPERR_AUTHENTICATION_FAILURE;
  ------------------
  |  |  219|      0|#define SNMPERR_AUTHENTICATION_FAILURE 	(-35)
  ------------------
 4562|      0|                return -1;
 4563|      0|            }
 4564|      0|        }
 4565|       |
 4566|      0|        DEBUGDUMPSECTION("recv", "PDU");
  ------------------
  |  |   81|      0|	do {if (_DBG_IF_) {__DBGDUMPSECTION(token,x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               	do {if (_DBG_IF_) {__DBGDUMPSECTION(token,x);} }while(0)
  |  |  ------------------
  |  |  |  |  191|      0|        __DBGPRINTINDENT("dumph_" token); \
  |  |  |  |  ------------------
  |  |  |  |  |  |  175|      0|#define __DBGPRINTINDENT(token) __DBGMSGTL((token, "%*s", __DBGINDENT(), ""))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  192|      0|        debugmsg("dumph_" token,"%s\n",x);\
  |  |  |  |  193|      0|        __DBGINDENTMORE()
  |  |  |  |  ------------------
  |  |  |  |  |  |  173|      0|#define __DBGINDENTMORE()  debug_indent_add(2)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (81:56): [Folded, False: 0]
  |  |  ------------------
  ------------------
 4567|      0|        result = snmp_pdu_parse(pdu, data, &length);
 4568|      0|        if (result < 0) {
  ------------------
  |  Branch (4568:13): [True: 0, False: 0]
  ------------------
 4569|       |            /*
 4570|       |             * This indicates a parse error.  
 4571|       |             */
 4572|      0|            snmp_increment_statistic(STAT_SNMPINASNPARSEERRS);
  ------------------
  |  |  637|      0|#define  STAT_SNMPINASNPARSEERRS             14
  ------------------
 4573|      0|        }
 4574|      0|        DEBUGINDENTADD(-6);
  ------------------
  |  |   73|      0|#define DEBUGINDENTADD(x)  do {if (_DBG_IF_) {__DBGINDENTADD(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGINDENTADD(x)  do {if (_DBG_IF_) {__DBGINDENTADD(x);} }while(0)
  |  |  ------------------
  |  |  |  |  172|      0|#define __DBGINDENTADD(x)  debug_indent_add(x)
  |  |  ------------------
  |  |  |  Branch (73:74): [Folded, False: 0]
  |  |  ------------------
  ------------------
 4575|      0|        break;
 4576|      0|#endif /* support for community based SNMP */
 4577|       |
 4578|  3.01k|    case SNMP_VERSION_3:
  ------------------
  |  |  113|  3.01k|#define SNMP_VERSION_3     3
  ------------------
  |  Branch (4578:5): [True: 3.01k, False: 0]
  ------------------
 4579|  3.01k|        NETSNMP_RUNTIME_PROTOCOL_CHECK_V3(SNMP_VERSION_3,unsupported_version);
  ------------------
  |  |  233|  3.01k|#define NETSNMP_RUNTIME_PROTOCOL_CHECK_V3(pc_ver, pc_target) do {      \
  |  |  234|  3.01k|        if (NETSNMP_RUNTIME_PROTOCOL_SKIP_V3(pc_ver)) {                \
  |  |  ------------------
  |  |  |  |  229|  3.01k|    ((pc_ver == SNMP_VERSION_3) &&                                   \
  |  |  |  |  ------------------
  |  |  |  |  |  |  113|  3.01k|#define SNMP_VERSION_3     3
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (229:6): [True: 3.01k, Folded]
  |  |  |  |  ------------------
  |  |  |  |  230|  3.01k|     netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID,                     \
  |  |  |  |  ------------------
  |  |  |  |  |  |   48|  3.01k|#define NETSNMP_DS_LIBRARY_ID     0
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (230:6): [True: 0, False: 3.01k]
  |  |  |  |  ------------------
  |  |  |  |  231|  3.01k|                            NETSNMP_DS_LIB_DISABLE_V3))
  |  |  |  |  ------------------
  |  |  |  |  |  |  105|  3.01k|#define NETSNMP_DS_LIB_DISABLE_V3          45 /* disable SNMPv3 */
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  235|      0|            DEBUGMSGTL(("snmp:protocol:disabled", "enforced\n"));      \
  |  |  ------------------
  |  |  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  236|      0|            goto pc_target;                                            \
  |  |  237|      0|        }                                                              \
  |  |  238|  3.01k|    } while(0)
  |  |  ------------------
  |  |  |  Branch (238:13): [Folded, False: 3.01k]
  |  |  ------------------
  ------------------
 4580|  3.01k|        result = snmpv3_parse(pdu, data, &length, NULL, session);
 4581|  3.01k|        DEBUGMSGTL(("snmp_parse",
  ------------------
  |  |   66|  3.01k|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|  3.01k|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 3.01k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (164:52): [True: 0, False: 0]
  |  |  |  |  |  Branch (164:52): [True: 0, False: 0]
  |  |  |  |  |  Branch (164:64): [True: 0, False: 0]
  |  |  |  |  |  Branch (164:64): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 3.01k]
  |  |  ------------------
  ------------------
 4582|  3.01k|                    "Parsed SNMPv3 message (secName:%s, secLevel:%s): %s\n",
 4583|  3.01k|                    pdu->securityName,
 4584|  3.01k|                    (pdu->securityLevel >= 0 && pdu->securityLevel < 4) ?
 4585|  3.01k|                    secLevelName[pdu->securityLevel] : "ERROR: invalid",
 4586|  3.01k|                    snmp_api_errstring(result)));
 4587|       |
 4588|  3.01k|        if (result == SNMPERR_USM_UNKNOWNSECURITYNAME) {
  ------------------
  |  |  227|  3.01k|#define SNMPERR_USM_UNKNOWNSECURITYNAME		(-43)
  ------------------
  |  Branch (4588:13): [True: 283, False: 2.73k]
  ------------------
 4589|    283|            snmp_call_callbacks(SNMP_CALLBACK_APPLICATION,
  ------------------
  |  |   19|    283|#define SNMP_CALLBACK_APPLICATION 1
  ------------------
 4590|    283|                                SNMPD_CALLBACK_AUTH_FAILURE, pdu);
  ------------------
  |  |   21|    283|#define SNMPD_CALLBACK_AUTH_FAILURE             17
  ------------------
 4591|    283|        }
 4592|       |        
 4593|  3.01k|        if (result) {
  ------------------
  |  Branch (4593:13): [True: 2.89k, False: 124]
  ------------------
 4594|  2.89k|            struct snmp_secmod_def *secmod =
 4595|  2.89k|                find_sec_mod(pdu->securityModel);
 4596|  2.89k|            if (!slp) {
  ------------------
  |  Branch (4596:17): [True: 2.89k, False: 0]
  ------------------
 4597|  2.89k|                session->s_snmp_errno = result;
 4598|  2.89k|            } else {
 4599|       |                /*
 4600|       |                 * Call the security model to special handle any errors
 4601|       |                 */
 4602|       |
 4603|      0|                if (secmod && secmod->handle_report) {
  ------------------
  |  Branch (4603:21): [True: 0, False: 0]
  |  Branch (4603:31): [True: 0, False: 0]
  ------------------
 4604|      0|                    (*secmod->handle_report)(slp, slp->transport, session,
 4605|      0|                                             result, pdu);
 4606|      0|                }
 4607|      0|            }
 4608|  2.89k|            free_securityStateRef(pdu);
 4609|  2.89k|        }
 4610|       |
 4611|       |        /* Implement RFC5343 here for two reasons:
 4612|       |           1) From a security perspective it handles this otherwise
 4613|       |              always approved request earlier.  It bypasses the need
 4614|       |              for authorization to the snmpEngineID scalar, which is
 4615|       |              what is what RFC3415 appendix A species as ok.  Note
 4616|       |              that we haven't bypassed authentication since if there
 4617|       |              was an authentication error it would have been handled
 4618|       |              above in the if(result) part at the latest.
 4619|       |           2) From an application point of view if we let this request
 4620|       |              get all the way to the application, it'd require that
 4621|       |              all application types supporting discovery also fire up
 4622|       |              a minimal agent in order to handle just this request
 4623|       |              which seems like overkill.  Though there is no other
 4624|       |              application types that currently need discovery (NRs
 4625|       |              accept notifications from contextEngineIDs that derive
 4626|       |              from the NO not the NR).  Also a lame excuse for doing
 4627|       |              it here.
 4628|       |           3) Less important technically, but the net-snmp agent
 4629|       |              doesn't currently handle registrations of different
 4630|       |              engineIDs either and it would have been a lot more work
 4631|       |              to implement there since we'd need to support that
 4632|       |              first. :-/ Supporting multiple context engineIDs should
 4633|       |              be done anyway, so it's not a valid excuse here.
 4634|       |           4) There is a lot less to do if we trump the agent at this
 4635|       |              point; IE, the agent does a lot more unnecessary
 4636|       |              processing when the only thing that should ever be in
 4637|       |              this context by definition is the single scalar.
 4638|       |        */
 4639|       |
 4640|       |        /* special RFC5343 engineID discovery engineID check */
 4641|  3.01k|        if (!netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID,
  ------------------
  |  |   48|  3.01k|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  |  Branch (4641:13): [True: 3.01k, False: 0]
  ------------------
 4642|  3.01k|                                    NETSNMP_DS_LIB_NO_DISCOVERY) &&
  ------------------
  |  |   98|  3.01k|#define NETSNMP_DS_LIB_NO_DISCOVERY        38 /* don't support RFC5343 contextEngineID discovery */
  ------------------
 4643|  3.01k|            SNMP_MSG_RESPONSE       != pdu->command &&
  ------------------
  |  |  127|  3.01k|#define SNMP_MSG_RESPONSE   (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x2) /* a2=162 */
  |  |  ------------------
  |  |  |  |   92|  3.01k|#define ASN_CONTEXT	    0x80U
  |  |  ------------------
  |  |               #define SNMP_MSG_RESPONSE   (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x2) /* a2=162 */
  |  |  ------------------
  |  |  |  |   96|  3.01k|#define ASN_CONSTRUCTOR	    0x20U
  |  |  ------------------
  ------------------
  |  Branch (4643:13): [True: 2.97k, False: 41]
  ------------------
 4644|  3.01k|            NULL                    != pdu->contextEngineID &&
  ------------------
  |  Branch (4644:13): [True: 1.88k, False: 1.08k]
  ------------------
 4645|  1.88k|            pdu->contextEngineIDLen == 5 &&
  ------------------
  |  Branch (4645:13): [True: 173, False: 1.71k]
  ------------------
 4646|    173|            pdu->contextEngineID[0] == 0x80 &&
  ------------------
  |  Branch (4646:13): [True: 159, False: 14]
  ------------------
 4647|    159|            pdu->contextEngineID[1] == 0x00 &&
  ------------------
  |  Branch (4647:13): [True: 150, False: 9]
  ------------------
 4648|    150|            pdu->contextEngineID[2] == 0x00 &&
  ------------------
  |  Branch (4648:13): [True: 140, False: 10]
  ------------------
 4649|    140|            pdu->contextEngineID[3] == 0x00 &&
  ------------------
  |  Branch (4649:13): [True: 132, False: 8]
  ------------------
 4650|    132|            pdu->contextEngineID[4] == 0x06) {
  ------------------
  |  Branch (4650:13): [True: 122, False: 10]
  ------------------
 4651|       |
 4652|       |            /* define a result so it doesn't get past us at this point
 4653|       |               and gets dropped by future parts of the stack */
 4654|    122|            result = SNMPERR_JUST_A_CONTEXT_PROBE;
  ------------------
  |  |  250|    122|#define SNMPERR_JUST_A_CONTEXT_PROBE    (-66)
  ------------------
 4655|       |
 4656|    122|            DEBUGMSGTL(("snmpv3_contextid", "starting context ID discovery\n"));
  ------------------
  |  |   66|    122|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|    122|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 122]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 122]
  |  |  ------------------
  ------------------
 4657|       |            /* ensure exactly one variable */
 4658|    122|            if (NULL != pdu->variables &&
  ------------------
  |  Branch (4658:17): [True: 109, False: 13]
  ------------------
 4659|    122|                NULL == pdu->variables->next_variable &&
  ------------------
  |  Branch (4659:17): [True: 107, False: 2]
  ------------------
 4660|       |
 4661|       |                /* if it's a GET, match it exactly */
 4662|    107|                ((SNMP_MSG_GET == pdu->command &&
  ------------------
  |  |  125|    107|#define SNMP_MSG_GET        (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x0) /* a0=160 */
  |  |  ------------------
  |  |  |  |   92|    107|#define ASN_CONTEXT	    0x80U
  |  |  ------------------
  |  |               #define SNMP_MSG_GET        (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x0) /* a0=160 */
  |  |  ------------------
  |  |  |  |   96|    107|#define ASN_CONSTRUCTOR	    0x20U
  |  |  ------------------
  ------------------
  |  Branch (4662:19): [True: 47, False: 60]
  ------------------
 4663|     47|                  snmp_oid_compare(snmpEngineIDoid,
  ------------------
  |  Branch (4663:19): [True: 1, False: 46]
  ------------------
 4664|     47|                                   snmpEngineIDoid_len,
 4665|     47|                                   pdu->variables->name,
 4666|     47|                                   pdu->variables->name_length) == 0)
 4667|       |                 /* if it's a GETNEXT ensure it's less than the engineID oid */
 4668|    106|                 ||
 4669|    106|                 (SNMP_MSG_GETNEXT == pdu->command &&
  ------------------
  |  |  126|    106|#define SNMP_MSG_GETNEXT    (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x1) /* a1=161 */
  |  |  ------------------
  |  |  |  |   92|    106|#define ASN_CONTEXT	    0x80U
  |  |  ------------------
  |  |               #define SNMP_MSG_GETNEXT    (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x1) /* a1=161 */
  |  |  ------------------
  |  |  |  |   96|    106|#define ASN_CONSTRUCTOR	    0x20U
  |  |  ------------------
  ------------------
  |  Branch (4669:19): [True: 57, False: 49]
  ------------------
 4670|     57|                  snmp_oid_compare(snmpEngineIDoid,
  ------------------
  |  Branch (4670:19): [True: 23, False: 34]
  ------------------
 4671|     57|                                   snmpEngineIDoid_len,
 4672|     57|                                   pdu->variables->name,
 4673|     57|                                   pdu->variables->name_length) > 0)
 4674|    107|                    )) {
 4675|       |
 4676|     24|                DEBUGMSGTL(("snmpv3_contextid",
  ------------------
  |  |   66|     24|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     24|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 24]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 24]
  |  |  ------------------
  ------------------
 4677|     24|                            "  One correct variable found\n"));
 4678|       |
 4679|       |                /* Note: we're explicitly not handling a GETBULK.  Deal. */
 4680|       |
 4681|       |                /* set up the response */
 4682|     24|                pdu2 = snmp_clone_pdu(pdu);
 4683|     24|                if (NULL == pdu2) {
  ------------------
  |  Branch (4683:21): [True: 0, False: 24]
  ------------------
 4684|      0|                    snmp_log(LOG_ERR, "failed to clone PDU for rfc5343 probe\n");
 4685|      0|                    if (pdu->securityStateRef)
  ------------------
  |  Branch (4685:25): [True: 0, False: 0]
  ------------------
 4686|      0|                        free_securityStateRef(pdu);
 4687|      0|                    return result;
 4688|      0|                }
 4689|       |
 4690|       |                /* free the current varbind */
 4691|     24|                snmp_free_varbind(pdu2->variables);
 4692|       |
 4693|       |                /* set the variables */
 4694|     24|                pdu2->variables = NULL;
 4695|     24|                pdu2->command = SNMP_MSG_RESPONSE;
  ------------------
  |  |  127|     24|#define SNMP_MSG_RESPONSE   (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x2) /* a2=162 */
  |  |  ------------------
  |  |  |  |   92|     24|#define ASN_CONTEXT	    0x80U
  |  |  ------------------
  |  |               #define SNMP_MSG_RESPONSE   (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x2) /* a2=162 */
  |  |  ------------------
  |  |  |  |   96|     24|#define ASN_CONSTRUCTOR	    0x20U
  |  |  ------------------
  ------------------
 4696|     24|                pdu2->errstat = 0;
 4697|     24|                pdu2->errindex = 0;
 4698|       |
 4699|     24|                ourEngineID_len =
 4700|     24|                    snmpv3_get_engineID((u_char*)ourEngineID, ourEngineID_len);
 4701|     24|                if (0 != ourEngineID_len) {
  ------------------
  |  Branch (4701:21): [True: 24, False: 0]
  ------------------
 4702|       |
 4703|     24|                    DEBUGMSGTL(("snmpv3_contextid",
  ------------------
  |  |   66|     24|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     24|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 24]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 24]
  |  |  ------------------
  ------------------
 4704|     24|                                "  responding with our engineID\n"));
 4705|       |
 4706|     24|                    snmp_pdu_add_variable(pdu2,
 4707|     24|                                          snmpEngineIDoid, snmpEngineIDoid_len,
 4708|     24|                                          ASN_OCTET_STR,
  ------------------
  |  |   78|     24|#define ASN_OCTET_STR	    0x04U
  ------------------
 4709|     24|                                          ourEngineID, ourEngineID_len);
 4710|       |                    
 4711|       |                    /* send the response */
 4712|     24|                    if (0 == snmp_sess_send(slp, pdu2)) {
  ------------------
  |  Branch (4712:25): [True: 24, False: 0]
  ------------------
 4713|       |
 4714|     24|                        DEBUGMSGTL(("snmpv3_contextid",
  ------------------
  |  |   66|     24|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     24|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 24]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 24]
  |  |  ------------------
  ------------------
 4715|     24|                                    "  sent it off!\n"));
 4716|       |
 4717|     24|                        snmp_free_pdu(pdu2);
 4718|       |                        
 4719|     24|                        snmp_log(LOG_ERR, "sending a response to the context engineID probe failed\n");
 4720|     24|                    }
 4721|     24|                } else {
 4722|      0|                    snmp_log(LOG_ERR, "failed to get our own engineID!\n");
 4723|      0|                    snmp_free_pdu(pdu2);
 4724|      0|                }
 4725|     98|            } else {
 4726|     98|                snmp_log(LOG_WARNING,
 4727|     98|                         "received an odd context engineID probe\n");
 4728|     98|            }
 4729|    122|            if (pdu->securityStateRef)
  ------------------
  |  Branch (4729:17): [True: 35, False: 87]
  ------------------
 4730|     35|                free_securityStateRef(pdu);
 4731|    122|        }
 4732|       |
 4733|  3.01k|        break;
 4734|  3.01k|    case SNMPERR_BAD_VERSION:
  ------------------
  |  |  198|      0|#define SNMPERR_BAD_VERSION		(-14)
  ------------------
  |  Branch (4734:5): [True: 0, False: 3.01k]
  ------------------
 4735|      0|        ERROR_MSG("error parsing snmp message version");
  ------------------
  |  |  188|      0|#define ERROR_MSG(string)	snmp_set_detail(string)
  ------------------
 4736|      0|        snmp_increment_statistic(STAT_SNMPINASNPARSEERRS);
  ------------------
  |  |  637|      0|#define  STAT_SNMPINASNPARSEERRS             14
  ------------------
 4737|      0|        session->s_snmp_errno = SNMPERR_BAD_VERSION;
  ------------------
  |  |  198|      0|#define SNMPERR_BAD_VERSION		(-14)
  ------------------
 4738|      0|        break;
 4739|       |
 4740|      0|        unsupported_version:  /* goto label */
 4741|      0|    case SNMP_VERSION_sec:
  ------------------
  |  |  118|      0|#define SNMP_VERSION_sec   128  /* not (will never be) supported by this code */
  ------------------
  |  Branch (4741:5): [True: 0, False: 3.01k]
  ------------------
 4742|      0|    case SNMP_VERSION_2u:
  ------------------
  |  |  112|      0|#define SNMP_VERSION_2u    2    /* not (will never be) supported by this code */
  ------------------
  |  Branch (4742:5): [True: 0, False: 3.01k]
  ------------------
 4743|      0|    case SNMP_VERSION_2star:
  ------------------
  |  |  120|      0|#define SNMP_VERSION_2star 130  /* not (will never be) supported by this code */
  ------------------
  |  Branch (4743:5): [True: 0, False: 3.01k]
  ------------------
 4744|      0|    case SNMP_VERSION_2p:
  ------------------
  |  |  119|      0|#define SNMP_VERSION_2p	   129  /* no longer supported by this code (> 4.0) */
  ------------------
  |  Branch (4744:5): [True: 0, False: 3.01k]
  ------------------
 4745|      0|    default:
  ------------------
  |  Branch (4745:5): [True: 0, False: 3.01k]
  ------------------
 4746|      0|        ERROR_MSG("unsupported snmp message version");
  ------------------
  |  |  188|      0|#define ERROR_MSG(string)	snmp_set_detail(string)
  ------------------
 4747|      0|        snmp_increment_statistic(STAT_SNMPINBADVERSIONS);
  ------------------
  |  |  634|      0|#define  STAT_SNMPINBADVERSIONS              11
  ------------------
 4748|       |
 4749|       |        /*
 4750|       |         * need better way to determine OS independent
 4751|       |         * INT32_MAX value, for now hardcode
 4752|       |         */
 4753|      0|        if (pdu->version < 0 || pdu->version > 2147483647) {
  ------------------
  |  Branch (4753:13): [True: 0, False: 0]
  |  Branch (4753:33): [True: 0, False: 0]
  ------------------
 4754|      0|            snmp_increment_statistic(STAT_SNMPINASNPARSEERRS);
  ------------------
  |  |  637|      0|#define  STAT_SNMPINASNPARSEERRS             14
  ------------------
 4755|      0|        }
 4756|      0|        session->s_snmp_errno = SNMPERR_BAD_VERSION;
  ------------------
  |  |  198|      0|#define SNMPERR_BAD_VERSION		(-14)
  ------------------
 4757|      0|        break;
 4758|  3.01k|    }
 4759|       |
 4760|  3.01k|    return result;
 4761|  3.01k|}

snmp_clone_var:
  258|     24|{
  259|     24|    if (!newvar || !var)
  ------------------
  |  Branch (259:9): [True: 0, False: 24]
  |  Branch (259:20): [True: 0, False: 24]
  ------------------
  260|      0|        return 1;
  261|       |
  262|     24|    memmove(newvar, var, sizeof(netsnmp_variable_list));
  263|     24|    newvar->next_variable = NULL;
  264|     24|    newvar->name = NULL;
  265|     24|    newvar->val.string = NULL;
  266|     24|    newvar->data = NULL;
  267|     24|    newvar->dataFreeHook = NULL;
  268|     24|    newvar->index = 0;
  269|       |
  270|       |    /*
  271|       |     * Clone the object identifier and the value.
  272|       |     * Allocate memory iff original will not fit into local storage.
  273|       |     */
  274|     24|    if (snmp_set_var_objid(newvar, var->name, var->name_length))
  ------------------
  |  Branch (274:9): [True: 0, False: 24]
  ------------------
  275|      0|        return 1;
  276|       |
  277|       |    /*
  278|       |     * need a pointer to copy a string value. 
  279|       |     */
  280|     24|    if (var->val.string) {
  ------------------
  |  Branch (280:9): [True: 22, False: 2]
  ------------------
  281|     22|        if (var->val.string != &var->buf[0]) {
  ------------------
  |  Branch (281:13): [True: 9, False: 13]
  ------------------
  282|      9|            if (var->val_len < sizeof(var->buf)) {
  ------------------
  |  Branch (282:17): [True: 6, False: 3]
  ------------------
  283|      6|                newvar->val.string = newvar->buf;
  284|      6|                memmove(newvar->val.string, var->val.string, var->val_len);
  285|      6|                newvar->val.string[var->val_len] = 0;
  286|      6|            } else {
  287|      3|                newvar->val.string = (u_char *) malloc(var->val_len + 1);
  288|      3|                if (!newvar->val.string)
  ------------------
  |  Branch (288:21): [True: 0, False: 3]
  ------------------
  289|      0|                    return 1;
  290|      3|                memmove(newvar->val.string, var->val.string, var->val_len);
  291|      3|                newvar->val.string[var->val_len] = 0;
  292|      3|            }
  293|     13|        } else {                /* fix the pointer to new local store */
  294|     13|            newvar->val.string = newvar->buf;
  295|       |            /*
  296|       |             * no need for a memmove, since we copied the whole var
  297|       |             * struct (and thus var->buf) at the beginning of this function.
  298|       |             */
  299|     13|        }
  300|     22|    } else {
  301|      2|        newvar->val.string = NULL;
  302|      2|        newvar->val_len = 0;
  303|      2|    }
  304|       |
  305|     24|    return 0;
  306|     24|}
snmp_clone_mem:
  316|    168|{
  317|    168|    *dstPtr = NULL;
  318|    168|    if (srcPtr) {
  ------------------
  |  Branch (318:9): [True: 96, False: 72]
  ------------------
  319|     96|        if (len == UINT_MAX)
  ------------------
  |  Branch (319:13): [True: 0, False: 96]
  ------------------
  320|      0|            return 1;
  321|     96|        *dstPtr = malloc(len + 1);
  322|     96|        if (!*dstPtr) {
  ------------------
  |  Branch (322:13): [True: 0, False: 96]
  ------------------
  323|      0|            return 1;
  324|      0|        }
  325|     96|        memmove(*dstPtr, srcPtr, len);
  326|       |        /*
  327|       |         * this is for those routines that expect 0-terminated strings!!!
  328|       |         * someone should rather have called strdup
  329|       |         */
  330|     96|        ((char *) *dstPtr)[len] = 0;
  331|     96|    }
  332|    168|    return 0;
  333|    168|}
snmp_clone_pdu:
  602|     24|{
  603|     24|    return _clone_pdu(pdu, 0);  /* copies all variables */
  604|     24|}
snmp_set_var_objid:
  700|  1.30k|{
  701|  1.30k|    size_t          len = sizeof(oid) * name_length;
  702|       |
  703|  1.30k|    if (vp->name != vp->name_loc && vp->name != NULL) {
  ------------------
  |  Branch (703:9): [True: 1.30k, False: 0]
  |  Branch (703:37): [True: 0, False: 1.30k]
  ------------------
  704|       |        /*
  705|       |         * Probably previously-allocated "big storage".  Better free it
  706|       |         * else memory leaks possible.  
  707|       |         */
  708|      0|        free(vp->name);
  709|      0|    }
  710|       |
  711|       |    /*
  712|       |     * use built-in storage for smaller values 
  713|       |     */
  714|  1.30k|    if (len <= sizeof(vp->name_loc)) {
  ------------------
  |  Branch (714:9): [True: 1.30k, False: 0]
  ------------------
  715|  1.30k|        vp->name = vp->name_loc;
  716|  1.30k|    } else {
  717|      0|        vp->name = (oid *) malloc(len);
  718|      0|        if (!vp->name)
  ------------------
  |  Branch (718:13): [True: 0, False: 0]
  ------------------
  719|      0|            return 1;
  720|      0|    }
  721|  1.30k|    if (objid)
  ------------------
  |  Branch (721:9): [True: 1.30k, False: 0]
  ------------------
  722|  1.30k|        memmove(vp->name, objid, len);
  723|  1.30k|    vp->name_length = name_length;
  724|  1.30k|    return 0;
  725|  1.30k|}
snmp_set_var_value:
  816|     24|{
  817|     24|    int             largeval = 1;
  818|       |
  819|       |    /*
  820|       |     * xxx-rks: why the unconditional free? why not use existing
  821|       |     * memory, if len < vars->val_len ?
  822|       |     */
  823|     24|    if (vars->val.string && vars->val.string != vars->buf) {
  ------------------
  |  Branch (823:9): [True: 0, False: 24]
  |  Branch (823:29): [True: 0, False: 0]
  ------------------
  824|      0|        free(vars->val.string);
  825|      0|    }
  826|     24|    vars->val.string = NULL;
  827|     24|    vars->val_len = 0;
  828|       |
  829|     24|    if (value == NULL && len > 0) {
  ------------------
  |  Branch (829:9): [True: 0, False: 24]
  |  Branch (829:26): [True: 0, False: 0]
  ------------------
  830|      0|        snmp_log(LOG_ERR, "bad size for NULL value\n");
  831|      0|        return 1;
  832|      0|    }
  833|       |
  834|       |    /*
  835|       |     * use built-in storage for smaller values 
  836|       |     */
  837|     24|    if (len <= sizeof(vars->buf)) {
  ------------------
  |  Branch (837:9): [True: 24, False: 0]
  ------------------
  838|     24|        vars->val.string = (u_char *) vars->buf;
  839|     24|        largeval = 0;
  840|     24|    }
  841|       |
  842|     24|    if ((0 == len) || (NULL == value)) {
  ------------------
  |  Branch (842:9): [True: 0, False: 24]
  |  Branch (842:23): [True: 0, False: 24]
  ------------------
  843|      0|        vars->val.string[0] = 0;
  844|      0|        return 0;
  845|      0|    }
  846|       |
  847|     24|    vars->val_len = len;
  848|     24|    switch (vars->type) {
  849|      0|    case ASN_INTEGER:
  ------------------
  |  |   75|      0|#define ASN_INTEGER	    0x02U
  ------------------
  |  Branch (849:5): [True: 0, False: 24]
  ------------------
  850|      0|    case ASN_UNSIGNED:
  ------------------
  |  |   91|      0|#define ASN_UNSIGNED    (ASN_APPLICATION | 2)   /* RFC 1902 - same as GAUGE */
  |  |  ------------------
  |  |  |  |   91|      0|#define ASN_APPLICATION     0x40U
  |  |  ------------------
  ------------------
  |  Branch (850:5): [True: 0, False: 24]
  ------------------
  851|      0|    case ASN_TIMETICKS:
  ------------------
  |  |   92|      0|#define ASN_TIMETICKS   (ASN_APPLICATION | 3)
  |  |  ------------------
  |  |  |  |   91|      0|#define ASN_APPLICATION     0x40U
  |  |  ------------------
  ------------------
  |  Branch (851:5): [True: 0, False: 24]
  ------------------
  852|      0|    case ASN_COUNTER:
  ------------------
  |  |   89|      0|#define ASN_COUNTER	(ASN_APPLICATION | 1)
  |  |  ------------------
  |  |  |  |   91|      0|#define ASN_APPLICATION     0x40U
  |  |  ------------------
  ------------------
  |  Branch (852:5): [True: 0, False: 24]
  ------------------
  853|      0|    case ASN_UINTEGER:
  ------------------
  |  |  100|      0|#define ASN_UINTEGER    (ASN_APPLICATION | 7)   /* historic - don't use */
  |  |  ------------------
  |  |  |  |   91|      0|#define ASN_APPLICATION     0x40U
  |  |  ------------------
  ------------------
  |  Branch (853:5): [True: 0, False: 24]
  ------------------
  854|      0|        if (vars->val_len == sizeof(int)) {
  ------------------
  |  Branch (854:13): [True: 0, False: 0]
  ------------------
  855|      0|            if (ASN_INTEGER == vars->type) {
  ------------------
  |  |   75|      0|#define ASN_INTEGER	    0x02U
  ------------------
  |  Branch (855:17): [True: 0, False: 0]
  ------------------
  856|      0|                const int      *val_int 
  857|      0|                    = (const int *) value;
  858|      0|                *(vars->val.integer) = (long) *val_int;
  859|      0|            } else {
  860|      0|                const u_int    *val_uint
  861|      0|                    = (const u_int *) value;
  862|      0|                *(vars->val.integer) = (unsigned long) *val_uint;
  863|      0|            }
  864|      0|        }
  865|      0|        else if (vars->val_len == sizeof(long)){
  ------------------
  |  Branch (865:18): [True: 0, False: 0]
  ------------------
  866|      0|            const u_long   *val_ulong
  867|      0|                = (const u_long *) value;
  868|      0|            *(vars->val.integer) = *val_ulong;
  869|      0|            if (*(vars->val.integer) > 0xffffffff) {
  ------------------
  |  Branch (869:17): [True: 0, False: 0]
  ------------------
  870|      0|                NETSNMP_LOGONCE((LOG_INFO,
  ------------------
  |  |   37|      0|#define NETSNMP_LOGONCE(x) do { \
  |  |   38|      0|        static char logged = 0; \
  |  |   39|      0|        if (!logged) {          \
  |  |  ------------------
  |  |  |  Branch (39:13): [True: 0, False: 0]
  |  |  ------------------
  |  |   40|      0|            logged = 1;         \
  |  |   41|      0|            snmp_log x ;        \
  |  |   42|      0|        }                       \
  |  |   43|      0|    } while(0)
  |  |  ------------------
  |  |  |  Branch (43:13): [Folded, False: 0]
  |  |  ------------------
  ------------------
  871|      0|                                 "truncating integer value > 32 bits\n"));
  872|      0|                *(vars->val.integer) &= 0xffffffff;
  873|      0|            }
  874|      0|        }
  875|      0|        else if (vars->val_len == sizeof(long long)){
  ------------------
  |  Branch (875:18): [True: 0, False: 0]
  ------------------
  876|      0|            const unsigned long long   *val_ullong
  877|      0|                = (const unsigned long long *) value;
  878|      0|            *(vars->val.integer) = (long) *val_ullong;
  879|      0|            if (*(vars->val.integer) > 0xffffffff) {
  ------------------
  |  Branch (879:17): [True: 0, False: 0]
  ------------------
  880|      0|                NETSNMP_LOGONCE((LOG_INFO,
  ------------------
  |  |   37|      0|#define NETSNMP_LOGONCE(x) do { \
  |  |   38|      0|        static char logged = 0; \
  |  |   39|      0|        if (!logged) {          \
  |  |  ------------------
  |  |  |  Branch (39:13): [True: 0, False: 0]
  |  |  ------------------
  |  |   40|      0|            logged = 1;         \
  |  |   41|      0|            snmp_log x ;        \
  |  |   42|      0|        }                       \
  |  |   43|      0|    } while(0)
  |  |  ------------------
  |  |  |  Branch (43:13): [Folded, False: 0]
  |  |  ------------------
  ------------------
  881|      0|                                 "truncating integer value > 32 bits\n"));
  882|      0|                *(vars->val.integer) &= 0xffffffff;
  883|      0|            }
  884|      0|        }
  885|      0|        else if (vars->val_len == sizeof(intmax_t)){
  ------------------
  |  Branch (885:18): [True: 0, False: 0]
  ------------------
  886|      0|            const uintmax_t *val_uintmax_t
  887|      0|                = (const uintmax_t *) value;
  888|      0|            *(vars->val.integer) = (long) *val_uintmax_t;
  889|      0|            if (*(vars->val.integer) > 0xffffffff) {
  ------------------
  |  Branch (889:17): [True: 0, False: 0]
  ------------------
  890|      0|                NETSNMP_LOGONCE((LOG_INFO,
  ------------------
  |  |   37|      0|#define NETSNMP_LOGONCE(x) do { \
  |  |   38|      0|        static char logged = 0; \
  |  |   39|      0|        if (!logged) {          \
  |  |  ------------------
  |  |  |  Branch (39:13): [True: 0, False: 0]
  |  |  ------------------
  |  |   40|      0|            logged = 1;         \
  |  |   41|      0|            snmp_log x ;        \
  |  |   42|      0|        }                       \
  |  |   43|      0|    } while(0)
  |  |  ------------------
  |  |  |  Branch (43:13): [Folded, False: 0]
  |  |  ------------------
  ------------------
  891|      0|                                 "truncating integer value > 32 bits\n"));
  892|      0|                *(vars->val.integer) &= 0xffffffff;
  893|      0|            }
  894|      0|        }
  895|      0|        else if (vars->val_len == sizeof(short)) {
  ------------------
  |  Branch (895:18): [True: 0, False: 0]
  ------------------
  896|      0|            if (ASN_INTEGER == vars->type) {
  ------------------
  |  |   75|      0|#define ASN_INTEGER	    0x02U
  ------------------
  |  Branch (896:17): [True: 0, False: 0]
  ------------------
  897|      0|                const short      *val_short 
  898|      0|                    = (const short *) value;
  899|      0|                *(vars->val.integer) = (long) *val_short;
  900|      0|            } else {
  901|      0|                const u_short    *val_ushort
  902|      0|                    = (const u_short *) value;
  903|      0|                *(vars->val.integer) = (unsigned long) *val_ushort;
  904|      0|            }
  905|      0|        }
  906|      0|        else if (vars->val_len == sizeof(char)) {
  ------------------
  |  Branch (906:18): [True: 0, False: 0]
  ------------------
  907|      0|            if (ASN_INTEGER == vars->type) {
  ------------------
  |  |   75|      0|#define ASN_INTEGER	    0x02U
  ------------------
  |  Branch (907:17): [True: 0, False: 0]
  ------------------
  908|      0|                const signed char   *val_char
  909|      0|                    = (const signed char *) value;
  910|      0|                *(vars->val.integer) = (long) *val_char;
  911|      0|            } else {
  912|      0|                    const u_char    *val_uchar
  913|      0|                    = (const u_char *) value;
  914|      0|                *(vars->val.integer) = (unsigned long) *val_uchar;
  915|      0|            }
  916|      0|        }
  917|      0|        else {
  918|      0|            snmp_log(LOG_ERR,"bad size for integer-like type (%d)\n",
  919|      0|                     (int)vars->val_len);
  920|      0|            return (1);
  921|      0|        }
  922|      0|        vars->val_len = sizeof(long);
  923|      0|        break;
  924|       |
  925|      0|    case ASN_OBJECT_ID:
  ------------------
  |  |   81|      0|#define ASN_OBJECT_ID	    0x06U
  ------------------
  |  Branch (925:5): [True: 0, False: 24]
  ------------------
  926|      0|    case ASN_PRIV_IMPLIED_OBJECT_ID:
  ------------------
  |  |  205|      0|#define ASN_PRIV_IMPLIED_OBJECT_ID  (ASN_PRIVATE | ASN_OBJECT_ID)       /* 6 */
  |  |  ------------------
  |  |  |  |   93|      0|#define ASN_PRIVATE	    0xC0U
  |  |  ------------------
  |  |               #define ASN_PRIV_IMPLIED_OBJECT_ID  (ASN_PRIVATE | ASN_OBJECT_ID)       /* 6 */
  |  |  ------------------
  |  |  |  |   81|      0|#define ASN_OBJECT_ID	    0x06U
  |  |  ------------------
  ------------------
  |  Branch (926:5): [True: 0, False: 24]
  ------------------
  927|      0|    case ASN_PRIV_INCL_RANGE:
  ------------------
  |  |  201|      0|#define ASN_PRIV_INCL_RANGE (ASN_PRIVATE | 2)
  |  |  ------------------
  |  |  |  |   93|      0|#define ASN_PRIVATE	    0xC0U
  |  |  ------------------
  ------------------
  |  Branch (927:5): [True: 0, False: 24]
  ------------------
  928|      0|    case ASN_PRIV_EXCL_RANGE:
  ------------------
  |  |  202|      0|#define ASN_PRIV_EXCL_RANGE (ASN_PRIVATE | 3)
  |  |  ------------------
  |  |  |  |   93|      0|#define ASN_PRIVATE	    0xC0U
  |  |  ------------------
  ------------------
  |  Branch (928:5): [True: 0, False: 24]
  ------------------
  929|      0|        if (largeval) {
  ------------------
  |  Branch (929:13): [True: 0, False: 0]
  ------------------
  930|      0|            vars->val.objid = (oid *) malloc(vars->val_len);
  931|      0|        }
  932|      0|        if (vars->val.objid == NULL) {
  ------------------
  |  Branch (932:13): [True: 0, False: 0]
  ------------------
  933|      0|            snmp_log(LOG_ERR,"no storage for OID\n");
  934|      0|            return 1;
  935|      0|        }
  936|      0|        memmove(vars->val.objid, value, vars->val_len);
  937|      0|        break;
  938|       |
  939|      0|    case ASN_IPADDRESS: /* snmp_build_var_op treats IPADDR like a string */
  ------------------
  |  |   88|      0|#define ASN_IPADDRESS   (ASN_APPLICATION | 0)
  |  |  ------------------
  |  |  |  |   91|      0|#define ASN_APPLICATION     0x40U
  |  |  ------------------
  ------------------
  |  Branch (939:5): [True: 0, False: 24]
  ------------------
  940|      0|        if (4 != vars->val_len) {
  ------------------
  |  Branch (940:13): [True: 0, False: 0]
  ------------------
  941|      0|            netsnmp_assert("ipaddress length == 4");
  ------------------
  |  |   47|      0|#      define netsnmp_assert(x)  do { \
  |  |   48|      0|              if ( x ) \
  |  |  ------------------
  |  |  |  Branch (48:20): [True: 0, False: 0]
  |  |  ------------------
  |  |   49|      0|                 ; \
  |  |   50|      0|              else \
  |  |   51|      0|                 snmp_log(LOG_ERR, \
  |  |   52|      0|                          "netsnmp_assert %s failed %s:%d" NETSNMP_FUNC_FMT, \
  |  |  ------------------
  |  |  |  |   40|      0|#          define NETSNMP_FUNC_FMT " %s()\n"
  |  |  ------------------
  |  |   53|      0|                          __STRING(x),__FILE__,__LINE__, \
  |  |   54|      0|                          NETSNMP_FUNC_PARAM); \
  |  |  ------------------
  |  |  |  |   41|      0|#          define NETSNMP_FUNC_PARAM NETSNMP_FUNCTION
  |  |  |  |  ------------------
  |  |  |  |  |  | 1727|      0|#define NETSNMP_FUNCTION __func__
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   55|      0|           }while(0)
  |  |  ------------------
  |  |  |  Branch (55:19): [Folded, False: 0]
  |  |  ------------------
  ------------------
  942|      0|        }
  943|      0|        NETSNMP_FALLTHROUGH;
  ------------------
  |  | 2443|      0|#    define NETSNMP_FALLTHROUGH __attribute__((__fallthrough__))
  ------------------
  944|      0|    case ASN_PRIV_IMPLIED_OCTET_STR:
  ------------------
  |  |  204|      0|#define ASN_PRIV_IMPLIED_OCTET_STR  (ASN_PRIVATE | ASN_OCTET_STR)       /* 4 */
  |  |  ------------------
  |  |  |  |   93|      0|#define ASN_PRIVATE	    0xC0U
  |  |  ------------------
  |  |               #define ASN_PRIV_IMPLIED_OCTET_STR  (ASN_PRIVATE | ASN_OCTET_STR)       /* 4 */
  |  |  ------------------
  |  |  |  |   78|      0|#define ASN_OCTET_STR	    0x04U
  |  |  ------------------
  ------------------
  |  Branch (944:5): [True: 0, False: 24]
  ------------------
  945|     24|    case ASN_OCTET_STR:
  ------------------
  |  |   78|     24|#define ASN_OCTET_STR	    0x04U
  ------------------
  |  Branch (945:5): [True: 24, False: 0]
  ------------------
  946|     24|    case ASN_BIT_STR:
  ------------------
  |  |   77|     24|#define ASN_BIT_STR	    0x03U
  ------------------
  |  Branch (946:5): [True: 0, False: 24]
  ------------------
  947|     24|    case ASN_OPAQUE:
  ------------------
  |  |   93|     24|#define ASN_OPAQUE	(ASN_APPLICATION | 4)   /* changed so no conflict with other includes */
  |  |  ------------------
  |  |  |  |   91|     24|#define ASN_APPLICATION     0x40U
  |  |  ------------------
  ------------------
  |  Branch (947:5): [True: 0, False: 24]
  ------------------
  948|     24|    case ASN_NSAP:
  ------------------
  |  |   98|     24|#define ASN_NSAP	(ASN_APPLICATION | 5)   /* historic - don't use */
  |  |  ------------------
  |  |  |  |   91|     24|#define ASN_APPLICATION     0x40U
  |  |  ------------------
  ------------------
  |  Branch (948:5): [True: 0, False: 24]
  ------------------
  949|     24|        if (vars->val_len >= sizeof(vars->buf)) {
  ------------------
  |  Branch (949:13): [True: 0, False: 24]
  ------------------
  950|      0|            vars->val.string = (u_char *) malloc(vars->val_len + 1);
  951|      0|        }
  952|     24|        if (vars->val.string == NULL) {
  ------------------
  |  Branch (952:13): [True: 0, False: 24]
  ------------------
  953|      0|            snmp_log(LOG_ERR,"no storage for string\n");
  954|      0|            return 1;
  955|      0|        }
  956|     24|        memmove(vars->val.string, value, vars->val_len);
  957|       |        /*
  958|       |         * Make sure the string is zero-terminated; some bits of code make
  959|       |         * this assumption.  Easier to do this here than fix all these wrong
  960|       |         * assumptions.  
  961|       |         */
  962|     24|        vars->val.string[vars->val_len] = '\0';
  963|     24|        break;
  964|       |
  965|      0|    case SNMP_NOSUCHOBJECT:
  ------------------
  |  |  201|      0|#define SNMP_NOSUCHOBJECT    (ASN_CONTEXT | ASN_PRIMITIVE | 0x0) /* 80=128 */
  |  |  ------------------
  |  |  |  |   92|      0|#define ASN_CONTEXT	    0x80U
  |  |  ------------------
  |  |               #define SNMP_NOSUCHOBJECT    (ASN_CONTEXT | ASN_PRIMITIVE | 0x0) /* 80=128 */
  |  |  ------------------
  |  |  |  |   95|      0|#define ASN_PRIMITIVE	    0x00U
  |  |  ------------------
  ------------------
  |  Branch (965:5): [True: 0, False: 24]
  ------------------
  966|      0|    case SNMP_NOSUCHINSTANCE:
  ------------------
  |  |  202|      0|#define SNMP_NOSUCHINSTANCE  (ASN_CONTEXT | ASN_PRIMITIVE | 0x1) /* 81=129 */
  |  |  ------------------
  |  |  |  |   92|      0|#define ASN_CONTEXT	    0x80U
  |  |  ------------------
  |  |               #define SNMP_NOSUCHINSTANCE  (ASN_CONTEXT | ASN_PRIMITIVE | 0x1) /* 81=129 */
  |  |  ------------------
  |  |  |  |   95|      0|#define ASN_PRIMITIVE	    0x00U
  |  |  ------------------
  ------------------
  |  Branch (966:5): [True: 0, False: 24]
  ------------------
  967|      0|    case SNMP_ENDOFMIBVIEW:
  ------------------
  |  |  203|      0|#define SNMP_ENDOFMIBVIEW    (ASN_CONTEXT | ASN_PRIMITIVE | 0x2) /* 82=130 */
  |  |  ------------------
  |  |  |  |   92|      0|#define ASN_CONTEXT	    0x80U
  |  |  ------------------
  |  |               #define SNMP_ENDOFMIBVIEW    (ASN_CONTEXT | ASN_PRIMITIVE | 0x2) /* 82=130 */
  |  |  ------------------
  |  |  |  |   95|      0|#define ASN_PRIMITIVE	    0x00U
  |  |  ------------------
  ------------------
  |  Branch (967:5): [True: 0, False: 24]
  ------------------
  968|      0|    case ASN_NULL:
  ------------------
  |  |   79|      0|#define ASN_NULL	    0x05U
  ------------------
  |  Branch (968:5): [True: 0, False: 24]
  ------------------
  969|      0|        vars->val_len = 0;
  970|      0|        vars->val.string = NULL;
  971|      0|        break;
  972|       |
  973|      0|#ifdef NETSNMP_WITH_OPAQUE_SPECIAL_TYPES
  974|      0|    case ASN_OPAQUE_U64:
  ------------------
  |  |  192|      0|#define ASN_OPAQUE_U64 (ASN_OPAQUE_TAG2 + ASN_APP_U64)
  |  |  ------------------
  |  |  |  |  136|      0|#define ASN_OPAQUE_TAG2 0x30U
  |  |  ------------------
  |  |               #define ASN_OPAQUE_U64 (ASN_OPAQUE_TAG2 + ASN_APP_U64)
  |  |  ------------------
  |  |  |  |  150|      0|#define ASN_APP_U64 (ASN_APPLICATION | 11)
  |  |  |  |  ------------------
  |  |  |  |  |  |   91|      0|#define ASN_APPLICATION     0x40U
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (974:5): [True: 0, False: 24]
  ------------------
  975|      0|    case ASN_OPAQUE_I64:
  ------------------
  |  |  183|      0|#define ASN_OPAQUE_I64 (ASN_OPAQUE_TAG2 + ASN_APP_I64)
  |  |  ------------------
  |  |  |  |  136|      0|#define ASN_OPAQUE_TAG2 0x30U
  |  |  ------------------
  |  |               #define ASN_OPAQUE_I64 (ASN_OPAQUE_TAG2 + ASN_APP_I64)
  |  |  ------------------
  |  |  |  |  149|      0|#define ASN_APP_I64 (ASN_APPLICATION | 10)
  |  |  |  |  ------------------
  |  |  |  |  |  |   91|      0|#define ASN_APPLICATION     0x40U
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (975:5): [True: 0, False: 24]
  ------------------
  976|      0|#endif                          /* NETSNMP_WITH_OPAQUE_SPECIAL_TYPES */
  977|      0|    case ASN_COUNTER64:
  ------------------
  |  |   99|      0|#define ASN_COUNTER64   (ASN_APPLICATION | 6)
  |  |  ------------------
  |  |  |  |   91|      0|#define ASN_APPLICATION     0x40U
  |  |  ------------------
  ------------------
  |  Branch (977:5): [True: 0, False: 24]
  ------------------
  978|      0|        if (largeval || vars->val_len != sizeof(struct counter64)) {
  ------------------
  |  Branch (978:13): [True: 0, False: 0]
  |  Branch (978:25): [True: 0, False: 0]
  ------------------
  979|      0|            snmp_log(LOG_ERR,"bad size for counter 64 (%d)\n",
  980|      0|                     (int)vars->val_len);
  981|      0|            return (1);
  982|      0|        }
  983|      0|        vars->val_len = sizeof(struct counter64);
  984|      0|        memmove(vars->val.counter64, value, vars->val_len);
  985|      0|        break;
  986|       |
  987|      0|#ifdef NETSNMP_WITH_OPAQUE_SPECIAL_TYPES
  988|      0|    case ASN_OPAQUE_FLOAT:
  ------------------
  |  |  165|      0|#define ASN_OPAQUE_FLOAT (ASN_OPAQUE_TAG2 + ASN_APP_FLOAT)
  |  |  ------------------
  |  |  |  |  136|      0|#define ASN_OPAQUE_TAG2 0x30U
  |  |  ------------------
  |  |               #define ASN_OPAQUE_FLOAT (ASN_OPAQUE_TAG2 + ASN_APP_FLOAT)
  |  |  ------------------
  |  |  |  |  147|      0|#define ASN_APP_FLOAT (ASN_APPLICATION | 8)
  |  |  |  |  ------------------
  |  |  |  |  |  |   91|      0|#define ASN_APPLICATION     0x40U
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (988:5): [True: 0, False: 24]
  ------------------
  989|      0|        if (largeval) {
  ------------------
  |  Branch (989:13): [True: 0, False: 0]
  ------------------
  990|      0|            snmp_log(LOG_ERR,"bad size for opaque float (%d)\n",
  991|      0|                     (int)vars->val_len);
  992|      0|            return (1);
  993|      0|        }
  994|      0|        vars->val_len = sizeof(float);
  995|      0|        memmove(vars->val.floatVal, value, vars->val_len);
  996|      0|        break;
  997|       |
  998|      0|    case ASN_OPAQUE_DOUBLE:
  ------------------
  |  |  174|      0|#define ASN_OPAQUE_DOUBLE (ASN_OPAQUE_TAG2 + ASN_APP_DOUBLE)
  |  |  ------------------
  |  |  |  |  136|      0|#define ASN_OPAQUE_TAG2 0x30U
  |  |  ------------------
  |  |               #define ASN_OPAQUE_DOUBLE (ASN_OPAQUE_TAG2 + ASN_APP_DOUBLE)
  |  |  ------------------
  |  |  |  |  148|      0|#define ASN_APP_DOUBLE (ASN_APPLICATION | 9)
  |  |  |  |  ------------------
  |  |  |  |  |  |   91|      0|#define ASN_APPLICATION     0x40U
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (998:5): [True: 0, False: 24]
  ------------------
  999|      0|        if (largeval) {
  ------------------
  |  Branch (999:13): [True: 0, False: 0]
  ------------------
 1000|      0|            snmp_log(LOG_ERR,"bad size for opaque double (%d)\n",
 1001|      0|                     (int)vars->val_len);
 1002|      0|            return (1);
 1003|      0|        }
 1004|      0|        vars->val_len = sizeof(double);
 1005|      0|        memmove(vars->val.doubleVal, value, vars->val_len);
 1006|      0|        break;
 1007|       |
 1008|      0|#endif                          /* NETSNMP_WITH_OPAQUE_SPECIAL_TYPES */
 1009|       |
 1010|      0|    default:
  ------------------
  |  Branch (1010:5): [True: 0, False: 24]
  ------------------
 1011|      0|        snmp_log(LOG_ERR,"Internal error in type switching\n");
 1012|      0|        snmp_set_detail("Internal error in type switching\n");
 1013|      0|        return (1);
 1014|     24|    }
 1015|       |
 1016|     24|    return 0;
 1017|     24|}
snmp_client.c:_copy_varlist:
  437|     24|{                               /* !=0 number variables to copy */
  438|     24|    netsnmp_variable_list *newhead, *newvar, *oldvar;
  439|     24|    int             ii = 0;
  440|       |
  441|     24|    newhead = NULL;
  442|     24|    oldvar = NULL;
  443|       |
  444|     48|    while (var && (copy_count-- > 0)) {
  ------------------
  |  Branch (444:12): [True: 24, False: 24]
  |  Branch (444:19): [True: 24, False: 0]
  ------------------
  445|       |        /*
  446|       |         * Drop the specified variable (if applicable) 
  447|       |         * xxx hmm, is it intentional that dropping the errindex
  448|       |         *     counts towards copy_count?
  449|       |         */
  450|     24|        if (++ii == errindex) {
  ------------------
  |  Branch (450:13): [True: 0, False: 24]
  ------------------
  451|      0|            var = var->next_variable;
  452|      0|            continue;
  453|      0|        }
  454|       |
  455|       |        /*
  456|       |         * clone the next variable. Cleanup if alloc fails 
  457|       |         */
  458|     24|        newvar = (netsnmp_variable_list *)
  459|     24|            malloc(sizeof(netsnmp_variable_list));
  460|     24|        if (snmp_clone_var(var, newvar)) {
  ------------------
  |  Branch (460:13): [True: 0, False: 24]
  ------------------
  461|      0|            if (newvar)
  ------------------
  |  Branch (461:17): [True: 0, False: 0]
  ------------------
  462|      0|                free(newvar);
  463|      0|            snmp_free_varbind(newhead);
  464|      0|            return NULL;
  465|      0|        }
  466|       |
  467|       |        /*
  468|       |         * add cloned variable to new list  
  469|       |         */
  470|     24|        if (NULL == newhead)
  ------------------
  |  Branch (470:13): [True: 24, False: 0]
  ------------------
  471|     24|            newhead = newvar;
  472|     24|        if (oldvar)
  ------------------
  |  Branch (472:13): [True: 0, False: 24]
  ------------------
  473|      0|            oldvar->next_variable = newvar;
  474|     24|        oldvar = newvar;
  475|       |
  476|     24|        var = var->next_variable;
  477|     24|    }
  478|     24|    return newhead;
  479|     24|}
snmp_client.c:_clone_pdu:
  570|     24|{
  571|     24|    netsnmp_pdu    *newpdu;
  572|       |
  573|     24|    newpdu = _clone_pdu_header(pdu);
  574|     24|    if (!newpdu)
  ------------------
  |  Branch (574:9): [True: 0, False: 24]
  ------------------
  575|      0|        return newpdu;
  576|     24|    newpdu = _copy_pdu_vars(pdu, newpdu, drop_err, 0, 10000);   /* skip none, copy all */
  577|       |
  578|     24|    return newpdu;
  579|     24|}
snmp_client.c:_clone_pdu_header:
  372|     24|{
  373|     24|    netsnmp_pdu    *newpdu;
  374|     24|    struct snmp_secmod_def *sptr;
  375|     24|    int ret;
  376|       |
  377|     24|    if (!pdu)
  ------------------
  |  Branch (377:9): [True: 0, False: 24]
  ------------------
  378|      0|        return NULL;
  379|       |
  380|     24|    newpdu = netsnmp_memdup(pdu, sizeof(netsnmp_pdu));
  381|     24|    if (!newpdu)
  ------------------
  |  Branch (381:9): [True: 0, False: 24]
  ------------------
  382|      0|        return NULL;
  383|       |
  384|       |    /*
  385|       |     * reset copied pointers if copy fails 
  386|       |     */
  387|     24|    newpdu->variables = NULL;
  388|     24|    newpdu->enterprise = NULL;
  389|     24|    newpdu->community = NULL;
  390|     24|    newpdu->securityEngineID = NULL;
  391|     24|    newpdu->securityName = NULL;
  392|     24|    newpdu->contextEngineID = NULL;
  393|     24|    newpdu->contextName = NULL;
  394|     24|    newpdu->transport_data = NULL;
  395|     24|    newpdu->securityStateRef = NULL;
  396|       |
  397|       |    /*
  398|       |     * copy buffers individually. If any copy fails, all are freed. 
  399|       |     */
  400|     24|    if (snmp_clone_mem((void **) &newpdu->enterprise, pdu->enterprise,
  ------------------
  |  Branch (400:9): [True: 0, False: 24]
  ------------------
  401|     24|                       sizeof(oid) * pdu->enterprise_length) ||
  402|     24|        snmp_clone_mem((void **) &newpdu->community, pdu->community,
  ------------------
  |  Branch (402:9): [True: 0, False: 24]
  ------------------
  403|     24|                       pdu->community_len) ||
  404|     24|        snmp_clone_mem((void **) &newpdu->contextEngineID,
  ------------------
  |  Branch (404:9): [True: 0, False: 24]
  ------------------
  405|     24|                       pdu->contextEngineID, pdu->contextEngineIDLen)
  406|     24|        || snmp_clone_mem((void **) &newpdu->securityEngineID,
  ------------------
  |  Branch (406:12): [True: 0, False: 24]
  ------------------
  407|     24|                          pdu->securityEngineID, pdu->securityEngineIDLen)
  408|     24|        || snmp_clone_mem((void **) &newpdu->contextName, pdu->contextName,
  ------------------
  |  Branch (408:12): [True: 0, False: 24]
  ------------------
  409|     24|                          pdu->contextNameLen)
  410|     24|        || snmp_clone_mem((void **) &newpdu->securityName,
  ------------------
  |  Branch (410:12): [True: 0, False: 24]
  ------------------
  411|     24|                          pdu->securityName, pdu->securityNameLen)
  412|     24|        || snmp_clone_mem((void **) &newpdu->transport_data,
  ------------------
  |  Branch (412:12): [True: 0, False: 24]
  ------------------
  413|     24|                          pdu->transport_data,
  414|     24|                          pdu->transport_data_length)) {
  415|      0|        snmp_free_pdu(newpdu);
  416|      0|        return NULL;
  417|      0|    }
  418|       |
  419|     24|    sptr = find_sec_mod(newpdu->securityModel);
  420|     24|    if (sptr && sptr->pdu_clone) {
  ------------------
  |  Branch (420:9): [True: 24, False: 0]
  |  Branch (420:17): [True: 24, False: 0]
  ------------------
  421|       |        /* call security model if it needs to know about this */
  422|     24|        ret = sptr->pdu_clone(pdu, newpdu);
  423|     24|        if (ret) {
  ------------------
  |  Branch (423:13): [True: 0, False: 24]
  ------------------
  424|      0|            snmp_free_pdu(newpdu);
  425|      0|            return NULL;
  426|      0|        }
  427|     24|    }
  428|       |
  429|     24|    return newpdu;
  430|     24|}
snmp_client.c:_copy_pdu_vars:
  507|     24|{                               /* !=0 number of variables to copy */
  508|     24|    netsnmp_variable_list *var;
  509|       |#ifdef TEMPORARILY_DISABLED
  510|       |    int             copied;
  511|       |#endif
  512|     24|    int             drop_idx;
  513|       |
  514|     24|    if (!newpdu)
  ------------------
  |  Branch (514:9): [True: 0, False: 24]
  ------------------
  515|      0|        return NULL;            /* where is PDU to copy to ? */
  516|       |
  517|     24|    if (drop_err)
  ------------------
  |  Branch (517:9): [True: 0, False: 24]
  ------------------
  518|      0|        drop_idx = pdu->errindex - skip_count;
  519|     24|    else
  520|     24|        drop_idx = 0;
  521|       |
  522|     24|    var = pdu->variables;
  523|     24|    while (var && (skip_count-- > 0))   /* skip over pdu variables */
  ------------------
  |  Branch (523:12): [True: 24, False: 0]
  |  Branch (523:19): [True: 0, False: 24]
  ------------------
  524|      0|        var = var->next_variable;
  525|       |
  526|       |#ifdef TEMPORARILY_DISABLED
  527|       |    copied = 0;
  528|       |    if (pdu->flags & UCD_MSG_FLAG_FORCE_PDU_COPY)
  529|       |        copied = 1;             /* We're interested in 'empty' responses too */
  530|       |#endif
  531|       |
  532|     24|    newpdu->variables = _copy_varlist(var, drop_idx, copy_count);
  533|       |#ifdef TEMPORARILY_DISABLED
  534|       |    if (newpdu->variables)
  535|       |        copied = 1;
  536|       |#endif
  537|       |
  538|       |#ifdef ALSO_TEMPORARILY_DISABLED
  539|       |    /*
  540|       |     * Error if bad errindex or if target PDU has no variables copied 
  541|       |     */
  542|       |    if ((drop_err && (ii < pdu->errindex))
  543|       |#ifdef TEMPORARILY_DISABLED
  544|       |        /*
  545|       |         * SNMPv3 engineID probes are allowed to be empty.
  546|       |         * See the comment in snmp_api.c for further details 
  547|       |         */
  548|       |        || copied == 0
  549|       |#endif
  550|       |        ) {
  551|       |        snmp_free_pdu(newpdu);
  552|       |        return 0;
  553|       |    }
  554|       |#endif
  555|     24|    return newpdu;
  556|     24|}

snmp_get_do_debugging:
  551|   175k|{
  552|   175k|    return dodebug;
  553|   175k|}
snmp_debug_init:
  722|      2|{
  723|       |#ifdef HAVE_WOLFSSL_WOLFCRYPT_LOGGING_H
  724|       |    wolfSSL_Debugging_ON();
  725|       |    wolfSSL_SetLoggingCb(snmp_log_wolfssl_msg);
  726|       |#endif
  727|       |
  728|      2|    register_prenetsnmp_mib_handler("snmp", "doDebugging",
  729|      2|                                    debug_config_turn_on_debugging, NULL,
  730|      2|                                    "(1|0)");
  731|      2|    register_prenetsnmp_mib_handler("snmp", "debugTokens",
  732|      2|                                    debug_config_register_tokens, NULL,
  733|      2|                                    "token[,token...]");
  734|      2|#ifndef NETSNMP_DISABLE_DYNAMIC_LOG_LEVEL
  735|      2|    register_prenetsnmp_mib_handler("snmp", "debugLogLevel",
  736|       |                                    debug_config_debug_log_level, NULL,
  737|      2|                                    "(emerg|alert|crit|err|warning|notice|info|debug)");
  738|      2|#endif /* NETSNMP_DISABLE_DYNAMIC_LOG_LEVEL */
  739|      2|}

init_snmp_enum:
   54|      2|{
   55|      2|    if (NULL != snmp_enum_lists)
  ------------------
  |  Branch (55:9): [True: 0, False: 2]
  ------------------
   56|      0|        return SE_OK;
  ------------------
  |  |   42|      0|#define SE_OK            0
  ------------------
   57|       |
   58|      2|    snmp_enum_lists = calloc(SE_MAX_IDS * SE_MAX_SUBIDS,
  ------------------
  |  |   21|      2|#define SE_MAX_IDS 5
  ------------------
                  snmp_enum_lists = calloc(SE_MAX_IDS * SE_MAX_SUBIDS,
  ------------------
  |  |   22|      2|#define SE_MAX_SUBIDS 32        /* needs to be a multiple of 8 */
  ------------------
   59|      2|                             sizeof(*snmp_enum_lists));
   60|      2|    if (!snmp_enum_lists)
  ------------------
  |  Branch (60:9): [True: 0, False: 2]
  ------------------
   61|      0|        return SE_NOMEM;
  ------------------
  |  |   43|      0|#define SE_NOMEM         1
  ------------------
   62|      2|    current_maj_num = SE_MAX_IDS;
  ------------------
  |  |   21|      2|#define SE_MAX_IDS 5
  ------------------
   63|      2|    current_min_num = SE_MAX_SUBIDS;
  ------------------
  |  |   22|      2|#define SE_MAX_SUBIDS 32        /* needs to be a multiple of 8 */
  ------------------
   64|       |
   65|      2|    register_const_config_handler(type, "enum", se_read_conf, NULL, NULL);
   66|      2|    return SE_OK;
  ------------------
  |  |   42|      2|#define SE_OK            0
  ------------------
   67|      2|}
se_add_pair_to_list:
  269|     56|{
  270|     56|    struct snmp_enum_list *lastnode = NULL, *new_node, *tmp;
  271|       |
  272|     56|    if (!list) {
  ------------------
  |  Branch (272:9): [True: 0, False: 56]
  ------------------
  273|      0|        free(label);
  274|      0|        return SE_DNE;
  ------------------
  |  |   45|      0|#define SE_DNE           -2
  ------------------
  275|      0|    }
  276|       |
  277|     56|    tmp = *list;
  278|    168|    while (tmp) {
  ------------------
  |  Branch (278:12): [True: 120, False: 48]
  ------------------
  279|    120|        if (tmp->value == value) {
  ------------------
  |  Branch (279:13): [True: 8, False: 112]
  ------------------
  280|      8|            free(label);
  281|      8|            return (SE_ALREADY_THERE);
  ------------------
  |  |   44|      8|#define SE_ALREADY_THERE 2
  ------------------
  282|      8|        }
  283|    112|        lastnode = tmp;
  284|    112|        tmp = tmp->next;
  285|    112|    }
  286|       |
  287|     48|    new_node = SNMP_MALLOC_STRUCT(snmp_enum_list);
  ------------------
  |  |   69|     48|#define SNMP_MALLOC_STRUCT(s)   (struct s *) calloc(1, sizeof(struct s))
  ------------------
  288|     48|    if (!new_node) {
  ------------------
  |  Branch (288:9): [True: 0, False: 48]
  ------------------
  289|      0|        free(label);
  290|      0|        return (SE_NOMEM);
  ------------------
  |  |   43|      0|#define SE_NOMEM         1
  ------------------
  291|      0|    }
  292|       |
  293|     48|    if (lastnode)
  ------------------
  |  Branch (293:9): [True: 38, False: 10]
  ------------------
  294|     38|        lastnode->next = new_node;
  295|     10|    else
  296|     10|        *list = new_node;
  297|     48|    new_node->label = label;
  298|     48|    new_node->value = value;
  299|     48|    new_node->next = NULL;
  300|     48|    return (SE_OK);
  ------------------
  |  |   42|     48|#define SE_OK            0
  ------------------
  301|     48|}
se_add_pair_to_slist:
  365|     56|{
  366|     56|    struct snmp_enum_list **list_p = se_find_slist_ptr(listname);
  367|       |
  368|     56|    if (!list_p) {
  ------------------
  |  Branch (368:9): [True: 10, False: 46]
  ------------------
  369|     10|        struct snmp_enum_list_str *sptr =
  370|     10|            SNMP_MALLOC_STRUCT(snmp_enum_list_str);
  ------------------
  |  |   69|     10|#define SNMP_MALLOC_STRUCT(s)   (struct s *) calloc(1, sizeof(struct s))
  ------------------
  371|     10|        if (!sptr) {
  ------------------
  |  Branch (371:13): [True: 0, False: 10]
  ------------------
  372|      0|            free(label);
  373|      0|            return SE_NOMEM;
  ------------------
  |  |   43|      0|#define SE_NOMEM         1
  ------------------
  374|      0|        }
  375|     10|        sptr->next = sliststorage;
  376|     10|        sptr->name = strdup(listname);
  377|     10|        if (!sptr->name) {
  ------------------
  |  Branch (377:13): [True: 0, False: 10]
  ------------------
  378|      0|            free(sptr);
  379|      0|            free(label);
  380|      0|            return SE_NOMEM;
  ------------------
  |  |   43|      0|#define SE_NOMEM         1
  ------------------
  381|      0|        }
  382|     10|        list_p = &sptr->list;
  383|     10|        sliststorage = sptr;
  384|     10|    }
  385|       |
  386|     56|    return se_add_pair_to_list(list_p, label, value);
  387|     56|}
snmp_enum.c:se_find_slist_ptr:
  314|     56|{
  315|     56|    struct snmp_enum_list_str *sptr;
  316|     56|    if (!listname)
  ------------------
  |  Branch (316:9): [True: 0, False: 56]
  ------------------
  317|      0|        return NULL;
  318|       |
  319|     76|    for (sptr = sliststorage; sptr != NULL; sptr = sptr->next)
  ------------------
  |  Branch (319:31): [True: 66, False: 10]
  ------------------
  320|     66|        if (sptr->name && strcmp(sptr->name, listname) == 0)
  ------------------
  |  Branch (320:13): [True: 66, False: 0]
  |  Branch (320:27): [True: 46, False: 20]
  ------------------
  321|     46|            return &sptr->list;
  322|       |
  323|     10|    return NULL;
  324|     56|}

init_snmp_logging:
  168|      2|{
  169|      2|    netsnmp_ds_register_premib(ASN_BOOLEAN, "snmp", "logTimestamp", 
  ------------------
  |  |   72|      2|#define ASN_BOOLEAN	    0x01U
  ------------------
  170|      2|			 NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_LOG_TIMESTAMP);
  ------------------
  |  |   48|      2|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
              			 NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_LOG_TIMESTAMP);
  ------------------
  |  |   64|      2|#define NETSNMP_DS_LIB_LOG_TIMESTAMP       5
  ------------------
  171|      2|    register_prenetsnmp_mib_handler("snmp", "logOption",
  172|      2|                                    parse_config_logOption, NULL, "string");
  173|       |
  174|      2|}
netsnmp_set_line_buffering:
  187|      2|{
  188|       |#if defined(WIN32)
  189|       |    /*
  190|       |     * According to MSDN, the Microsoft Visual Studio C runtime library does
  191|       |     * not support line buffering, so turn off buffering completely.
  192|       |     * See also http://msdn.microsoft.com/en-us/library/86cebhfs(VS.71).aspx.
  193|       |     */
  194|       |    setvbuf(stream, NULL, _IONBF, BUFSIZ);
  195|       |#elif defined(HAVE_SETLINEBUF)
  196|       |    /* setlinefunction() is a function from the BSD Unix API. */
  197|       |    setlinebuf(stream);
  198|       |#else
  199|       |    /* See also the C89 or C99 standard for more information about setvbuf(). */
  200|      2|    setvbuf(stream, NULL, _IOLBF, BUFSIZ);
  201|      2|#endif
  202|      2|}
log_handler_stdouterr:
 1103|  1.58k|{
 1104|  1.58k|    static int      newline = 1;	 /* MTCRITICAL_RESOURCE */
 1105|  1.58k|    const char     *newline_ptr;
 1106|  1.58k|    char            sbuf[40];
 1107|       |
 1108|  1.58k|    if (netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, 
  ------------------
  |  |   48|  1.58k|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  |  Branch (1108:9): [True: 0, False: 1.58k]
  ------------------
 1109|  1.58k|                               NETSNMP_DS_LIB_LOG_TIMESTAMP) && newline) {
  ------------------
  |  |   64|  1.58k|#define NETSNMP_DS_LIB_LOG_TIMESTAMP       5
  ------------------
  |  Branch (1109:65): [True: 0, False: 0]
  ------------------
 1110|      0|        snprintf_stamp(NULL, sbuf, sizeof(sbuf));
 1111|  1.58k|    } else {
 1112|  1.58k|        strcpy(sbuf, "");
 1113|  1.58k|    }
 1114|       |    /*
 1115|       |     * Remember whether or not the current line ends with a newline for the
 1116|       |     * next call of log_handler_stdouterr().
 1117|       |     */
 1118|  1.58k|    newline_ptr = strrchr(str, '\n');
 1119|  1.58k|    newline = newline_ptr && newline_ptr[1] == 0;
  ------------------
  |  Branch (1119:15): [True: 1.58k, False: 0]
  |  Branch (1119:30): [True: 1.58k, False: 0]
  ------------------
 1120|       |
 1121|  1.58k|    if (logh->imagic)
  ------------------
  |  Branch (1121:9): [True: 0, False: 1.58k]
  ------------------
 1122|      0|       printf(         "%s%s", sbuf, str);
 1123|  1.58k|    else
 1124|  1.58k|       fprintf(stderr, "%s%s", sbuf, str);
 1125|       |
 1126|  1.58k|    return 1;
 1127|  1.58k|}
snmp_log_string:
 1294|  1.58k|{
 1295|  1.58k|#ifndef NETSNMP_FEATURE_REMOVE_LOGGING_STDIO
 1296|  1.58k|    static int stderr_enabled = 0;
 1297|  1.58k|    static netsnmp_log_handler lh = { 1, 0, 0, 0, "stderr",
 1298|  1.58k|                                      log_handler_stdouterr, 0, NULL,  NULL,
 1299|  1.58k|                                      NULL };
 1300|  1.58k|#endif /* NETSNMP_FEATURE_REMOVE_LOGGING_STDIO */
 1301|  1.58k|    netsnmp_log_handler *logh;
 1302|       |
 1303|       |    /*
 1304|       |     * We've got to be able to log messages *somewhere*!
 1305|       |     * If you don't want stderr logging, then enable something else.
 1306|       |     */
 1307|  1.58k|    if (0 == logh_enabled) {
  ------------------
  |  Branch (1307:9): [True: 1.58k, False: 0]
  ------------------
 1308|  1.58k|#ifndef NETSNMP_FEATURE_REMOVE_LOGGING_STDIO
 1309|  1.58k|        if (!stderr_enabled) {
  ------------------
  |  Branch (1309:13): [True: 2, False: 1.58k]
  ------------------
 1310|      2|            ++stderr_enabled;
 1311|      2|            netsnmp_set_line_buffering(stderr);
 1312|      2|        }
 1313|  1.58k|        log_handler_stdouterr( &lh, priority, str );
 1314|  1.58k|#endif /* NETSNMP_FEATURE_REMOVE_LOGGING_STDIO */
 1315|       |
 1316|  1.58k|        return;
 1317|  1.58k|    }
 1318|      0|#ifndef NETSNMP_FEATURE_REMOVE_LOGGING_STDIO
 1319|      0|    else if (stderr_enabled) {
  ------------------
  |  Branch (1319:14): [True: 0, False: 0]
  ------------------
 1320|      0|        stderr_enabled = 0;
 1321|      0|        log_handler_stdouterr( &lh, LOG_INFO,
 1322|      0|                               "Log handling defined - disabling stderr\n" );
 1323|      0|    }
 1324|      0|#endif /* NETSNMP_FEATURE_REMOVE_LOGGING_STDIO */
 1325|       |        
 1326|       |
 1327|       |    /*
 1328|       |     * Start at the given priority, and work "upwards"....
 1329|       |     */
 1330|      0|    if (priority < LOG_EMERG)
  ------------------
  |  Branch (1330:9): [True: 0, False: 0]
  ------------------
 1331|      0|        priority = LOG_EMERG;
 1332|      0|    else if (priority > LOG_DEBUG)
  ------------------
  |  Branch (1332:14): [True: 0, False: 0]
  ------------------
 1333|      0|        priority = LOG_DEBUG;
 1334|      0|    logh = logh_priorities[priority];
 1335|      0|    for ( ; logh; logh = logh->next ) {
  ------------------
  |  Branch (1335:13): [True: 0, False: 0]
  ------------------
 1336|       |        /*
 1337|       |         * ... but skipping any handlers with a "maximum priority"
 1338|       |         *     that we have already exceeded. And don't forget to
 1339|       |         *     ensure this logging is turned on (see snmp_disable_stderrlog
 1340|       |         *     and its cohorts).
 1341|       |         */
 1342|      0|        if (logh->enabled && priority >= logh->pri_max)
  ------------------
  |  Branch (1342:13): [True: 0, False: 0]
  |  Branch (1342:30): [True: 0, False: 0]
  ------------------
 1343|      0|            logh->handler( logh, priority, str );
 1344|      0|    }
 1345|      0|}
snmp_vlog:
 1383|  1.58k|{
 1384|  1.58k|    char           *buffer = NULL;
 1385|  1.58k|    int             length;
 1386|       |
 1387|  1.58k|    length = vasprintf(&buffer, format, ap);
 1388|  1.58k|    if (length < 0) {
  ------------------
  |  Branch (1388:9): [True: 0, False: 1.58k]
  ------------------
 1389|      0|        snmp_log_string(LOG_ERR, "Could not format log-string\n");
 1390|      0|        return -1;
 1391|      0|    }
 1392|       |
 1393|  1.58k|    snmp_log_string(priority, buffer);
 1394|  1.58k|    free(buffer);
 1395|  1.58k|    return 0;
 1396|  1.58k|}
snmp_log:
 1407|  1.58k|{
 1408|  1.58k|    va_list         ap;
 1409|  1.58k|    int             ret;
 1410|  1.58k|    va_start(ap, format);
 1411|  1.58k|    ret = snmp_vlog(priority, format, ap);
 1412|       |    va_end(ap);
 1413|  1.58k|    return (ret);
 1414|  1.58k|}

netsnmp_init_openssl:
  118|      4|void netsnmp_init_openssl(void) {
  119|       |
  120|       |    /* avoid duplicate calls */
  121|      4|    if (have_started_already)
  ------------------
  |  Branch (121:9): [True: 2, False: 2]
  ------------------
  122|      2|        return;
  123|      2|    have_started_already = 1;
  124|       |
  125|      2|    DEBUGMSGTL(("snmp_openssl", "initializing\n"));
  ------------------
  |  |   66|      2|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      2|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 2]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 2]
  |  |  ------------------
  ------------------
  126|       |
  127|       |    /* Initializing OpenSSL */
  128|      2|#ifdef HAVE_SSL_LIBRARY_INIT
  129|      2|    SSL_library_init();
  130|      2|#endif
  131|      2|#ifdef HAVE_SSL_LOAD_ERROR_STRINGS
  132|      2|    SSL_load_error_strings();
  133|      2|#endif
  134|       |#ifdef HAVE_ERR_LOAD_BIO_STRINGS
  135|       |    ERR_load_BIO_strings();
  136|       |#endif
  137|      2|#ifdef HAVE_OPENSSL_ADD_ALL_ALGORITHMS
  138|       |    OpenSSL_add_all_algorithms();
  139|      2|#endif
  140|      2|}

init_secmod:
   48|      2|{
   49|      2|    snmp_register_callback(SNMP_CALLBACK_LIBRARY,
  ------------------
  |  |   18|      2|#define SNMP_CALLBACK_LIBRARY     0
  ------------------
   50|      2|                           SNMP_CALLBACK_SESSION_INIT, set_default_secmod,
  ------------------
  |  |   29|      2|#define SNMP_CALLBACK_SESSION_INIT		5
  ------------------
   51|      2|                           NULL);
   52|       |
   53|      2|    netsnmp_ds_register_config(ASN_OCTET_STR, "snmp", "defSecurityModel",
  ------------------
  |  |   78|      2|#define ASN_OCTET_STR	    0x04U
  ------------------
   54|      2|			       NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_SECMODEL);
  ------------------
  |  |   48|      2|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
              			       NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_SECMODEL);
  ------------------
  |  |  161|      2|#define NETSNMP_DS_LIB_SECMODEL          10
  ------------------
   55|       |    /*
   56|       |     * this file is generated by configure for all the stuff we're using 
   57|       |     */
   58|      2|#include "snmpsm_init.h"
  ------------------
  |  |    1|       |/* This file is automatically generated by configure.  Do not modify by hand. */
  |  |    2|      2|init_usm();
  |  |    3|      2|init_tsm();
  |  |    4|      2|init_ksm();
  ------------------
   59|      2|}
register_sec_mod:
   70|      6|{
   71|      6|    int             result = 0;
   72|      6|    struct snmp_secmod_list *sptr;
   73|      6|    char           *othername, *modname2 = NULL;
   74|       |
   75|     12|    for (sptr = registered_services; sptr; sptr = sptr->next) {
  ------------------
  |  Branch (75:38): [True: 6, False: 6]
  ------------------
   76|      6|        if (sptr->securityModel == secmod) {
  ------------------
  |  Branch (76:13): [True: 0, False: 6]
  ------------------
   77|      0|            return SNMPERR_GENERR;
  ------------------
  |  |  185|      0|#define SNMPERR_GENERR			(-1)
  ------------------
   78|      0|        }
   79|      6|    }
   80|      6|    sptr = SNMP_MALLOC_STRUCT(snmp_secmod_list);
  ------------------
  |  |   69|      6|#define SNMP_MALLOC_STRUCT(s)   (struct s *) calloc(1, sizeof(struct s))
  ------------------
   81|      6|    if (sptr == NULL)
  ------------------
  |  Branch (81:9): [True: 0, False: 6]
  ------------------
   82|      0|        return SNMPERR_MALLOC;
  ------------------
  |  |  246|      0|#define SNMPERR_MALLOC			(-62)
  ------------------
   83|      6|    sptr->secDef = newdef;
   84|      6|    sptr->securityModel = secmod;
   85|      6|    sptr->next = registered_services;
   86|      6|    registered_services = sptr;
   87|      6|    modname2 = strdup(modname);
   88|      6|    if (!modname2)
  ------------------
  |  Branch (88:9): [True: 0, False: 6]
  ------------------
   89|      0|        result = SE_NOMEM;
  ------------------
  |  |   43|      0|#define SE_NOMEM         1
  ------------------
   90|      6|    else
   91|      6|        result = se_add_pair_to_slist("snmp_secmods", modname2, secmod);
   92|      6|    if (result != SE_OK) {
  ------------------
  |  |   42|      6|#define SE_OK            0
  ------------------
  |  Branch (92:9): [True: 0, False: 6]
  ------------------
   93|      0|        switch (result) {
   94|      0|        case SE_NOMEM:
  ------------------
  |  |   43|      0|#define SE_NOMEM         1
  ------------------
  |  Branch (94:9): [True: 0, False: 0]
  ------------------
   95|      0|            snmp_log(LOG_CRIT, "snmp_secmod: no memory\n");
   96|      0|            break;
   97|       |
   98|      0|        case SE_ALREADY_THERE:
  ------------------
  |  |   44|      0|#define SE_ALREADY_THERE 2
  ------------------
  |  Branch (98:9): [True: 0, False: 0]
  ------------------
   99|      0|            othername = se_find_label_in_slist("snmp_secmods", secmod);
  100|      0|            if (strcmp(othername, modname) != 0) {
  ------------------
  |  Branch (100:17): [True: 0, False: 0]
  ------------------
  101|      0|                snmp_log(LOG_ERR,
  102|      0|                         "snmp_secmod: two security modules %s and %s registered with the same security number\n",
  103|      0|                         modname, othername);
  104|      0|            }
  105|      0|            break;
  106|       |
  107|      0|        default:
  ------------------
  |  Branch (107:9): [True: 0, False: 0]
  ------------------
  108|      0|            snmp_log(LOG_ERR,
  109|      0|                     "snmp_secmod: unknown error trying to register a new security module\n");
  110|      0|            break;
  111|      0|        }
  112|      0|        return SNMPERR_GENERR;
  ------------------
  |  |  185|      0|#define SNMPERR_GENERR			(-1)
  ------------------
  113|      0|    }
  114|      6|    return SNMPERR_SUCCESS;
  ------------------
  |  |  184|      6|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
  115|      6|}
find_sec_mod:
  160|  11.7k|{
  161|  11.7k|    struct snmp_secmod_list *sptr;
  162|       |
  163|  39.9k|    for (sptr = registered_services; sptr; sptr = sptr->next) {
  ------------------
  |  Branch (163:38): [True: 34.6k, False: 5.25k]
  ------------------
  164|  34.6k|        if (sptr->securityModel == secmod) {
  ------------------
  |  Branch (164:13): [True: 6.48k, False: 28.1k]
  ------------------
  165|  6.48k|            return sptr->secDef;
  166|  6.48k|        }
  167|  34.6k|    }
  168|       |    /*
  169|       |     * not registered 
  170|       |     */
  171|  5.25k|    return NULL;
  172|  11.7k|}

netsnmp_register_default_domain:
   60|      4|{
   61|      4|    struct netsnmp_lookup_domain *run = domains, *prev = NULL;
   62|      4|    int res = 0;
   63|       |
   64|      6|    while (run != NULL && strcmp(run->application, application) < 0) {
  ------------------
  |  Branch (64:12): [True: 2, False: 4]
  |  Branch (64:27): [True: 2, False: 0]
  ------------------
   65|      2|	prev = run;
   66|      2|	run = run->next;
   67|      2|    }
   68|      4|    if (run && strcmp(run->application, application) == 0) {
  ------------------
  |  Branch (68:9): [True: 0, False: 4]
  |  Branch (68:16): [True: 0, False: 0]
  ------------------
   69|      0|      if (run->domain != NULL) {
  ------------------
  |  Branch (69:11): [True: 0, False: 0]
  ------------------
   70|      0|          destroy_word_array(run->domain);
   71|      0|	  run->domain = NULL;
   72|      0|	  res = 1;
   73|      0|      }
   74|      4|    } else {
   75|      4|	run = SNMP_MALLOC_STRUCT(netsnmp_lookup_domain);
  ------------------
  |  |   69|      4|#define SNMP_MALLOC_STRUCT(s)   (struct s *) calloc(1, sizeof(struct s))
  ------------------
   76|      4|	run->application = strdup(application);
   77|      4|	run->userDomain = NULL;
   78|      4|	if (prev) {
  ------------------
  |  Branch (78:6): [True: 2, False: 2]
  ------------------
   79|      2|	    run->next = prev->next;
   80|      2|	    prev->next = run;
   81|      2|	} else {
   82|      2|	    run->next = domains;
   83|      2|	    domains = run;
   84|      2|	}
   85|      4|    }
   86|      4|    if (domain) {
  ------------------
  |  Branch (86:9): [True: 4, False: 0]
  ------------------
   87|      4|        run->domain = create_word_array(domain);
   88|      4|    } else if (run->userDomain == NULL) {
  ------------------
  |  Branch (88:16): [True: 0, False: 0]
  ------------------
   89|      0|	if (prev)
  ------------------
  |  Branch (89:6): [True: 0, False: 0]
  ------------------
   90|      0|	    prev->next = run->next;
   91|      0|	else
   92|      0|	    domains = run->next;
   93|      0|	free(run->application);
   94|      0|	free(run);
   95|      0|    }
   96|      4|    return res;
   97|      4|}
netsnmp_register_default_target:
  248|     28|{
  249|     28|    struct netsnmp_lookup_target *run = targets, *prev = NULL;
  250|     28|    int i = 0, res = 0;
  251|    154|    while (run && ((i = strcmp(run->application, application)) < 0 ||
  ------------------
  |  Branch (251:12): [True: 146, False: 8]
  |  Branch (251:20): [True: 98, False: 48]
  ------------------
  252|    126|		   (i == 0 && strcmp(run->domain, domain) < 0))) {
  ------------------
  |  Branch (252:7): [True: 48, False: 0]
  |  Branch (252:17): [True: 28, False: 20]
  ------------------
  253|    126|	prev = run;
  254|    126|	run = run->next;
  255|    126|    }
  256|     28|    if (run && i == 0 && strcmp(run->domain, domain) == 0) {
  ------------------
  |  Branch (256:9): [True: 20, False: 8]
  |  Branch (256:16): [True: 20, False: 0]
  |  Branch (256:26): [True: 0, False: 20]
  ------------------
  257|      0|      if (run->target != NULL) {
  ------------------
  |  Branch (257:11): [True: 0, False: 0]
  ------------------
  258|      0|	    free(run->target);
  259|      0|	    run->target = NULL;
  260|      0|	    res = 1;
  261|      0|      }
  262|     28|    } else {
  263|     28|	run = SNMP_MALLOC_STRUCT(netsnmp_lookup_target);
  ------------------
  |  |   69|     28|#define SNMP_MALLOC_STRUCT(s)   (struct s *) calloc(1, sizeof(struct s))
  ------------------
  264|     28|	run->application = strdup(application);
  265|     28|	run->domain = strdup(domain);
  266|     28|	run->userTarget = NULL;
  267|     28|	if (prev) {
  ------------------
  |  Branch (267:6): [True: 22, False: 6]
  ------------------
  268|     22|	    run->next = prev->next;
  269|     22|	    prev->next = run;
  270|     22|	} else {
  271|      6|	    run->next = targets;
  272|      6|	    targets = run;
  273|      6|	}
  274|     28|    }
  275|     28|    if (target) {
  ------------------
  |  Branch (275:9): [True: 28, False: 0]
  ------------------
  276|     28|	run->target = strdup(target);
  277|     28|    } else if (run->userTarget == NULL) {
  ------------------
  |  Branch (277:16): [True: 0, False: 0]
  ------------------
  278|      0|	if (prev)
  ------------------
  |  Branch (278:6): [True: 0, False: 0]
  ------------------
  279|      0|	    prev->next = run->next;
  280|      0|	else
  281|      0|	    targets = run->next;
  282|      0|	free(run->domain);
  283|      0|	free(run->application);
  284|      0|	free(run);
  285|      0|    }
  286|     28|    return res;
  287|     28|}
netsnmp_register_service_handlers:
  426|      2|{
  427|      2|    register_config_handler("snmp:", "defDomain",
  428|      2|			    netsnmp_register_user_domain,
  429|      2|			    netsnmp_clear_user_domain,
  430|      2|			    "application domain");
  431|      2|    register_config_handler("snmp:", "defTarget",
  432|      2|			    netsnmp_register_user_target,
  433|      2|			    netsnmp_clear_user_target,
  434|      2|			    "application domain target");
  435|      2|}
snmp_service.c:create_word_array:
   28|      4|{
   29|      4|    size_t tmplen = strlen(cptr);
   30|      4|    char* tmp = (char*)malloc(tmplen + 1);
   31|      4|    char** res = create_word_array_helper(cptr, 0, tmp, tmplen + 1);
   32|      4|    free(tmp);
   33|      4|    return res;
   34|      4|}
snmp_service.c:create_word_array_helper:
   11|      8|{
   12|      8|    char* item;
   13|      8|    char** res;
   14|      8|    cptr = copy_nword_const(cptr, tmp, tmplen);
   15|      8|    item = strdup(tmp);
   16|      8|    if (cptr)
  ------------------
  |  Branch (16:9): [True: 4, False: 4]
  ------------------
   17|      4|        res = create_word_array_helper(cptr, idx + 1, tmp, tmplen);
   18|      4|    else {
   19|      4|        res = (char**)malloc(sizeof(char*) * (idx + 2));
   20|       |        res[idx + 1] = NULL;
   21|      4|    }
   22|      8|    res[idx] = item;
   23|      8|    return res;
   24|      8|}
snmp_service.c:netsnmp_clear_user_domain:
  161|      4|{
  162|      4|    struct netsnmp_lookup_domain *run = domains, *prev = NULL;
  163|       |
  164|     12|    while (run) {
  ------------------
  |  Branch (164:12): [True: 8, False: 4]
  ------------------
  165|      8|	if (run->userDomain != NULL) {
  ------------------
  |  Branch (165:6): [True: 0, False: 8]
  ------------------
  166|      0|            destroy_word_array(run->userDomain);
  167|      0|	    run->userDomain = NULL;
  168|      0|	}
  169|      8|	if (run->domain == NULL) {
  ------------------
  |  Branch (169:6): [True: 0, False: 8]
  ------------------
  170|      0|	    struct netsnmp_lookup_domain *tmp = run;
  171|      0|	    if (prev)
  ------------------
  |  Branch (171:10): [True: 0, False: 0]
  ------------------
  172|      0|		run = prev->next = run->next;
  173|      0|	    else
  174|      0|		run = domains = run->next;
  175|      0|	    free(tmp->application);
  176|      0|	    free(tmp);
  177|      8|	} else {
  178|      8|	    prev = run;
  179|      8|	    run = run->next;
  180|      8|	}
  181|      8|    }
  182|      4|}
snmp_service.c:netsnmp_clear_user_target:
  371|      4|{
  372|      4|    struct netsnmp_lookup_target *run = targets, *prev = NULL;
  373|       |
  374|     60|    while (run) {
  ------------------
  |  Branch (374:12): [True: 56, False: 4]
  ------------------
  375|     56|	if (run->userTarget != NULL) {
  ------------------
  |  Branch (375:6): [True: 0, False: 56]
  ------------------
  376|      0|	    free(run->userTarget);
  377|      0|	    run->userTarget = NULL;
  378|      0|	}
  379|     56|	if (run->target == NULL) {
  ------------------
  |  Branch (379:6): [True: 0, False: 56]
  ------------------
  380|      0|	    struct netsnmp_lookup_target *tmp = run;
  381|      0|	    if (prev)
  ------------------
  |  Branch (381:10): [True: 0, False: 0]
  ------------------
  382|      0|		run = prev->next = run->next;
  383|      0|	    else
  384|      0|		run = targets = run->next;
  385|      0|	    free(tmp->application);
  386|      0|	    free(tmp->domain);
  387|      0|	    free(tmp);
  388|     56|	} else {
  389|     56|	    prev = run;
  390|     56|	    run = run->next;
  391|     56|	}
  392|     56|    }
  393|      4|}

init_snmp_transport:
  124|      2|{
  125|      2|    netsnmp_ds_register_config(ASN_BOOLEAN,
  ------------------
  |  |   72|      2|#define ASN_BOOLEAN	    0x01U
  ------------------
  126|      2|                               "snmp", "dontLoadHostConfig",
  127|      2|                               NETSNMP_DS_LIBRARY_ID,
  ------------------
  |  |   48|      2|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  128|      2|                               NETSNMP_DS_LIB_DONT_LOAD_HOST_FILES);
  ------------------
  |  |  100|      2|#define NETSNMP_DS_LIB_DONT_LOAD_HOST_FILES 40 /* don't read host.conf files */
  ------------------
  129|      2|#ifndef NETSNMP_FEATURE_REMOVE_FILTER_SOURCE
  130|      2|    register_app_config_handler("sourceFilterType",
  131|      2|                                netsnmp_transport_parse_filterType,
  132|       |                                NULL, "none|whitelist|blacklist");
  133|      2|    register_app_config_handler("sourceFilterAddress",
  134|      2|                                netsnmp_transport_parse_filter,
  135|      2|                                netsnmp_transport_filter_cleanup,
  136|      2|                                "host");
  137|      2|#endif /* NETSNMP_FEATURE_REMOVE_FILTER_SOURCE */
  138|      2|}
netsnmp_transport_filter_cleanup:
  381|      2|{
  382|      2|    if (NULL == filtered)
  ------------------
  |  Branch (382:9): [True: 2, False: 0]
  ------------------
  383|      2|        return;
  384|      0|    CONTAINER_CLEAR(filtered, filtered->free_item, NULL);
  385|      0|    CONTAINER_FREE(filtered);
  386|       |    filtered = NULL;
  387|      0|}
netsnmp_tdomain_init:
  503|      2|{
  504|      2|    DEBUGMSGTL(("tdomain", "netsnmp_tdomain_init() called\n"));
  ------------------
  |  |   66|      2|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      2|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 2]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 2]
  |  |  ------------------
  ------------------
  505|       |
  506|       |/* include the configure generated list of constructor calls */
  507|      2|#include "transports/snmp_transport_inits.h"
  ------------------
  |  |    1|       |/* This file is automatically generated by configure.  Do not modify by hand. */
  |  |    2|      2|netsnmp_tlsbase_ctor();
  |  |    3|      2|netsnmp_tlstcp_ctor();
  |  |    4|      2|netsnmp_dtlsudp_ctor();
  |  |    5|      2|netsnmp_udpshared_ctor();
  |  |    6|      2|netsnmp_std_ctor();
  |  |    7|      2|netsnmp_ipx_ctor();
  |  |    8|      2|netsnmp_aal5pvc_ctor();
  |  |    9|      2|netsnmp_udpipv6_ctor();
  |  |   10|      2|netsnmp_tcpipv6_ctor();
  |  |   11|      2|netsnmp_udp_ctor();
  |  |   12|      2|netsnmp_tcp_ctor();
  |  |   13|      2|netsnmp_alias_ctor();
  |  |   14|      2|netsnmp_unix_ctor();
  ------------------
  508|       |
  509|      2|    netsnmp_tdomain_dump();
  510|       |
  511|       |
  512|      2|}
netsnmp_tdomain_register:
  554|     24|{
  555|     24|    netsnmp_tdomain **prevNext = &domain_list, *d;
  556|       |
  557|     24|    if (n != NULL) {
  ------------------
  |  Branch (557:9): [True: 24, False: 0]
  ------------------
  558|    156|        for (d = domain_list; d != NULL; d = d->next) {
  ------------------
  |  Branch (558:31): [True: 132, False: 24]
  ------------------
  559|    132|            if (netsnmp_oid_equals(n->name, n->name_length,
  ------------------
  |  Branch (559:17): [True: 0, False: 132]
  ------------------
  560|    132|                                d->name, d->name_length) == 0) {
  561|       |                /*
  562|       |                 * Already registered.  
  563|       |                 */
  564|      0|                return 0;
  565|      0|            }
  566|    132|            prevNext = &(d->next);
  567|    132|        }
  568|     24|        n->next = NULL;
  569|     24|        *prevNext = n;
  570|     24|        return 1;
  571|     24|    } else {
  572|      0|        return 0;
  573|      0|    }
  574|     24|}
snmp_transport.c:netsnmp_tdomain_dump:
  532|      2|{
  533|      2|    netsnmp_tdomain *d;
  534|      2|    int i = 0;
  535|       |
  536|      2|    DEBUGMSGTL(("tdomain", "domain_list -> "));
  ------------------
  |  |   66|      2|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      2|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 2]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 2]
  |  |  ------------------
  ------------------
  537|     26|    for (d = domain_list; d != NULL; d = d->next) {
  ------------------
  |  Branch (537:27): [True: 24, False: 2]
  ------------------
  538|     24|        DEBUGMSG(("tdomain", "{ "));
  ------------------
  |  |   61|     24|#define DEBUGMSG(x)        do {if (_DBG_IF_) {debugmsg x;} }while(0)
  |  |  ------------------
  |  |  |  |  144|     24|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 24]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (61:67): [Folded, False: 24]
  |  |  ------------------
  ------------------
  539|     24|        DEBUGMSGOID(("tdomain", d->name, d->name_length));
  ------------------
  |  |   67|     24|#define DEBUGMSGOID(x)     do {if (_DBG_IF_) {__DBGMSGOID(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     24|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 24]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGOID(x)     do {if (_DBG_IF_) {__DBGMSGOID(x);} }while(0)
  |  |  ------------------
  |  |  |  |  165|      0|#define __DBGMSGOID(x)     debugmsg_oid x
  |  |  ------------------
  |  |  |  Branch (67:71): [Folded, False: 24]
  |  |  ------------------
  ------------------
  540|     24|        DEBUGMSG(("tdomain", ", \""));
  ------------------
  |  |   61|     24|#define DEBUGMSG(x)        do {if (_DBG_IF_) {debugmsg x;} }while(0)
  |  |  ------------------
  |  |  |  |  144|     24|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 24]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (61:67): [Folded, False: 24]
  |  |  ------------------
  ------------------
  541|     68|        for (i = 0; d->prefix[i] != NULL; i++) {
  ------------------
  |  Branch (541:21): [True: 44, False: 24]
  ------------------
  542|     44|            DEBUGMSG(("tdomain", "%s%s", d->prefix[i],
  ------------------
  |  |   61|     44|#define DEBUGMSG(x)        do {if (_DBG_IF_) {debugmsg x;} }while(0)
  |  |  ------------------
  |  |  |  |  144|     44|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 44]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (61:56): [True: 0, False: 0]
  |  |  |  Branch (61:67): [Folded, False: 44]
  |  |  ------------------
  ------------------
  543|     44|		      (d->prefix[i + 1]) ? "/" : ""));
  544|     44|        }
  545|     24|        DEBUGMSG(("tdomain", "\" } -> "));
  ------------------
  |  |   61|     24|#define DEBUGMSG(x)        do {if (_DBG_IF_) {debugmsg x;} }while(0)
  |  |  ------------------
  |  |  |  |  144|     24|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 24]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (61:67): [Folded, False: 24]
  |  |  ------------------
  ------------------
  546|     24|    }
  547|      2|    DEBUGMSG(("tdomain", "[NIL]\n"));
  ------------------
  |  |   61|      2|#define DEBUGMSG(x)        do {if (_DBG_IF_) {debugmsg x;} }while(0)
  |  |  ------------------
  |  |  |  |  144|      2|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 2]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (61:67): [Folded, False: 2]
  |  |  ------------------
  ------------------
  548|      2|}

init_ksm:
  218|      2|{
  219|      2|    krb5_error_code retval;
  220|      2|    struct snmp_secmod_def *def;
  221|      2|    int             i;
  222|       |
  223|      2|    netsnmp_ds_register_config(ASN_OCTET_STR, "snmp", "defKSMKeytab",
  ------------------
  |  |   78|      2|#define ASN_OCTET_STR	    0x04U
  ------------------
  224|      2|                               NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_KSM_KEYTAB);
  ------------------
  |  |   48|      2|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
                                             NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_KSM_KEYTAB);
  ------------------
  |  |  172|      2|#define NETSNMP_DS_LIB_KSM_KEYTAB        21
  ------------------
  225|      2|    netsnmp_ds_register_config(ASN_OCTET_STR, "snmp", "defKSMServiceName",
  ------------------
  |  |   78|      2|#define ASN_OCTET_STR	    0x04U
  ------------------
  226|      2|                               NETSNMP_DS_LIBRARY_ID,
  ------------------
  |  |   48|      2|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  227|      2|			       NETSNMP_DS_LIB_KSM_SERVICE_NAME);
  ------------------
  |  |  173|      2|#define NETSNMP_DS_LIB_KSM_SERVICE_NAME  22
  ------------------
  228|      2|    snmp_register_callback(SNMP_CALLBACK_LIBRARY,
  ------------------
  |  |   18|      2|#define SNMP_CALLBACK_LIBRARY     0
  ------------------
  229|      2|			   SNMP_CALLBACK_POST_READ_CONFIG,
  ------------------
  |  |   24|      2|#define SNMP_CALLBACK_POST_READ_CONFIG	        0
  ------------------
  230|      2|			   init_snmpksm_post_config, NULL);
  231|       |
  232|       |
  233|      2|    if (kcontext == NULL) {
  ------------------
  |  Branch (233:9): [True: 2, False: 0]
  ------------------
  234|      2|        retval = krb5_init_context(&kcontext);
  235|       |
  236|      2|        if (retval) {
  ------------------
  |  Branch (236:13): [True: 0, False: 2]
  ------------------
  237|      0|            DEBUGMSGTL(("ksm", "krb5_init_context failed (%s), not "
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
  238|      0|                        "registering KSM\n", error_message(retval)));
  239|      0|            return;
  240|      0|        }
  241|      2|    }
  242|       |
  243|    130|    for (i = 0; i < HASHSIZE; i++)
  ------------------
  |  |  129|    130|#define HASHSIZE	64
  ------------------
  |  Branch (243:17): [True: 128, False: 2]
  ------------------
  244|    128|        ksm_hash_table[i] = NULL;
  245|       |
  246|      2|    def = SNMP_MALLOC_STRUCT(snmp_secmod_def);
  ------------------
  |  |   69|      2|#define SNMP_MALLOC_STRUCT(s)   (struct s *) calloc(1, sizeof(struct s))
  ------------------
  247|       |
  248|      2|    if (!def) {
  ------------------
  |  Branch (248:9): [True: 0, False: 2]
  ------------------
  249|      0|        DEBUGMSGTL(("ksm", "Unable to malloc snmp_secmod struct, not "
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
  250|      0|                    "registering KSM\n"));
  251|      0|        return;
  252|      0|    }
  253|       |
  254|      2|    def->encode_reverse = ksm_rgenerate_out_msg;
  255|      2|    def->decode = ksm_process_in_msg;
  256|      2|    def->session_open = ksm_session_init;
  257|      2|    def->pdu_free_state_ref = ksm_free_state_ref;
  258|      2|    def->pdu_free = ksm_free_pdu;
  259|      2|    def->pdu_clone = ksm_clone_pdu;
  260|       |
  261|      2|    register_sec_mod(NETSNMP_SEC_MODEL_KSM, "ksm", def);
  ------------------
  |  |   13|      2|#define NETSNMP_SEC_MODEL_KSM     2066432
  ------------------
  262|      2|}
ksm_process_in_msg:
 1243|     94|{
 1244|     94|    long            temp;
 1245|     94|    krb5_cksumtype  cksumtype;
 1246|     94|    krb5_auth_context auth_context = NULL;
 1247|     94|    krb5_error_code retcode;
 1248|     94|    krb5_checksum   checksum;
 1249|     94|    krb5_data       ap_req, ivector;
 1250|     94|    krb5_flags      flags;
 1251|     94|    krb5_keyblock  *subkey = NULL;
 1252|     94|#ifdef NETSNMP_USE_KERBEROS_MIT
 1253|     94|    krb5_data       input, output;
 1254|     94|    krb5_boolean    valid;
 1255|     94|    krb5_enc_data   in_crypt;
 1256|       |#elif defined OLD_HEIMDAL	/* NETSNMP_USE_KERBEROS_MIT */
 1257|       |    krb5_data output;
 1258|       |    krb5_crypto heim_crypto = NULL;
 1259|       |#else                           /* NETSNMP_USE_KERBEROS_MIT */
 1260|       |    krb5_encrypt_block eblock;
 1261|       |#endif                          /* NETSNMP_USE_KERBEROS_MIT */
 1262|     94|    krb5_ticket    *ticket = NULL;
 1263|     94|    int             retval = SNMPERR_SUCCESS, response = 0;
  ------------------
  |  |  184|     94|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
 1264|     94|    size_t          length =
 1265|     94|        parms->wholeMsgLen - (u_int) (parms->secParams - parms->wholeMsg);
 1266|     94|    u_char         *current = parms->secParams, type;
 1267|     94|#ifndef OLD_HEIMDAL
 1268|     94|    size_t          blocksize;
 1269|     94|#endif
 1270|     94|    size_t          cksumlength;
 1271|     94|    long            hint;
 1272|     94|    char           *cname;
 1273|     94|    struct ksm_secStateRef *ksm_state;
 1274|     94|    struct ksm_cache_entry *entry;
 1275|       |
 1276|     94|    DEBUGMSGTL(("ksm", "Processing has begun\n"));
  ------------------
  |  |   66|     94|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     94|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 94]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 94]
  |  |  ------------------
  ------------------
 1277|       |
 1278|     94|    CHECKSUM_CONTENTS(&checksum) = NULL;
  ------------------
  |  |   60|     94|#define CHECKSUM_CONTENTS(x)	(x)->contents
  ------------------
 1279|     94|    ap_req.data = NULL;
 1280|     94|    ivector.length = 0;
 1281|     94|    ivector.data = NULL;
 1282|       |
 1283|       |    /*
 1284|       |     * First, parse the security parameters (because we need the subkey inside
 1285|       |     * of the ticket to do anything
 1286|       |     */
 1287|       |
 1288|     94|    if ((current = asn_parse_sequence(current, &length, &type,
  ------------------
  |  Branch (1288:9): [True: 5, False: 89]
  ------------------
 1289|     94|                                      (ASN_UNIVERSAL | ASN_PRIMITIVE |
  ------------------
  |  |   90|     94|#define ASN_UNIVERSAL	    0x00U
  ------------------
                                                    (ASN_UNIVERSAL | ASN_PRIMITIVE |
  ------------------
  |  |   95|     94|#define ASN_PRIMITIVE	    0x00U
  ------------------
 1290|     94|                                       ASN_OCTET_STR),
  ------------------
  |  |   78|     94|#define ASN_OCTET_STR	    0x04U
  ------------------
 1291|     94|                                      "ksm first octet")) == NULL) {
 1292|      5|        DEBUGMSGTL(("ksm", "Initial security paramter parsing failed\n"));
  ------------------
  |  |   66|      5|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      5|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 5]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 5]
  |  |  ------------------
  ------------------
 1293|       |
 1294|      5|        retval = SNMPERR_ASN_PARSE_ERR;
  ------------------
  |  |  213|      5|#define SNMPERR_ASN_PARSE_ERR           (-29)
  ------------------
 1295|      5|        goto error;
 1296|      5|    }
 1297|       |
 1298|     89|    if ((current = asn_parse_sequence(current, &length, &type,
  ------------------
  |  Branch (1298:9): [True: 5, False: 84]
  ------------------
 1299|     89|                                      (ASN_SEQUENCE | ASN_CONSTRUCTOR),
  ------------------
  |  |   84|     89|#define ASN_SEQUENCE	    0x10U
  ------------------
                                                    (ASN_SEQUENCE | ASN_CONSTRUCTOR),
  ------------------
  |  |   96|     89|#define ASN_CONSTRUCTOR	    0x20U
  ------------------
 1300|     89|                                      "ksm sequence")) == NULL) {
 1301|      5|        DEBUGMSGTL(("ksm",
  ------------------
  |  |   66|      5|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      5|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 5]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 5]
  |  |  ------------------
  ------------------
 1302|      5|                    "Security parameter sequence parsing failed\n"));
 1303|       |
 1304|      5|        retval = SNMPERR_ASN_PARSE_ERR;
  ------------------
  |  |  213|      5|#define SNMPERR_ASN_PARSE_ERR           (-29)
  ------------------
 1305|      5|        goto error;
 1306|      5|    }
 1307|       |
 1308|     84|    if ((current = asn_parse_int(current, &length, &type, &temp,
  ------------------
  |  Branch (1308:9): [True: 1, False: 83]
  ------------------
 1309|     84|                                 sizeof(temp))) == NULL) {
 1310|      1|        DEBUGMSGTL(("ksm", "Security parameter checksum type parsing"
  ------------------
  |  |   66|      1|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      1|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 1]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 1]
  |  |  ------------------
  ------------------
 1311|      1|                    "failed\n"));
 1312|       |
 1313|      1|        retval = SNMPERR_ASN_PARSE_ERR;
  ------------------
  |  |  213|      1|#define SNMPERR_ASN_PARSE_ERR           (-29)
  ------------------
 1314|      1|        goto error;
 1315|      1|    }
 1316|       |
 1317|     83|    cksumtype = temp;
 1318|       |
 1319|     83|#ifdef NETSNMP_USE_KERBEROS_MIT
 1320|     83|    if (!krb5_c_valid_cksumtype(cksumtype)) {
  ------------------
  |  Branch (1320:9): [True: 1, False: 82]
  ------------------
 1321|      1|        DEBUGMSGTL(("ksm", "Invalid checksum type (%d)\n", cksumtype));
  ------------------
  |  |   66|      1|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      1|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 1]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 1]
  |  |  ------------------
  ------------------
 1322|       |
 1323|      1|        retval = SNMPERR_KRB5;
  ------------------
  |  |  247|      1|#define SNMPERR_KRB5			(-63)
  ------------------
 1324|      1|        snmp_set_detail("Invalid checksum type");
 1325|      1|        goto error;
 1326|      1|    }
 1327|       |
 1328|     82|    if (!krb5_c_is_keyed_cksum(cksumtype)) {
  ------------------
  |  Branch (1328:9): [True: 1, False: 81]
  ------------------
 1329|      1|        DEBUGMSGTL(("ksm", "Checksum type %d is not a keyed checksum\n",
  ------------------
  |  |   66|      1|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      1|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 1]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 1]
  |  |  ------------------
  ------------------
 1330|      1|                    cksumtype));
 1331|      1|        snmp_set_detail("Checksum is not a keyed checksum");
 1332|      1|        retval = SNMPERR_KRB5;
  ------------------
  |  |  247|      1|#define SNMPERR_KRB5			(-63)
  ------------------
 1333|      1|        goto error;
 1334|      1|    }
 1335|       |
 1336|     81|    if (!krb5_c_is_coll_proof_cksum(cksumtype)) {
  ------------------
  |  Branch (1336:9): [True: 0, False: 81]
  ------------------
 1337|      0|        DEBUGMSGTL(("ksm", "Checksum type %d is not a collision-proof "
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1338|      0|                    "checksum\n", cksumtype));
 1339|      0|        snmp_set_detail("Checksum is not a collision-proof checksum");
 1340|      0|        retval = SNMPERR_KRB5;
  ------------------
  |  |  247|      0|#define SNMPERR_KRB5			(-63)
  ------------------
 1341|      0|        goto error;
 1342|      0|    }
 1343|       |#else /* ! NETSNMP_USE_KERBEROS_MIT */
 1344|       |#ifdef OLD_HEIMDAL
 1345|       |    /* kludge */
 1346|       |    if (krb5_checksumsize(kcontext, cksumtype, &cksumlength)) {
 1347|       |#else					/* OLD_HEIMDAL */
 1348|       |    if (!valid_cksumtype(cksumtype)) {
 1349|       |#endif					/* OLD_HEIMDAL */
 1350|       |        DEBUGMSGTL(("ksm", "Invalid checksum type (%d)\n", cksumtype));
 1351|       |
 1352|       |        retval = SNMPERR_KRB5;
 1353|       |        snmp_set_detail("Invalid checksum type");
 1354|       |        goto error;
 1355|       |    }
 1356|       |
 1357|       |#ifdef OLD_HEIMDAL
 1358|       |    if (!krb5_checksum_is_keyed(kcontext, cksumtype)) {
 1359|       |#else					/* OLD_HEIMDAL */
 1360|       |    if (!is_keyed_cksum(cksumtype)) {
 1361|       |#endif					/* OLD_HEIMDAL */
 1362|       |        DEBUGMSGTL(("ksm", "Checksum type %d is not a keyed checksum\n",
 1363|       |                    cksumtype));
 1364|       |        snmp_set_detail("Checksum is not a keyed checksum");
 1365|       |        retval = SNMPERR_KRB5;
 1366|       |        goto error;
 1367|       |    }
 1368|       |
 1369|       |#ifdef OLD_HEIMDAL
 1370|       |    if (!krb5_checksum_is_collision_proof(kcontext, cksumtype)) {
 1371|       |#else					/* OLD_HEIMDAL */
 1372|       |    if (!is_coll_proof_cksum(cksumtype)) {
 1373|       |#endif					/* OLD_HEIMDAL */
 1374|       |        DEBUGMSGTL(("ksm", "Checksum type %d is not a collision-proof "
 1375|       |                    "checksum\n", cksumtype));
 1376|       |        snmp_set_detail("Checksum is not a collision-proof checksum");
 1377|       |        retval = SNMPERR_KRB5;
 1378|       |        goto error;
 1379|       |    }
 1380|       |#endif /* NETSNMP_USE_KERBEROS_MIT */
 1381|       |
 1382|     81|    CHECKSUM_TYPE(&checksum) = cksumtype;
  ------------------
  |  |   59|     81|#define CHECKSUM_TYPE(x)	(x)->checksum_type
  ------------------
 1383|       |
 1384|     81|    cksumlength = length;
 1385|       |
 1386|     81|    if ((current = asn_parse_sequence(current, &cksumlength, &type,
  ------------------
  |  Branch (1386:9): [True: 1, False: 80]
  ------------------
 1387|     81|                                      (ASN_UNIVERSAL | ASN_PRIMITIVE |
  ------------------
  |  |   90|     81|#define ASN_UNIVERSAL	    0x00U
  ------------------
                                                    (ASN_UNIVERSAL | ASN_PRIMITIVE |
  ------------------
  |  |   95|     81|#define ASN_PRIMITIVE	    0x00U
  ------------------
 1388|     81|                                       ASN_OCTET_STR), "ksm checksum")) ==
  ------------------
  |  |   78|     81|#define ASN_OCTET_STR	    0x04U
  ------------------
 1389|     81|        NULL) {
 1390|      1|        DEBUGMSGTL(("ksm",
  ------------------
  |  |   66|      1|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      1|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 1]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 1]
  |  |  ------------------
  ------------------
 1391|      1|                    "Security parameter checksum parsing failed\n"));
 1392|       |
 1393|      1|        retval = SNMPERR_ASN_PARSE_ERR;
  ------------------
  |  |  213|      1|#define SNMPERR_ASN_PARSE_ERR           (-29)
  ------------------
 1394|      1|        goto error;
 1395|      1|    }
 1396|       |
 1397|     80|    CHECKSUM_CONTENTS(&checksum) = malloc(cksumlength);
  ------------------
  |  |   60|     80|#define CHECKSUM_CONTENTS(x)	(x)->contents
  ------------------
 1398|     80|    if (!CHECKSUM_CONTENTS(&checksum)) {
  ------------------
  |  |   60|     80|#define CHECKSUM_CONTENTS(x)	(x)->contents
  ------------------
  |  Branch (1398:9): [True: 0, False: 80]
  ------------------
 1399|      0|        DEBUGMSGTL(("ksm", "Unable to malloc %d bytes for checksum.\n",
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1400|      0|                    (int)cksumlength));
 1401|      0|        retval = SNMPERR_MALLOC;
  ------------------
  |  |  246|      0|#define SNMPERR_MALLOC			(-62)
  ------------------
 1402|      0|        goto error;
 1403|      0|    }
 1404|       |
 1405|     80|    memcpy(CHECKSUM_CONTENTS(&checksum), current, cksumlength);
  ------------------
  |  |   60|     80|#define CHECKSUM_CONTENTS(x)	(x)->contents
  ------------------
 1406|       |
 1407|     80|    CHECKSUM_LENGTH(&checksum) = cksumlength;
  ------------------
  |  |   61|     80|#define CHECKSUM_LENGTH(x)	(x)->length
  ------------------
 1408|     80|    CHECKSUM_TYPE(&checksum) = cksumtype;
  ------------------
  |  |   59|     80|#define CHECKSUM_TYPE(x)	(x)->checksum_type
  ------------------
 1409|       |
 1410|       |    /*
 1411|       |     * Zero out the checksum so the validation works correctly
 1412|       |     */
 1413|       |
 1414|     80|    memset(current, 0, cksumlength);
 1415|       |
 1416|     80|    current += cksumlength;
 1417|     80|    length = parms->wholeMsgLen - (u_int) (current - parms->wholeMsg);
 1418|       |
 1419|     80|    if ((current = asn_parse_sequence(current, &length, &type,
  ------------------
  |  Branch (1419:9): [True: 2, False: 78]
  ------------------
 1420|     80|                                      (ASN_UNIVERSAL | ASN_PRIMITIVE |
  ------------------
  |  |   90|     80|#define ASN_UNIVERSAL	    0x00U
  ------------------
                                                    (ASN_UNIVERSAL | ASN_PRIMITIVE |
  ------------------
  |  |   95|     80|#define ASN_PRIMITIVE	    0x00U
  ------------------
 1421|     80|                                       ASN_OCTET_STR), "ksm ap_req")) ==
  ------------------
  |  |   78|     80|#define ASN_OCTET_STR	    0x04U
  ------------------
 1422|     80|        NULL) {
 1423|      2|        DEBUGMSGTL(("ksm", "KSM security parameter AP_REQ/REP parsing "
  ------------------
  |  |   66|      2|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      2|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 2]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 2]
  |  |  ------------------
  ------------------
 1424|      2|                    "failed\n"));
 1425|       |
 1426|      2|        retval = SNMPERR_ASN_PARSE_ERR;
  ------------------
  |  |  213|      2|#define SNMPERR_ASN_PARSE_ERR           (-29)
  ------------------
 1427|      2|        goto error;
 1428|      2|    }
 1429|       |
 1430|     78|    ap_req.length = length;
 1431|     78|    ap_req.data = malloc(length);
 1432|     78|    if (!ap_req.data) {
  ------------------
  |  Branch (1432:9): [True: 0, False: 78]
  ------------------
 1433|      0|        DEBUGMSGTL(("ksm",
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1434|      0|                    "KSM unable to malloc %d bytes for AP_REQ/REP.\n",
 1435|      0|                    (int)length));
 1436|      0|        retval = SNMPERR_MALLOC;
  ------------------
  |  |  246|      0|#define SNMPERR_MALLOC			(-62)
  ------------------
 1437|      0|        goto error;
 1438|      0|    }
 1439|       |
 1440|     78|    memcpy(ap_req.data, current, length);
 1441|       |
 1442|     78|    current += length;
 1443|     78|    length = parms->wholeMsgLen - (u_int) (current - parms->wholeMsg);
 1444|       |
 1445|     78|    if ((current = asn_parse_int(current, &length, &type, &hint,
  ------------------
  |  Branch (1445:9): [True: 51, False: 27]
  ------------------
 1446|     78|                                 sizeof(hint))) == NULL) {
 1447|     51|        DEBUGMSGTL(("ksm",
  ------------------
  |  |   66|     51|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     51|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 51]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 51]
  |  |  ------------------
  ------------------
 1448|     51|                    "KSM security parameter hint parsing failed\n"));
 1449|       |
 1450|     51|        retval = SNMPERR_ASN_PARSE_ERR;
  ------------------
  |  |  213|     51|#define SNMPERR_ASN_PARSE_ERR           (-29)
  ------------------
 1451|     51|        goto error;
 1452|     51|    }
 1453|       |
 1454|       |    /*
 1455|       |     * Okay!  We've got it all!  Now try decoding the damn ticket.
 1456|       |     *
 1457|       |     * But of course there's a WRINKLE!  We need to figure out if we're
 1458|       |     * processing a AP_REQ or an AP_REP.  How do we do that?  We're going
 1459|       |     * to cheat, and look at the first couple of bytes (which is what
 1460|       |     * the Kerberos library routines do anyway).
 1461|       |     *
 1462|       |     * If there are ever new Kerberos message formats, we'll need to fix
 1463|       |     * this here.
 1464|       |     *
 1465|       |     * If it's a _response_, then we need to get the auth_context
 1466|       |     * from our cache.
 1467|       |     */
 1468|       |
 1469|     27|    if (ap_req.length
  ------------------
  |  Branch (1469:9): [True: 26, False: 1]
  ------------------
 1470|     26|#ifndef NETSNMP_USE_KERBEROS_HEIMDAL
 1471|     26|        && (ap_req.data[0] == 0x6e || ap_req.data[0] == 0x4e)) {
  ------------------
  |  Branch (1471:13): [True: 3, False: 23]
  |  Branch (1471:39): [True: 2, False: 21]
  ------------------
 1472|       |#else				/* NETSNMP_USE_KERBEROS_HEIMDAL */
 1473|       |        && (((char *)ap_req.data)[0] == 0x6e || ((char *)ap_req.data)[0] == 0x4e)) {
 1474|       |#endif
 1475|       |
 1476|       |        /*
 1477|       |         * We need to initialize the authorization context, and set the
 1478|       |         * replay cache in it (and initialize the replay cache if we
 1479|       |         * haven't already
 1480|       |         */
 1481|       |
 1482|      5|        retcode = krb5_auth_con_init(kcontext, &auth_context);
 1483|       |
 1484|      5|        if (retcode) {
  ------------------
  |  Branch (1484:13): [True: 0, False: 5]
  ------------------
 1485|      0|            DEBUGMSGTL(("ksm", "krb5_auth_con_init failed: %s\n",
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1486|      0|                        error_message(retcode)));
 1487|      0|            retval = SNMPERR_KRB5;
  ------------------
  |  |  247|      0|#define SNMPERR_KRB5			(-63)
  ------------------
 1488|      0|            snmp_set_detail(error_message(retcode));
 1489|      0|            goto error;
 1490|      0|        }
 1491|       |
 1492|      5|        if (!rcache) {
  ------------------
  |  Branch (1492:13): [True: 1, False: 4]
  ------------------
 1493|      1|            krb5_data       server;
 1494|      1|            server.data = service_host;
 1495|      1|            server.length = strlen(server.data);
 1496|       |
 1497|      1|            retcode = krb5_get_server_rcache(kcontext, &server, &rcache);
 1498|       |
 1499|      1|            if (retcode) {
  ------------------
  |  Branch (1499:17): [True: 0, False: 1]
  ------------------
 1500|      0|                DEBUGMSGTL(("ksm", "krb5_get_server_rcache failed: %s\n",
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1501|      0|                            error_message(retcode)));
 1502|      0|                retval = SNMPERR_KRB5;
  ------------------
  |  |  247|      0|#define SNMPERR_KRB5			(-63)
  ------------------
 1503|      0|                snmp_set_detail(error_message(retcode));
 1504|      0|                goto error;
 1505|      0|            }
 1506|      1|        }
 1507|       |
 1508|      5|        retcode = krb5_auth_con_setrcache(kcontext, auth_context, rcache);
 1509|       |
 1510|      5|        if (retcode) {
  ------------------
  |  Branch (1510:13): [True: 0, False: 5]
  ------------------
 1511|      0|            DEBUGMSGTL(("ksm", "krb5_auth_con_setrcache failed: %s\n",
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1512|      0|                        error_message(retcode)));
 1513|      0|            retval = SNMPERR_KRB5;
  ------------------
  |  |  247|      0|#define SNMPERR_KRB5			(-63)
  ------------------
 1514|      0|            snmp_set_detail(error_message(retcode));
 1515|      0|            goto error;
 1516|      0|        }
 1517|       |
 1518|      5|        retcode = krb5_rd_req(kcontext, &auth_context, &ap_req, NULL,
 1519|      5|                              keytab, &flags, &ticket);
 1520|       |
 1521|      5|        krb5_auth_con_setrcache(kcontext, auth_context, NULL);
 1522|       |
 1523|      5|        if (retcode) {
  ------------------
  |  Branch (1523:13): [True: 5, False: 0]
  ------------------
 1524|      5|            DEBUGMSGTL(("ksm", "krb5_rd_req() failed: %s\n",
  ------------------
  |  |   66|      5|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      5|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 5]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 5]
  |  |  ------------------
  ------------------
 1525|      5|                        error_message(retcode)));
 1526|      5|            retval = SNMPERR_KRB5;
  ------------------
  |  |  247|      5|#define SNMPERR_KRB5			(-63)
  ------------------
 1527|      5|            snmp_set_detail(error_message(retcode));
 1528|      5|            goto error;
 1529|      5|        }
 1530|       |
 1531|      0|        retcode =
 1532|      0|            krb5_unparse_name(kcontext, TICKET_CLIENT(ticket), &cname);
  ------------------
  |  |   62|      0|#define TICKET_CLIENT(x)	(x)->enc_part2->client
  ------------------
 1533|       |
 1534|      0|        if (retcode == 0) {
  ------------------
  |  Branch (1534:13): [True: 0, False: 0]
  ------------------
 1535|      0|            DEBUGMSGTL(("ksm", "KSM authenticated principal name: %s\n",
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1536|      0|                        cname));
 1537|      0|            free(cname);
 1538|      0|        }
 1539|       |
 1540|       |        /*
 1541|       |         * Check to make sure AP_OPTS_MUTUAL_REQUIRED was set
 1542|       |         */
 1543|       |
 1544|      0|        if (!(flags & AP_OPTS_MUTUAL_REQUIRED)) {
  ------------------
  |  Branch (1544:13): [True: 0, False: 0]
  ------------------
 1545|      0|            DEBUGMSGTL(("ksm",
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1546|      0|                        "KSM MUTUAL_REQUIRED not set in request!\n"));
 1547|      0|            retval = SNMPERR_KRB5;
  ------------------
  |  |  247|      0|#define SNMPERR_KRB5			(-63)
  ------------------
 1548|      0|            snmp_set_detail("MUTUAL_REQUIRED not set in message");
 1549|      0|            goto error;
 1550|      0|        }
 1551|       |
 1552|      0|        retcode =
 1553|      0|            krb5_auth_con_getrecvsubkey(kcontext, auth_context, &subkey);
 1554|       |
 1555|      0|        if (retcode) {
  ------------------
  |  Branch (1555:13): [True: 0, False: 0]
  ------------------
 1556|      0|            DEBUGMSGTL(("ksm", "KSM remote subkey retrieval failed: %s\n",
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1557|      0|                        error_message(retcode)));
 1558|      0|            retval = SNMPERR_KRB5;
  ------------------
  |  |  247|      0|#define SNMPERR_KRB5			(-63)
  ------------------
 1559|      0|            snmp_set_detail(error_message(retcode));
 1560|      0|            goto error;
 1561|      0|        }
 1562|       |
 1563|      0|#ifndef NETSNMP_USE_KERBEROS_HEIMDAL
 1564|     22|    } else if (ap_req.length && (ap_req.data[0] == 0x6f ||
  ------------------
  |  Branch (1564:16): [True: 21, False: 1]
  |  Branch (1564:34): [True: 1, False: 20]
  ------------------
 1565|     20|                                 ap_req.data[0] == 0x4f)) {
  ------------------
  |  Branch (1565:34): [True: 1, False: 19]
  ------------------
 1566|       |#else				/* NETSNMP_USE_KERBEROS_HEIMDAL */
 1567|       |    } else if (ap_req.length && (((char *)ap_req.data)[0] == 0x6f ||
 1568|       |                                 ((char *)ap_req.data)[0] == 0x4f)) {
 1569|       |#endif				/* NETSNMP_USE_KERBEROS_HEIMDAL */
 1570|       |        /*
 1571|       |         * Looks like a response; let's see if we've got that auth_context
 1572|       |         * in our cache.
 1573|       |         */
 1574|       |
 1575|      2|        krb5_ap_rep_enc_part *repl = NULL;
 1576|       |
 1577|      2|        response = 1;
 1578|       |
 1579|      2|        entry = ksm_get_cache(parms->pdu->msgid);
 1580|       |
 1581|      2|        if (!entry) {
  ------------------
  |  Branch (1581:13): [True: 2, False: 0]
  ------------------
 1582|      2|            DEBUGMSGTL(("ksm",
  ------------------
  |  |   66|      2|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      2|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 2]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 2]
  |  |  ------------------
  ------------------
 1583|      2|                        "KSM: Unable to find auth_context for PDU with "
 1584|      2|                        "message ID of %ld\n", parms->pdu->msgid));
 1585|      2|            retval = SNMPERR_KRB5;
  ------------------
  |  |  247|      2|#define SNMPERR_KRB5			(-63)
  ------------------
 1586|      2|            goto error;
 1587|      2|        }
 1588|       |
 1589|      0|        auth_context = entry->auth_context;
 1590|       |
 1591|       |        /*
 1592|       |         * In that case, let's call the rd_rep function
 1593|       |         */
 1594|       |
 1595|      0|        retcode = krb5_rd_rep(kcontext, auth_context, &ap_req, &repl);
 1596|       |
 1597|      0|        if (repl)
  ------------------
  |  Branch (1597:13): [True: 0, False: 0]
  ------------------
 1598|      0|            krb5_free_ap_rep_enc_part(kcontext, repl);
 1599|       |
 1600|      0|        if (retcode) {
  ------------------
  |  Branch (1600:13): [True: 0, False: 0]
  ------------------
 1601|      0|            DEBUGMSGTL(("ksm", "KSM: krb5_rd_rep() failed: %s\n",
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1602|      0|                        error_message(retcode)));
 1603|      0|            retval = SNMPERR_KRB5;
  ------------------
  |  |  247|      0|#define SNMPERR_KRB5			(-63)
  ------------------
 1604|      0|            goto error;
 1605|      0|        }
 1606|       |
 1607|      0|        DEBUGMSGTL(("ksm", "KSM: krb5_rd_rep() decoded successfully.\n"));
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1608|       |
 1609|      0|        retcode =
 1610|      0|            krb5_auth_con_getsendsubkey(kcontext, auth_context, &subkey);
 1611|       |
 1612|      0|        if (retcode) {
  ------------------
  |  Branch (1612:13): [True: 0, False: 0]
  ------------------
 1613|      0|            DEBUGMSGTL(("ksm", "Unable to retrieve local subkey: %s\n",
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1614|      0|                        error_message(retcode)));
 1615|      0|            retval = SNMPERR_KRB5;
  ------------------
  |  |  247|      0|#define SNMPERR_KRB5			(-63)
  ------------------
 1616|      0|            snmp_set_detail("Unable to retrieve local subkey");
 1617|      0|            goto error;
 1618|      0|        }
 1619|       |
 1620|     20|    } else {
 1621|     20|#ifndef NETSNMP_USE_KERBEROS_HEIMDAL
 1622|     20|        DEBUGMSGTL(("ksm", "Unknown Kerberos message type (%02x)\n",
  ------------------
  |  |   66|     20|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     20|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 20]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (164:52): [True: 0, False: 0]
  |  |  |  |  |  Branch (164:64): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 20]
  |  |  ------------------
  ------------------
 1623|     20|                    ap_req.length ? (unsigned char)ap_req.data[0] : 0));
 1624|       |#else 				/* NETSNMP_USE_KERBEROS_HEIMDAL */
 1625|       |	 DEBUGMSGTL(("ksm", "Unknown Kerberos message type (%02x)\n",
 1626|       |                    ap_req.length ? ((unsigned char *)ap_req.data)[0] : 0));
 1627|       |#endif
 1628|     20|        retval = SNMPERR_KRB5;
  ------------------
  |  |  247|     20|#define SNMPERR_KRB5			(-63)
  ------------------
 1629|     20|        snmp_set_detail("Unknown Kerberos message type");
 1630|     20|        goto error;
 1631|     20|    }
 1632|       |
 1633|      0|#ifdef NETSNMP_USE_KERBEROS_MIT
 1634|      0|    input.data = (char *) parms->wholeMsg;
 1635|      0|    input.length = parms->wholeMsgLen;
 1636|       |
 1637|      0|    retcode =
 1638|      0|        krb5_c_verify_checksum(kcontext, subkey, KSM_KEY_USAGE_CHECKSUM,
  ------------------
  |  |   28|      0|#define KSM_KEY_USAGE_CHECKSUM		1031
  ------------------
 1639|      0|                               &input, &checksum, &valid);
 1640|       |#elif defined(OLD_HEIMDAL)	/* NETSNMP_USE_KERBEROS_MIT */
 1641|       |    retcode = krb5_crypto_init(kcontext, subkey, 0, &heim_crypto);
 1642|       |    if (retcode) {
 1643|       |            DEBUGMSGTL(("ksm", "krb5_crypto_init failed: %s\n",
 1644|       |                        error_message(retcode)));
 1645|       |            snmp_set_detail(error_message(retcode));
 1646|       |            retval = SNMPERR_KRB5;
 1647|       |            goto error;
 1648|       |    }
 1649|       |    retcode = krb5_verify_checksum(kcontext, heim_crypto,
 1650|       |				   KSM_KEY_USAGE_CHECKSUM, parms->wholeMsg,
 1651|       |				   parms->wholeMsgLen, &checksum);
 1652|       |#else                           /* NETSNMP_USE_KERBEROS_MIT */
 1653|       |    retcode = krb5_verify_checksum(kcontext, cksumtype, &checksum,
 1654|       |                                   parms->wholeMsg, parms->wholeMsgLen,
 1655|       |                                   (krb5_pointer) subkey->contents,
 1656|       |                                   subkey->length);
 1657|       |#endif                          /* NETSNMP_USE_KERBEROS_MIT */
 1658|       |
 1659|      0|    if (retcode) {
  ------------------
  |  Branch (1659:9): [True: 0, False: 0]
  ------------------
 1660|      0|        DEBUGMSGTL(("ksm", "KSM checksum verification failed: %s\n",
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1661|      0|                    error_message(retcode)));
 1662|      0|        retval = SNMPERR_KRB5;
  ------------------
  |  |  247|      0|#define SNMPERR_KRB5			(-63)
  ------------------
 1663|      0|        snmp_set_detail(error_message(retcode));
 1664|      0|        goto error;
 1665|      0|    }
 1666|       |
 1667|       |    /*
 1668|       |     * Don't ask me why they didn't simply return an error, but we have
 1669|       |     * to check to see if "valid" is false.
 1670|       |     */
 1671|       |
 1672|      0|#ifdef NETSNMP_USE_KERBEROS_MIT
 1673|      0|    if (!valid) {
  ------------------
  |  Branch (1673:9): [True: 0, False: 0]
  ------------------
 1674|      0|        DEBUGMSGTL(("ksm", "Computed checksum did not match supplied "
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1675|      0|                    "checksum!\n"));
 1676|      0|        retval = SNMPERR_KRB5;
  ------------------
  |  |  247|      0|#define SNMPERR_KRB5			(-63)
  ------------------
 1677|      0|        snmp_set_detail
 1678|      0|            ("Computed checksum did not match supplied checksum");
 1679|      0|        goto error;
 1680|      0|    }
 1681|      0|#endif                          /* NETSNMP_USE_KERBEROS_MIT */
 1682|       |
 1683|       |    /*
 1684|       |     * Handle an encrypted PDU.  Note that it's an OCTET_STRING of the
 1685|       |     * output of whatever Kerberos cryptosystem you're using (defined by
 1686|       |     * the encryption type).  Note that this is NOT the EncryptedData
 1687|       |     * sequence - it's what goes in the "cipher" field of EncryptedData.
 1688|       |     */
 1689|       |
 1690|      0|    if (parms->secLevel == SNMP_SEC_LEVEL_AUTHPRIV) {
  ------------------
  |  |  301|      0|#define SNMP_SEC_LEVEL_AUTHPRIV		3
  ------------------
  |  Branch (1690:9): [True: 0, False: 0]
  ------------------
 1691|       |
 1692|      0|        if ((current = asn_parse_sequence(current, &length, &type,
  ------------------
  |  Branch (1692:13): [True: 0, False: 0]
  ------------------
 1693|      0|                                          (ASN_UNIVERSAL | ASN_PRIMITIVE |
  ------------------
  |  |   90|      0|#define ASN_UNIVERSAL	    0x00U
  ------------------
                                                        (ASN_UNIVERSAL | ASN_PRIMITIVE |
  ------------------
  |  |   95|      0|#define ASN_PRIMITIVE	    0x00U
  ------------------
 1694|      0|                                           ASN_OCTET_STR), "ksm pdu")) ==
  ------------------
  |  |   78|      0|#define ASN_OCTET_STR	    0x04U
  ------------------
 1695|      0|            NULL) {
 1696|      0|            DEBUGMSGTL(("ksm", "KSM sPDU octet decoding failed\n"));
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1697|      0|            retval = SNMPERR_ASN_PARSE_ERR;
  ------------------
  |  |  213|      0|#define SNMPERR_ASN_PARSE_ERR           (-29)
  ------------------
 1698|      0|            goto error;
 1699|      0|        }
 1700|       |
 1701|       |        /*
 1702|       |         * The PDU is now pointed at by "current", and the length is in
 1703|       |         * "length".
 1704|       |         */
 1705|       |
 1706|      0|        DEBUGMSGTL(("ksm", "KSM starting sPDU decode\n"));
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1707|       |
 1708|       |        /*
 1709|       |         * We need to set up a blank initialization vector for the decryption.
 1710|       |         * Use a block of all zero's (which is dependent on the block size
 1711|       |         * of the encryption method).
 1712|       |         */
 1713|       |
 1714|      0|#ifdef NETSNMP_USE_KERBEROS_MIT
 1715|       |
 1716|      0|        retcode = krb5_c_block_size(kcontext, subkey->enctype, &blocksize);
 1717|       |
 1718|      0|        if (retcode) {
  ------------------
  |  Branch (1718:13): [True: 0, False: 0]
  ------------------
 1719|      0|            DEBUGMSGTL(("ksm",
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1720|      0|                        "Unable to determine crypto block size: %s\n",
 1721|      0|                        error_message(retcode)));
 1722|      0|            snmp_set_detail(error_message(retcode));
 1723|      0|            retval = SNMPERR_KRB5;
  ------------------
  |  |  247|      0|#define SNMPERR_KRB5			(-63)
  ------------------
 1724|      0|            goto error;
 1725|      0|        }
 1726|       |#elif defined(OLD_HEIMDAL)	/* NETSNMP_USE_KERBEROS_MIT */
 1727|       |#else                           /* NETSNMP_USE_KERBEROS_MIT */
 1728|       |
 1729|       |        blocksize =
 1730|       |            krb5_enctype_array[subkey->enctype]->system->block_length;
 1731|       |
 1732|       |#endif                          /* NETSNMP_USE_KERBEROS_MIT */
 1733|       |
 1734|      0|#ifndef OLD_HEIMDAL
 1735|      0|        ivector.data = malloc(blocksize);
 1736|       |
 1737|      0|        if (!ivector.data) {
  ------------------
  |  Branch (1737:13): [True: 0, False: 0]
  ------------------
 1738|      0|            DEBUGMSGTL(("ksm", "Unable to allocate %d bytes for ivector\n",
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1739|      0|                        (int)blocksize));
 1740|      0|            retval = SNMPERR_MALLOC;
  ------------------
  |  |  246|      0|#define SNMPERR_MALLOC			(-62)
  ------------------
 1741|      0|            goto error;
 1742|      0|        }
 1743|       |
 1744|      0|        ivector.length = blocksize;
 1745|      0|        memset(ivector.data, 0, blocksize);
 1746|       |
 1747|       |#ifndef NETSNMP_USE_KERBEROS_MIT
 1748|       |
 1749|       |        krb5_use_enctype(kcontext, &eblock, subkey->enctype);
 1750|       |
 1751|       |        retcode = krb5_process_key(kcontext, &eblock, subkey);
 1752|       |
 1753|       |        if (retcode) {
 1754|       |            DEBUGMSGTL(("ksm", "KSM key post-processing failed: %s\n",
 1755|       |                        error_message(retcode)));
 1756|       |            snmp_set_detail(error_message(retcode));
 1757|       |            retval = SNMPERR_KRB5;
 1758|       |            goto error;
 1759|       |        }
 1760|       |#endif                          /* !NETSNMP_USE_KERBEROS_MIT */
 1761|       |
 1762|      0|#endif /* ! OLD_HEIMDAL */
 1763|       |
 1764|      0|        if (length > *parms->scopedPduLen) {
  ------------------
  |  Branch (1764:13): [True: 0, False: 0]
  ------------------
 1765|      0|            DEBUGMSGTL(("ksm", "KSM not enough room - have %d bytes to "
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1766|      0|                        "decrypt but only %d bytes available\n", (int)length,
 1767|      0|                        (int)*parms->scopedPduLen));
 1768|      0|            retval = SNMPERR_TOO_LONG;
  ------------------
  |  |  189|      0|#define SNMPERR_TOO_LONG		(-5)
  ------------------
 1769|       |#ifndef NETSNMP_USE_KERBEROS_MIT
 1770|       |#ifndef OLD_HEIMDAL
 1771|       |            krb5_finish_key(kcontext, &eblock);
 1772|       |#endif                          /* ! OLD_HEIMDAL */
 1773|       |#endif                          /* ! NETSNMP_USE_KERBEROS_MIT */
 1774|      0|            goto error;
 1775|      0|        }
 1776|      0|#ifdef NETSNMP_USE_KERBEROS_MIT
 1777|      0|        in_crypt.ciphertext.data = (char *) current;
 1778|      0|        in_crypt.ciphertext.length = length;
 1779|      0|        in_crypt.enctype = subkey->enctype;
 1780|      0|        output.data = (char *) *parms->scopedPdu;
 1781|      0|        output.length = *parms->scopedPduLen;
 1782|       |
 1783|      0|        retcode =
 1784|      0|            krb5_c_decrypt(kcontext, subkey, KSM_KEY_USAGE_ENCRYPTION,
  ------------------
  |  |   27|      0|#define KSM_KEY_USAGE_ENCRYPTION	1030
  ------------------
 1785|      0|                           &ivector, &in_crypt, &output);
 1786|       |#elif defined (OLD_HEIMDAL)	/* NETSNMP_USE_KERBEROS_MIT */
 1787|       |	retcode = krb5_decrypt(kcontext, heim_crypto, KSM_KEY_USAGE_ENCRYPTION,
 1788|       |			       current, length, &output);
 1789|       |	if (retcode == 0) {
 1790|       |		*parms->scopedPdu = (u_char *) output.data;
 1791|       |		*parms->scopedPduLen = output.length;
 1792|       |		krb5_data_zero(&output);
 1793|       |	}
 1794|       |#else                           /* NETSNMP_USE_KERBEROS_MIT */
 1795|       |
 1796|       |        retcode = krb5_decrypt(kcontext, (krb5_pointer) current,
 1797|       |                               *parms->scopedPdu, length, &eblock,
 1798|       |                               ivector.data);
 1799|       |
 1800|       |        krb5_finish_key(kcontext, &eblock);
 1801|       |
 1802|       |#endif                          /* NETSNMP_USE_KERBEROS_MIT */
 1803|       |
 1804|      0|        if (retcode) {
  ------------------
  |  Branch (1804:13): [True: 0, False: 0]
  ------------------
 1805|      0|            DEBUGMSGTL(("ksm", "Decryption failed: %s\n",
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1806|      0|                        error_message(retcode)));
 1807|      0|            snmp_set_detail(error_message(retcode));
 1808|      0|            retval = SNMPERR_KRB5;
  ------------------
  |  |  247|      0|#define SNMPERR_KRB5			(-63)
  ------------------
 1809|      0|            goto error;
 1810|      0|        }
 1811|       |
 1812|      0|        *parms->scopedPduLen = length;
 1813|       |
 1814|      0|    } else {
 1815|       |        /*
 1816|       |         * Clear PDU
 1817|       |         */
 1818|       |
 1819|      0|        *parms->scopedPdu = current;
 1820|      0|        *parms->scopedPduLen =
 1821|      0|            parms->wholeMsgLen - (current - parms->wholeMsg);
 1822|      0|    }
 1823|       |
 1824|       |    /*
 1825|       |     * A HUGE GROSS HACK
 1826|       |     */
 1827|       |
 1828|      0|    *parms->maxSizeResponse = parms->maxMsgSize - 200;
 1829|       |
 1830|      0|    DEBUGMSGTL(("ksm", "KSM processing complete\n"));
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1831|       |
 1832|       |    /*
 1833|       |     * Set the secName to the right value (a hack for now).  But that's
 1834|       |     * only used for when we're processing a request, not a response.
 1835|       |     */
 1836|       |
 1837|      0|    if (!response) {
  ------------------
  |  Branch (1837:9): [True: 0, False: 0]
  ------------------
 1838|       |
 1839|      0|        retcode = krb5_unparse_name(kcontext, TICKET_CLIENT(ticket),
  ------------------
  |  |   62|      0|#define TICKET_CLIENT(x)	(x)->enc_part2->client
  ------------------
 1840|      0|                                    &cname);
 1841|       |
 1842|      0|        if (retcode) {
  ------------------
  |  Branch (1842:13): [True: 0, False: 0]
  ------------------
 1843|      0|            DEBUGMSGTL(("ksm", "KSM krb5_unparse_name failed: %s\n",
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1844|      0|                        error_message(retcode)));
 1845|      0|            snmp_set_detail(error_message(retcode));
 1846|      0|            retval = SNMPERR_KRB5;
  ------------------
  |  |  247|      0|#define SNMPERR_KRB5			(-63)
  ------------------
 1847|      0|            goto error;
 1848|      0|        }
 1849|       |
 1850|      0|        if (strlen(cname) >= *parms->secNameLen) {
  ------------------
  |  Branch (1850:13): [True: 0, False: 0]
  ------------------
 1851|      0|            DEBUGMSGTL(("ksm",
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1852|      0|                        "KSM: Principal length (%d) is too long (%d)\n",
 1853|      0|                        (int)strlen(cname), (int)*parms->secNameLen));
 1854|      0|            retval = SNMPERR_TOO_LONG;
  ------------------
  |  |  189|      0|#define SNMPERR_TOO_LONG		(-5)
  ------------------
 1855|      0|            free(cname);
 1856|      0|            goto error;
 1857|      0|        }
 1858|       |
 1859|      0|        strcpy(parms->secName, cname);
 1860|      0|        *parms->secNameLen = strlen(cname);
 1861|       |
 1862|      0|        free(cname);
 1863|       |
 1864|       |        /*
 1865|       |         * Also, if we're not a response, keep around our auth_context so we
 1866|       |         * can encode the reply message correctly
 1867|       |         */
 1868|       |
 1869|      0|        ksm_state = SNMP_MALLOC_STRUCT(ksm_secStateRef);
  ------------------
  |  |   69|      0|#define SNMP_MALLOC_STRUCT(s)   (struct s *) calloc(1, sizeof(struct s))
  ------------------
 1870|       |
 1871|      0|        if (!ksm_state) {
  ------------------
  |  Branch (1871:13): [True: 0, False: 0]
  ------------------
 1872|      0|            DEBUGMSGTL(("ksm", "KSM unable to malloc memory for "
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1873|      0|                        "ksm_secStateRef\n"));
 1874|      0|            retval = SNMPERR_MALLOC;
  ------------------
  |  |  246|      0|#define SNMPERR_MALLOC			(-62)
  ------------------
 1875|      0|            goto error;
 1876|      0|        }
 1877|       |
 1878|      0|        ksm_state->auth_context = auth_context;
 1879|      0|        auth_context = NULL;
 1880|      0|        ksm_state->cksumtype = cksumtype;
 1881|       |
 1882|      0|        *parms->secStateRef = ksm_state;
 1883|      0|    } else {
 1884|       |
 1885|       |        /*
 1886|       |         * We _still_ have to set the secName in process_in_msg().  Do
 1887|       |         * that now with what we were passed in before (we cached it,
 1888|       |         * remember?)
 1889|       |         */
 1890|       |
 1891|      0|        if (entry->secNameLen >= *parms->secNameLen) {
  ------------------
  |  Branch (1891:13): [True: 0, False: 0]
  ------------------
 1892|      0|            retval = SNMPERR_TOO_LONG;
  ------------------
  |  |  189|      0|#define SNMPERR_TOO_LONG		(-5)
  ------------------
 1893|      0|            goto error;
 1894|      0|        }
 1895|      0|        memcpy(parms->secName, entry->secName, entry->secNameLen);
 1896|      0|        parms->secName[entry->secNameLen] = '\0';
 1897|      0|        *parms->secNameLen = entry->secNameLen;
 1898|      0|    }
 1899|       |
 1900|       |    /*
 1901|       |     * Just in case
 1902|       |     */
 1903|       |
 1904|      0|    parms->secEngineID = null_id;
 1905|      0|    *parms->secEngineIDLen = 0;
 1906|       |
 1907|      0|    auth_context = NULL;        /* So we don't try to free it on success */
 1908|       |
 1909|     94|  error:
 1910|     94|    if (retval == SNMPERR_ASN_PARSE_ERR &&
  ------------------
  |  |  213|    188|#define SNMPERR_ASN_PARSE_ERR           (-29)
  ------------------
  |  Branch (1910:9): [True: 65, False: 29]
  ------------------
 1911|     65|        snmp_increment_statistic(STAT_SNMPINASNPARSEERRS) == 0)
  ------------------
  |  |  637|     65|#define  STAT_SNMPINASNPARSEERRS             14
  ------------------
  |  Branch (1911:9): [True: 0, False: 65]
  ------------------
 1912|      0|        DEBUGMSGTL(("ksm", "Failed to increment statistics.\n"));
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1913|       |
 1914|     94|    if (subkey)
  ------------------
  |  Branch (1914:9): [True: 0, False: 94]
  ------------------
 1915|      0|        krb5_free_keyblock(kcontext, subkey);
 1916|       |
 1917|       |#ifdef OLD_HEIMDAL /* OLD_HEIMDAL */
 1918|       |    if (heim_crypto)
 1919|       |	    krb5_crypto_destroy(kcontext, heim_crypto);
 1920|       |#endif /* OLD_HEIMDAL */
 1921|       |
 1922|     94|    if (CHECKSUM_CONTENTS(&checksum))
  ------------------
  |  |   60|     94|#define CHECKSUM_CONTENTS(x)	(x)->contents
  |  |  ------------------
  |  |  |  Branch (60:30): [True: 80, False: 14]
  |  |  ------------------
  ------------------
 1923|     80|        free(CHECKSUM_CONTENTS(&checksum));
  ------------------
  |  |   60|     80|#define CHECKSUM_CONTENTS(x)	(x)->contents
  ------------------
 1924|       |
 1925|     94|    if (ivector.data)
  ------------------
  |  Branch (1925:9): [True: 0, False: 94]
  ------------------
 1926|      0|        free(ivector.data);
 1927|       |
 1928|     94|    if (ticket)
  ------------------
  |  Branch (1928:9): [True: 0, False: 94]
  ------------------
 1929|      0|        krb5_free_ticket(kcontext, ticket);
 1930|       |
 1931|     94|    if (!response && auth_context)
  ------------------
  |  Branch (1931:9): [True: 92, False: 2]
  |  Branch (1931:22): [True: 5, False: 87]
  ------------------
 1932|      5|        krb5_auth_con_free(kcontext, auth_context);
 1933|       |
 1934|     94|    if (ap_req.data)
  ------------------
  |  Branch (1934:9): [True: 78, False: 16]
  ------------------
 1935|     78|        free(ap_req.data);
 1936|       |
 1937|     94|    return retval;
 1938|      0|}
snmpksm.c:init_snmpksm_post_config:
  169|      2|{
  170|       |
  171|      2|    if (kcontext == NULL) {
  ------------------
  |  Branch (171:9): [True: 0, False: 2]
  ------------------
  172|       |	/* not reached, I'd imagine */
  173|      0|        return SNMPERR_KRB5;
  ------------------
  |  |  247|      0|#define SNMPERR_KRB5			(-63)
  ------------------
  174|      0|    }
  175|       |
  176|      2|    if (service_name == NULL) {
  ------------------
  |  Branch (176:9): [True: 2, False: 0]
  ------------------
  177|       |	/* always reached, I'd imagine */
  178|      2|	char *c = netsnmp_ds_get_string(NETSNMP_DS_LIBRARY_ID,
  ------------------
  |  |   48|      2|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  179|      2|					NETSNMP_DS_LIB_KSM_SERVICE_NAME);
  ------------------
  |  |  173|      2|#define NETSNMP_DS_LIB_KSM_SERVICE_NAME  22
  ------------------
  180|      2|	if (c != NULL) {
  ------------------
  |  Branch (180:6): [True: 0, False: 2]
  ------------------
  181|      0|		service_name = c;
  182|      0|	}
  183|      2|	else {
  184|      2|		service_name = service_host;
  185|      2|	}
  186|      2|    }
  187|       |
  188|      2|    if (keytab_setup == 0) {
  ------------------
  |  Branch (188:9): [True: 2, False: 0]
  ------------------
  189|       |	/* always reached, I'd imagine */
  190|      2|	char *c = netsnmp_ds_get_string(NETSNMP_DS_LIBRARY_ID,
  ------------------
  |  |   48|      2|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  191|      2|					NETSNMP_DS_LIB_KSM_KEYTAB);
  ------------------
  |  |  172|      2|#define NETSNMP_DS_LIB_KSM_KEYTAB        21
  ------------------
  192|      2|	if (c) {
  ------------------
  |  Branch (192:6): [True: 0, False: 2]
  ------------------
  193|      0|	    krb5_error_code retval;
  194|      0|	    DEBUGMSGTL(("ksm", "Using keytab %s\n", c));
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
  195|      0|	    retval = krb5_kt_resolve(kcontext, c, &keytab);
  196|      0|	    if (retval) {
  ------------------
  |  Branch (196:10): [True: 0, False: 0]
  ------------------
  197|      0|		DEBUGMSGTL(("ksm", "krb5_kt_resolve(\"%s\") failed. KSM "
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
  198|      0|			    "config callback failing\n", error_message(retval)));
  199|      0|		return SNMPERR_KRB5;
  ------------------
  |  |  247|      0|#define SNMPERR_KRB5			(-63)
  ------------------
  200|      0|	    }
  201|      0|	}
  202|      2|	else {
  203|      2|	    DEBUGMSGTL(("ksm", "Using default keytab\n"));
  ------------------
  |  |   66|      2|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      2|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 2]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 2]
  |  |  ------------------
  ------------------
  204|      2|	}
  205|      2|	keytab_setup = 1;
  206|      2|    }
  207|       |
  208|      2|    return SNMPERR_SUCCESS;
  ------------------
  |  |  184|      2|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
  209|      2|}
snmpksm.c:ksm_free_pdu:
  428|     94|{
  429|     94|    ksm_decrement_ref_count(pdu->msgid);
  430|       |
  431|     94|    DEBUGMSGTL(("ksm", "Decrementing cache entry for PDU msgid %ld\n",
  ------------------
  |  |   66|     94|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     94|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 94]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 94]
  |  |  ------------------
  ------------------
  432|     94|                pdu->msgid));
  433|       |
  434|     94|    return SNMPERR_SUCCESS;
  ------------------
  |  |  184|     94|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
  435|     94|}
snmpksm.c:ksm_decrement_ref_count:
  330|     94|{
  331|     94|    struct ksm_cache_entry *entry, *entry1;
  332|     94|    int             bucket;
  333|       |
  334|     94|    bucket = (unsigned long)msgid % HASHSIZE;
  ------------------
  |  |  129|     94|#define HASHSIZE	64
  ------------------
  335|       |
  336|     94|    if (ksm_hash_table[bucket] && ksm_hash_table[bucket]->msgid == msgid) {
  ------------------
  |  Branch (336:9): [True: 0, False: 94]
  |  Branch (336:35): [True: 0, False: 0]
  ------------------
  337|      0|        entry = ksm_hash_table[bucket];
  338|       |
  339|       |        /*
  340|       |         * If the reference count is zero, then free it
  341|       |         */
  342|       |
  343|      0|        if (--entry->refcount <= 0) {
  ------------------
  |  Branch (343:13): [True: 0, False: 0]
  ------------------
  344|      0|            DEBUGMSGTL(("ksm", "Freeing entry for msgid %ld\n", msgid));
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
  345|      0|            krb5_auth_con_free(kcontext, entry->auth_context);
  346|      0|            free(entry->secName);
  347|      0|            ksm_hash_table[bucket] = entry->next;
  348|      0|            free(entry);
  349|      0|        }
  350|       |
  351|      0|        return;
  352|       |
  353|     94|    } else if (ksm_hash_table[bucket])
  ------------------
  |  Branch (353:16): [True: 0, False: 94]
  ------------------
  354|      0|        for (entry1 = ksm_hash_table[bucket], entry = entry1->next;
  355|      0|             entry != NULL; entry1 = entry, entry = entry->next)
  ------------------
  |  Branch (355:14): [True: 0, False: 0]
  ------------------
  356|      0|            if (entry->msgid == msgid) {
  ------------------
  |  Branch (356:17): [True: 0, False: 0]
  ------------------
  357|       |
  358|      0|                if (--entry->refcount <= 0) {
  ------------------
  |  Branch (358:21): [True: 0, False: 0]
  ------------------
  359|      0|                    DEBUGMSGTL(("ksm", "Freeing entry for msgid %ld\n",
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
  360|      0|                                msgid));
  361|      0|                    krb5_auth_con_free(kcontext, entry->auth_context);
  362|      0|                    free(entry->secName);
  363|      0|                    entry1->next = entry->next;
  364|      0|                    free(entry);
  365|      0|                }
  366|       |
  367|      0|                return;
  368|      0|            }
  369|       |
  370|     94|    DEBUGMSGTL(("ksm",
  ------------------
  |  |   66|     94|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     94|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 94]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 94]
  |  |  ------------------
  ------------------
  371|     94|                "KSM: Unable to decrement cache entry for msgid %ld.\n",
  372|     94|                msgid));
  373|     94|}
snmpksm.c:ksm_get_cache:
  314|      2|{
  315|      2|    struct ksm_cache_entry *entry;
  316|      2|    int             bucket;
  317|       |
  318|      2|    bucket = (unsigned long)msgid % HASHSIZE;
  ------------------
  |  |  129|      2|#define HASHSIZE	64
  ------------------
  319|       |
  320|      2|    for (entry = ksm_hash_table[bucket]; entry != NULL;
  ------------------
  |  Branch (320:42): [True: 0, False: 2]
  ------------------
  321|      2|         entry = entry->next)
  322|      0|        if (entry->msgid == msgid)
  ------------------
  |  Branch (322:13): [True: 0, False: 0]
  ------------------
  323|      0|            return entry;
  324|       |
  325|      2|    return NULL;
  326|      2|}

init_tsm:
   43|      2|{
   44|      2|    struct snmp_secmod_def *def;
   45|      2|    int ret;
   46|       |
   47|      2|    def = SNMP_MALLOC_STRUCT(snmp_secmod_def);
  ------------------
  |  |   69|      2|#define SNMP_MALLOC_STRUCT(s)   (struct s *) calloc(1, sizeof(struct s))
  ------------------
   48|       |
   49|      2|    if (!def) {
  ------------------
  |  Branch (49:9): [True: 0, False: 2]
  ------------------
   50|      0|        snmp_log(LOG_ERR,
   51|      0|                 "Unable to malloc snmp_secmod struct, not registering TSM\n");
   52|      0|        return;
   53|      0|    }
   54|       |
   55|      2|    def->encode_reverse = tsm_rgenerate_out_msg;
   56|      2|    def->decode = tsm_process_in_msg;
   57|      2|    def->session_open = tsm_session_init;
   58|      2|    def->pdu_free_state_ref = tsm_free_state_ref;
   59|      2|    def->pdu_clone = tsm_clone_pdu;
   60|      2|    def->pdu_free = tsm_free_pdu;
   61|      2|    def->probe_engineid = snmpv3_probe_contextEngineID_rfc5343;
   62|       |
   63|      2|    DEBUGMSGTL(("tsm","registering ourselves\n"));
  ------------------
  |  |   66|      2|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      2|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 2]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 2]
  |  |  ------------------
  ------------------
   64|      2|    ret = register_sec_mod(SNMP_SEC_MODEL_TSM, "tsm", def);
  ------------------
  |  |  296|      2|#define SNMP_SEC_MODEL_TSM              4
  ------------------
   65|      2|    DEBUGMSGTL(("tsm"," returned %d\n", ret));
  ------------------
  |  |   66|      2|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      2|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 2]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 2]
  |  |  ------------------
  ------------------
   66|       |
   67|      2|    netsnmp_ds_register_config(ASN_BOOLEAN, "snmp", "tsmUseTransportPrefix",
  ------------------
  |  |   72|      2|#define ASN_BOOLEAN	    0x01U
  ------------------
   68|      2|			       NETSNMP_DS_LIBRARY_ID,
  ------------------
  |  |   48|      2|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
   69|      2|                               NETSNMP_DS_LIB_TSM_USE_PREFIX);
  ------------------
  |  |   99|      2|#define NETSNMP_DS_LIB_TSM_USE_PREFIX      39 /* TSM's simple security name mapping */
  ------------------
   70|      2|}
tsm_process_in_msg:
  429|      2|{
  430|      2|    u_char type_value;
  431|      2|    size_t remaining;
  432|      2|    u_char *data_ptr;
  433|      2|    netsnmp_tmStateReference *tmStateRef;
  434|      2|    netsnmp_tsmSecurityReference *tsmSecRef;
  435|      2|    u_char          ourEngineID[SNMP_MAX_ENG_SIZE];
  436|      2|    size_t          ourEngineID_len = sizeof(ourEngineID);
  437|       |    
  438|       |    /* Section 5.2, step 1: Set the securityEngineID to the local
  439|       |       snmpEngineID. */
  440|      2|    ourEngineID_len =
  441|      2|        snmpv3_get_engineID((u_char*) ourEngineID, ourEngineID_len);
  442|      2|    netsnmp_assert_or_return(ourEngineID_len != 0 &&
  ------------------
  |  |   56|      2|#      define netsnmp_assert_or_return(x, y)  do {        \
  |  |   57|      6|              if ( x ) \
  |  |  ------------------
  |  |  |  Branch (57:20): [True: 2, False: 0]
  |  |  |  Branch (57:20): [True: 2, False: 0]
  |  |  ------------------
  |  |   58|      2|                 ; \
  |  |   59|      2|              else { \
  |  |   60|      0|                 snmp_log(LOG_ERR, \
  |  |   61|      0|                          "netsnmp_assert %s failed %s:%d" NETSNMP_FUNC_FMT, \
  |  |  ------------------
  |  |  |  |   40|      0|#          define NETSNMP_FUNC_FMT " %s()\n"
  |  |  ------------------
  |  |   62|      0|                          __STRING(x),__FILE__,__LINE__, \
  |  |   63|      0|                          NETSNMP_FUNC_PARAM); \
  |  |  ------------------
  |  |  |  |   41|      0|#          define NETSNMP_FUNC_PARAM NETSNMP_FUNCTION
  |  |  |  |  ------------------
  |  |  |  |  |  | 1727|      0|#define NETSNMP_FUNCTION __func__
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   64|      0|                 return y; \
  |  |   65|      0|              } \
  |  |   66|      2|           }while(0)
  |  |  ------------------
  |  |  |  Branch (66:19): [Folded, False: 2]
  |  |  ------------------
  ------------------
  443|      2|                             ourEngineID_len <= *parms->secEngineIDLen,
  444|      2|                             SNMPERR_GENERR);
  445|      2|    memcpy(parms->secEngineID, ourEngineID, ourEngineID_len);
  446|      2|    *parms->secEngineIDLen = ourEngineID_len;
  447|       |
  448|       |    /* Section 5.2, step 2: If tmStateReference does not refer to a
  449|       |       cache containing values for tmTransportDomain,
  450|       |       tmTransportAddress, tmSecurityName, and
  451|       |       tmTransportSecurityLevel, then the snmpTsmInvalidCaches counter
  452|       |       is incremented, an error indication is returned to the calling
  453|       |       module, and Security Model processing stops for this
  454|       |       message. */
  455|      2|    if (!parms->pdu->transport_data ||
  ------------------
  |  Branch (455:9): [True: 2, False: 0]
  ------------------
  456|      0|        sizeof(netsnmp_tmStateReference) !=
  ------------------
  |  Branch (456:9): [True: 0, False: 0]
  ------------------
  457|      2|        parms->pdu->transport_data_length) {
  458|       |        /* if we're not coming in over a proper transport; bail! */
  459|      2|        DEBUGMSGTL(("tsm","improper transport data\n"));
  ------------------
  |  |   66|      2|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      2|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 2]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 2]
  |  |  ------------------
  ------------------
  460|      2|        return -1;
  461|      2|    }
  462|      0|    tmStateRef = (netsnmp_tmStateReference *) parms->pdu->transport_data;
  463|      0|    parms->pdu->transport_data = NULL;
  464|       |
  465|      0|    if (tmStateRef == NULL ||
  ------------------
  |  Branch (465:9): [True: 0, False: 0]
  ------------------
  466|       |        /* not needed: tmStateRef->transportDomain == NULL || */
  467|       |        /* not needed: tmStateRef->transportAddress == NULL || */
  468|      0|        tmStateRef->securityName[0] == '\0'
  ------------------
  |  Branch (468:9): [True: 0, False: 0]
  ------------------
  469|      0|        ) {
  470|      0|        snmp_increment_statistic(STAT_TSM_SNMPTSMINVALIDCACHES);
  ------------------
  |  |  684|      0|#define  STAT_TSM_SNMPTSMINVALIDCACHES             43
  ------------------
  471|      0|        SNMP_FREE(tmStateRef);
  ------------------
  |  |   62|      0|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 0, False: 0]
  |  |  |  Branch (62:66): [Folded, False: 0]
  |  |  ------------------
  ------------------
  472|      0|        return SNMPERR_GENERR;
  ------------------
  |  |  185|      0|#define SNMPERR_GENERR			(-1)
  ------------------
  473|      0|    }
  474|       |
  475|       |    /* Section 5.2, step 3: Copy the tmSecurityName to securityName. */
  476|      0|    if (*parms->secNameLen == 0) {
  ------------------
  |  Branch (476:9): [True: 0, False: 0]
  ------------------
  477|      0|        SNMP_FREE(tmStateRef);
  ------------------
  |  |   62|      0|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 0, False: 0]
  |  |  |  Branch (62:66): [Folded, False: 0]
  |  |  ------------------
  ------------------
  478|      0|        return SNMPERR_GENERR;
  ------------------
  |  |  185|      0|#define SNMPERR_GENERR			(-1)
  ------------------
  479|      0|    }
  480|      0|    if (netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID,
  ------------------
  |  |   48|      0|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  |  Branch (480:9): [True: 0, False: 0]
  ------------------
  481|      0|                               NETSNMP_DS_LIB_TSM_USE_PREFIX)) {
  ------------------
  |  |   99|      0|#define NETSNMP_DS_LIB_TSM_USE_PREFIX      39 /* TSM's simple security name mapping */
  ------------------
  482|       |        /* Section 5.2, step 3:
  483|       |          If the snmpTsmConfigurationUsePrefix object is set to true, then
  484|       |          use the tmTransportDomain to look up the corresponding prefix.
  485|       |        */
  486|      0|        const char *prefix = NULL;
  487|       |        /*
  488|       |          possibilities:
  489|       |           |--------------------+-------|
  490|       |           | snmpTLSTCPDomain   | tls:  |
  491|       |           | snmpDTLSUDPDomain  | dtls: |
  492|       |           | snmpSSHDomain      | ssh:  |
  493|       |           |--------------------+-------|
  494|       |        */
  495|       |        
  496|       |        /* XXX: cache in session! */
  497|       |#ifdef NETSNMP_TRANSPORT_SSH_DOMAIN
  498|       |        if (netsnmp_oid_equals(netsnmp_snmpSSHDomain,
  499|       |                               netsnmp_snmpSSHDomain_len,
  500|       |                               tmStateRef->transportDomain,
  501|       |                               tmStateRef->transportDomainLen) == 0) {
  502|       |            prefix = "ssh";
  503|       |        }
  504|       |#endif /*  NETSNMP_TRANSPORT_SSH_DOMAIN */
  505|       |
  506|      0|#ifdef NETSNMP_TRANSPORT_DTLSUDP_DOMAIN
  507|      0|        if (netsnmp_oid_equals(netsnmpDTLSUDPDomain,
  ------------------
  |  Branch (507:13): [True: 0, False: 0]
  ------------------
  508|      0|                               netsnmpDTLSUDPDomain_len,
  509|      0|                               tmStateRef->transportDomain,
  510|      0|                               tmStateRef->transportDomainLen) == 0) {
  511|       |            
  512|      0|            prefix = "dtls";
  513|      0|        }
  514|      0|#endif /* NETSNMP_TRANSPORT_DTLSUDP_DOMAIN */
  515|       |
  516|      0|#ifdef NETSNMP_TRANSPORT_TLSTCP_DOMAIN
  517|      0|        if (netsnmp_oid_equals(netsnmpTLSTCPDomain,
  ------------------
  |  Branch (517:13): [True: 0, False: 0]
  ------------------
  518|      0|                               netsnmpTLSTCPDomain_len,
  519|      0|                               tmStateRef->transportDomain,
  520|      0|                               tmStateRef->transportDomainLen) == 0) {
  521|       |            
  522|      0|            prefix = "tls";
  523|      0|        }
  524|      0|#endif /* NETSNMP_TRANSPORT_TLSTCP_DOMAIN */
  525|       |
  526|       |        /* Section 5.2, step 3:
  527|       |          If the prefix lookup fails for any reason, then the
  528|       |          snmpTsmUnknownPrefixes counter is incremented, an error
  529|       |          indication is returned to the calling module, and message
  530|       |          processing stops.
  531|       |        */
  532|      0|        if (prefix == NULL) {
  ------------------
  |  Branch (532:13): [True: 0, False: 0]
  ------------------
  533|      0|            snmp_increment_statistic(STAT_TSM_SNMPTSMUNKNOWNPREFIXES);
  ------------------
  |  |  686|      0|#define  STAT_TSM_SNMPTSMUNKNOWNPREFIXES           45
  ------------------
  534|      0|            SNMP_FREE(tmStateRef);
  ------------------
  |  |   62|      0|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 0, False: 0]
  |  |  |  Branch (62:66): [Folded, False: 0]
  |  |  ------------------
  ------------------
  535|      0|            return SNMPERR_GENERR;
  ------------------
  |  |  185|      0|#define SNMPERR_GENERR			(-1)
  ------------------
  536|      0|        }
  537|       |
  538|       |        /* Section 5.2, step 3:
  539|       |          If the lookup succeeds but the prefix length is less than 1 or
  540|       |          greater than 4 octets, then the snmpTsmInvalidPrefixes counter
  541|       |          is incremented, an error indication is returned to the calling
  542|       |          module, and message processing stops.
  543|       |        */
  544|       |#ifdef NOT_USING_HARDCODED_PREFIXES
  545|       |        /* the above code actually ensures this will never happen as
  546|       |           we don't support a dynamic prefix database where this might
  547|       |           happen. */
  548|       |        if (strlen(prefix) < 1 || strlen(prefix) > 4) {
  549|       |            /* XXX: snmpTsmInvalidPrefixes++ */
  550|       |            SNMP_FREE(tmStateRef);
  551|       |            return SNMPERR_GENERR;
  552|       |        }
  553|       |#endif
  554|       |        
  555|       |        /* Section 5.2, step 3:
  556|       |          Set the securityName to be the concatenation of the prefix, a
  557|       |          ':' character (US-ASCII 0x3a), and the tmSecurityName.
  558|       |        */
  559|      0|        snprintf(parms->secName, *parms->secNameLen,
  560|      0|                 "%s:%s", prefix, tmStateRef->securityName);
  561|      0|    } else {
  562|       |        /* if the use prefix flag wasn't set, do a straight copy */
  563|      0|        strlcpy(parms->secName, tmStateRef->securityName, *parms->secNameLen);
  564|      0|    }
  565|       |
  566|       |    /* set the length of the security name */
  567|      0|    *parms->secNameLen = strlen(parms->secName);
  568|      0|    DEBUGMSGTL(("tsm", "user: %s/%d\n", parms->secName, (int)*parms->secNameLen));
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
  569|       |
  570|       |    /* Section 5.2 Step 4:
  571|       |       Compare the value of tmTransportSecurityLevel in the
  572|       |       tmStateReference cache to the value of the securityLevel
  573|       |       parameter passed in the processIncomingMsg ASI.  If securityLevel
  574|       |       specifies privacy (Priv) and tmTransportSecurityLevel specifies
  575|       |       no privacy (noPriv), or if securityLevel specifies authentication
  576|       |       (auth) and tmTransportSecurityLevel specifies no authentication
  577|       |       (noAuth) was provided by the Transport Model, then the
  578|       |       snmpTsmInadequateSecurityLevels counter is incremented, an error
  579|       |       indication (unsupportedSecurityLevel) together with the OID and
  580|       |       value of the incremented counter is returned to the calling
  581|       |       module, and Transport Security Model processing stops for this
  582|       |       message.*/
  583|      0|    if (parms->secLevel > tmStateRef->transportSecurityLevel) {
  ------------------
  |  Branch (583:9): [True: 0, False: 0]
  ------------------
  584|      0|        snmp_increment_statistic(STAT_TSM_SNMPTSMINADEQUATESECURITYLEVELS);
  ------------------
  |  |  685|      0|#define  STAT_TSM_SNMPTSMINADEQUATESECURITYLEVELS  44
  ------------------
  585|      0|        DEBUGMSGTL(("tsm", "inadequate security level: %d\n", parms->secLevel));
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
  586|      0|        SNMP_FREE(tmStateRef);
  ------------------
  |  |   62|      0|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 0, False: 0]
  |  |  |  Branch (62:66): [Folded, False: 0]
  |  |  ------------------
  ------------------
  587|       |        /* net-snmp returns error codes not OIDs, which are dealt with later */
  588|      0|        return SNMPERR_UNSUPPORTED_SEC_LEVEL;
  ------------------
  |  |  218|      0|#define SNMPERR_UNSUPPORTED_SEC_LEVEL 	(-34)
  ------------------
  589|      0|    }
  590|       |
  591|       |    /* Section 5.2 Step 5
  592|       |       The tmStateReference is cached as cachedSecurityData so that a
  593|       |       possible response to this message will use the same security
  594|       |       parameters.  Then securityStateReference is set for subsequent
  595|       |       references to this cached data.
  596|       |    */
  597|      0|    if (NULL == *parms->secStateRef) {
  ------------------
  |  Branch (597:9): [True: 0, False: 0]
  ------------------
  598|      0|        tsmSecRef = SNMP_MALLOC_TYPEDEF(netsnmp_tsmSecurityReference);
  ------------------
  |  |   73|      0|#define SNMP_MALLOC_TYPEDEF(td)  (td *) calloc(1, sizeof(td))
  ------------------
  599|      0|    } else {
  600|      0|        tsmSecRef = *parms->secStateRef;
  601|      0|    }
  602|       |
  603|      0|    if (NULL == tsmSecRef) {
  ------------------
  |  Branch (603:9): [True: 0, False: 0]
  ------------------
  604|      0|        SNMP_FREE(tmStateRef);
  ------------------
  |  |   62|      0|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 0, False: 0]
  |  |  |  Branch (62:66): [Folded, False: 0]
  |  |  ------------------
  ------------------
  605|      0|        return SNMPERR_GENERR;
  ------------------
  |  |  185|      0|#define SNMPERR_GENERR			(-1)
  ------------------
  606|      0|    }
  607|       |
  608|      0|    *parms->secStateRef = tsmSecRef;
  609|      0|    if (tsmSecRef->tmStateRef != tmStateRef)
  ------------------
  |  Branch (609:9): [True: 0, False: 0]
  ------------------
  610|      0|        SNMP_FREE(tsmSecRef->tmStateRef);
  ------------------
  |  |   62|      0|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 0, False: 0]
  |  |  |  Branch (62:66): [Folded, False: 0]
  |  |  ------------------
  ------------------
  611|      0|    tsmSecRef->tmStateRef = tmStateRef;
  612|       |
  613|       |    /* If this did not come through a tunneled connection, this
  614|       |       security model is inappropriate (and would be a HUGE security
  615|       |       hole to assume otherwise).  This is functionally a double check
  616|       |       since the pdu wouldn't have transport data otherwise.  But this
  617|       |       is safer though is functionally an extra step beyond the TSM
  618|       |       RFC. */
  619|      0|    DEBUGMSGTL(("tsm","checking how we got here\n"));
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
  620|      0|    if (!(parms->pdu->flags & UCD_MSG_FLAG_TUNNELED)) {
  ------------------
  |  |  317|      0|#define UCD_MSG_FLAG_TUNNELED               0x4000
  ------------------
  |  Branch (620:9): [True: 0, False: 0]
  ------------------
  621|      0|        DEBUGMSGTL(("tsm","  pdu not tunneled\n"));
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
  622|      0|        if (!(parms->sess->flags & NETSNMP_TRANSPORT_FLAG_TUNNELED)) {
  ------------------
  |  |   53|      0|#define		NETSNMP_TRANSPORT_FLAG_TUNNELED	 0x04
  ------------------
  |  Branch (622:13): [True: 0, False: 0]
  ------------------
  623|      0|            DEBUGMSGTL(("tsm","  session not tunneled\n"));
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
  624|      0|            return SNMPERR_USM_AUTHENTICATIONFAILURE;
  ------------------
  |  |  230|      0|#define SNMPERR_USM_AUTHENTICATIONFAILURE	(-46)
  ------------------
  625|      0|        }
  626|      0|        DEBUGMSGTL(("tsm","  but session is tunneled\n"));
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
  627|      0|    } else {
  628|      0|        DEBUGMSGTL(("tsm","  tunneled\n"));
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
  629|      0|    }
  630|       |
  631|       |    /* Section 5.2, Step 6:
  632|       |       The scopedPDU component is extracted from the wholeMsg. */
  633|       |    /*
  634|       |     * Eat the first octet header.
  635|       |     */
  636|      0|    remaining = parms->wholeMsgLen - (parms->secParams - parms->wholeMsg);
  637|      0|    if ((data_ptr = asn_parse_sequence(parms->secParams, &remaining,
  ------------------
  |  Branch (637:9): [True: 0, False: 0]
  ------------------
  638|      0|                                        &type_value,
  639|      0|                                        (ASN_UNIVERSAL | ASN_PRIMITIVE |
  ------------------
  |  |   90|      0|#define ASN_UNIVERSAL	    0x00U
  ------------------
                                                      (ASN_UNIVERSAL | ASN_PRIMITIVE |
  ------------------
  |  |   95|      0|#define ASN_PRIMITIVE	    0x00U
  ------------------
  640|      0|                                         ASN_OCTET_STR),
  ------------------
  |  |   78|      0|#define ASN_OCTET_STR	    0x04U
  ------------------
  641|      0|                                        "tsm first octet")) == NULL) {
  642|       |        /*
  643|       |         * RETURN parse error 
  644|       |         */
  645|      0|        return SNMPERR_ASN_PARSE_ERR;
  ------------------
  |  |  213|      0|#define SNMPERR_ASN_PARSE_ERR           (-29)
  ------------------
  646|      0|    }
  647|       |    
  648|      0|    *parms->scopedPdu = data_ptr;
  649|      0|    *parms->scopedPduLen = parms->wholeMsgLen - (data_ptr - parms->wholeMsg);
  650|       |
  651|       |    /* Section 5.2, Step 7:
  652|       |       The maxSizeResponseScopedPDU is calculated.  This is the maximum
  653|       |       size allowed for a scopedPDU for a possible Response message.
  654|       |     */
  655|      0|    *parms->maxSizeResponse = parms->maxMsgSize; /* XXX */
  656|       |
  657|       |    /* Section 5.2, Step 8:
  658|       |       The statusInformation is set to success and a return is made to
  659|       |       the calling module passing back the OUT parameters as specified
  660|       |       in the processIncomingMsg ASI.
  661|       |    */
  662|      0|    return SNMPERR_SUCCESS;
  ------------------
  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
  663|      0|}
snmptsm.c:tsm_free_pdu:
  116|      2|{
  117|       |    /* free the security reference */
  118|      2|    if (pdu->securityStateRef) {
  ------------------
  |  Branch (118:9): [True: 0, False: 2]
  ------------------
  119|      0|        tsm_free_state_ref(pdu->securityStateRef);
  120|       |        pdu->securityStateRef = NULL;
  121|      0|    }
  122|      2|    return 0;
  123|      2|}

usm_add_user:
  645|      6|{
  646|      6|    struct usmUser *uptr;
  647|      6|    uptr = usm_add_user_to_list(user, userList);
  648|      6|    if (uptr != NULL)
  ------------------
  |  Branch (648:9): [True: 6, False: 0]
  ------------------
  649|      6|        userList = uptr;
  650|      6|    return uptr;
  651|      6|}
usm_free_user:
  749|  3.01k|{
  750|  3.01k|    if (user == NULL)
  ------------------
  |  Branch (750:9): [True: 3.01k, False: 0]
  ------------------
  751|  3.01k|        return NULL;
  752|       |
  753|      0|    SNMP_FREE(user->engineID);
  ------------------
  |  |   62|      0|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 0, False: 0]
  |  |  |  Branch (62:66): [Folded, False: 0]
  |  |  ------------------
  ------------------
  754|      0|    SNMP_FREE(user->name);
  ------------------
  |  |   62|      0|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 0, False: 0]
  |  |  |  Branch (62:66): [Folded, False: 0]
  |  |  ------------------
  ------------------
  755|      0|    SNMP_FREE(user->secName);
  ------------------
  |  |   62|      0|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 0, False: 0]
  |  |  |  Branch (62:66): [Folded, False: 0]
  |  |  ------------------
  ------------------
  756|      0|    SNMP_FREE(user->cloneFrom);
  ------------------
  |  |   62|      0|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 0, False: 0]
  |  |  |  Branch (62:66): [Folded, False: 0]
  |  |  ------------------
  ------------------
  757|      0|    SNMP_FREE(user->userPublicString);
  ------------------
  |  |   62|      0|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 0, False: 0]
  |  |  |  Branch (62:66): [Folded, False: 0]
  |  |  ------------------
  ------------------
  758|      0|    SNMP_FREE(user->authProtocol);
  ------------------
  |  |   62|      0|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 0, False: 0]
  |  |  |  Branch (62:66): [Folded, False: 0]
  |  |  ------------------
  ------------------
  759|      0|    SNMP_FREE(user->privProtocol);
  ------------------
  |  |   62|      0|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 0, False: 0]
  |  |  |  Branch (62:66): [Folded, False: 0]
  |  |  ------------------
  ------------------
  760|       |
  761|      0|    if (user->authKey != NULL) {
  ------------------
  |  Branch (761:9): [True: 0, False: 0]
  ------------------
  762|      0|        SNMP_ZERO(user->authKey, user->authKeyLen);
  ------------------
  |  |   77|      0|#define SNMP_ZERO(s,l)	do { if (s) memset(s, 0, l); } while(0)
  |  |  ------------------
  |  |  |  Branch (77:33): [True: 0, False: 0]
  |  |  |  Branch (77:61): [Folded, False: 0]
  |  |  ------------------
  ------------------
  763|      0|        SNMP_FREE(user->authKey);
  ------------------
  |  |   62|      0|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 0, False: 0]
  |  |  |  Branch (62:66): [Folded, False: 0]
  |  |  ------------------
  ------------------
  764|      0|    }
  765|       |
  766|      0|    if (user->privKey != NULL) {
  ------------------
  |  Branch (766:9): [True: 0, False: 0]
  ------------------
  767|      0|        SNMP_ZERO(user->privKey, user->privKeyLen);
  ------------------
  |  |   77|      0|#define SNMP_ZERO(s,l)	do { if (s) memset(s, 0, l); } while(0)
  |  |  ------------------
  |  |  |  Branch (77:33): [True: 0, False: 0]
  |  |  |  Branch (77:61): [Folded, False: 0]
  |  |  ------------------
  ------------------
  768|      0|        SNMP_FREE(user->privKey);
  ------------------
  |  |   62|      0|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 0, False: 0]
  |  |  |  Branch (62:66): [Folded, False: 0]
  |  |  ------------------
  ------------------
  769|      0|    }
  770|       |
  771|      0|    if (user->authKeyKu != NULL) {
  ------------------
  |  Branch (771:9): [True: 0, False: 0]
  ------------------
  772|      0|        SNMP_ZERO(user->authKeyKu, user->authKeyKuLen);
  ------------------
  |  |   77|      0|#define SNMP_ZERO(s,l)	do { if (s) memset(s, 0, l); } while(0)
  |  |  ------------------
  |  |  |  Branch (77:33): [True: 0, False: 0]
  |  |  |  Branch (77:61): [Folded, False: 0]
  |  |  ------------------
  ------------------
  773|      0|        SNMP_FREE(user->authKeyKu);
  ------------------
  |  |   62|      0|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 0, False: 0]
  |  |  |  Branch (62:66): [Folded, False: 0]
  |  |  ------------------
  ------------------
  774|      0|    }
  775|       |
  776|      0|    if (user->privKeyKu != NULL) {
  ------------------
  |  Branch (776:9): [True: 0, False: 0]
  ------------------
  777|      0|        SNMP_ZERO(user->privKeyKu, user->privKeyKuLen);
  ------------------
  |  |   77|      0|#define SNMP_ZERO(s,l)	do { if (s) memset(s, 0, l); } while(0)
  |  |  ------------------
  |  |  |  Branch (77:33): [True: 0, False: 0]
  |  |  |  Branch (77:61): [Folded, False: 0]
  |  |  ------------------
  ------------------
  778|      0|        SNMP_FREE(user->privKeyKu);
  ------------------
  |  |   62|      0|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 0, False: 0]
  |  |  |  Branch (62:66): [Folded, False: 0]
  |  |  ------------------
  ------------------
  779|      0|    }
  780|       |
  781|      0|#ifdef NETSNMP_USE_OPENSSL
  782|      0|    if (user->usmDHUserAuthKeyChange)
  ------------------
  |  Branch (782:9): [True: 0, False: 0]
  ------------------
  783|      0|    {
  784|      0|        DH_free(user->usmDHUserAuthKeyChange);
  785|      0|        user->usmDHUserAuthKeyChange = NULL;
  786|      0|    }
  787|       |
  788|      0|    if (user->usmDHUserPrivKeyChange)
  ------------------
  |  Branch (788:9): [True: 0, False: 0]
  ------------------
  789|      0|    {
  790|      0|        DH_free(user->usmDHUserPrivKeyChange);
  791|      0|        user->usmDHUserPrivKeyChange = NULL;
  792|      0|    }
  793|      0|#endif
  794|       |
  795|       |    /*
  796|       |     * FIX  Why not put this check *first?*
  797|       |     */
  798|      0|    if (user->prev != NULL && user->prev != (struct usmUser *)-1) {   /* ack, this shouldn't happen */
  ------------------
  |  Branch (798:9): [True: 0, False: 0]
  |  Branch (798:31): [True: 0, False: 0]
  ------------------
  799|      0|        user->prev->next = user->next;
  800|      0|    }
  801|      0|    if (user->next != NULL && user->next != (struct usmUser *)-1) {
  ------------------
  |  Branch (801:9): [True: 0, False: 0]
  |  Branch (801:31): [True: 0, False: 0]
  ------------------
  802|      0|        user->next->prev = user->prev;
  803|      0|        if (user->prev != NULL) /* ack this is really bad, because it means
  ------------------
  |  Branch (803:13): [True: 0, False: 0]
  ------------------
  804|       |                                 * * we'll loose the head of some structure tree */
  805|      0|            DEBUGMSGTL(("usm",
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
  806|      0|                        "Severe: Asked to free the head of a usmUser tree somewhere."));
  807|      0|    }
  808|       |
  809|       |
  810|      0|    SNMP_ZERO(user, sizeof(*user));
  ------------------
  |  |   77|      0|#define SNMP_ZERO(s,l)	do { if (s) memset(s, 0, l); } while(0)
  |  |  ------------------
  |  |  |  Branch (77:33): [True: 0, False: 0]
  |  |  |  Branch (77:61): [Folded, False: 0]
  |  |  ------------------
  ------------------
  811|      0|    SNMP_FREE(user);
  ------------------
  |  |   62|      0|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 0, False: 0]
  |  |  |  Branch (62:66): [Folded, False: 0]
  |  |  ------------------
  ------------------
  812|       |
  813|      0|    return NULL;                /* for convenience to returns from calling functions */
  814|       |
  815|  3.01k|}                               /* end usm_free_user() */
usm_lookup_auth_type:
 4029|      4|{
 4030|      4|    return usm_lookup_alg_type(str, usm_auth_type );
 4031|      4|}
usm_lookup_priv_type:
 4035|      4|{
 4036|      4|    return usm_lookup_alg_type(str, usm_priv_type );
 4037|      4|}
usm_create_user:
 4160|      8|{
 4161|      8|    struct usmUser *newUser;
 4162|       |
 4163|       |    /*
 4164|       |     * create the new user 
 4165|       |     */
 4166|      8|    newUser = calloc(1, sizeof(struct usmUser));
 4167|      8|    if (newUser == NULL)
  ------------------
  |  Branch (4167:9): [True: 0, False: 8]
  ------------------
 4168|      0|        return NULL;
 4169|       |
 4170|       |    /*
 4171|       |     * fill the auth/priv protocols 
 4172|       |     */
 4173|      8|    if ((newUser->authProtocol =
  ------------------
  |  Branch (4173:9): [True: 0, False: 8]
  ------------------
 4174|      8|         snmp_duplicate_objid(usmNoAuthProtocol,
 4175|      8|                              OID_LENGTH(usmNoAuthProtocol))) ==
  ------------------
  |  |   64|      8|    (sizeof(x) / sizeof((x)[0]) +                                       \
  |  |   65|      8|     sizeof(int[-__builtin_types_compatible_p(typeof(x), typeof(&(x)[0]))]))
  ------------------
 4176|      8|        NULL)
 4177|      0|        return usm_free_user(newUser);
 4178|      8|    newUser->authProtocolLen = OID_LENGTH(usmNoAuthProtocol);
  ------------------
  |  |   64|      8|    (sizeof(x) / sizeof((x)[0]) +                                       \
  |  |   65|      8|     sizeof(int[-__builtin_types_compatible_p(typeof(x), typeof(&(x)[0]))]))
  ------------------
 4179|       |
 4180|      8|    if ((newUser->privProtocol =
  ------------------
  |  Branch (4180:9): [True: 0, False: 8]
  ------------------
 4181|      8|         snmp_duplicate_objid(usmNoPrivProtocol,
 4182|      8|                              OID_LENGTH(usmNoPrivProtocol))) ==
  ------------------
  |  |   64|      8|    (sizeof(x) / sizeof((x)[0]) +                                       \
  |  |   65|      8|     sizeof(int[-__builtin_types_compatible_p(typeof(x), typeof(&(x)[0]))]))
  ------------------
 4183|      8|        NULL)
 4184|      0|        return usm_free_user(newUser);
 4185|      8|    newUser->privProtocolLen = OID_LENGTH(usmNoPrivProtocol);
  ------------------
  |  |   64|      8|    (sizeof(x) / sizeof((x)[0]) +                                       \
  |  |   65|      8|     sizeof(int[-__builtin_types_compatible_p(typeof(x), typeof(&(x)[0]))]))
  ------------------
 4186|       |
 4187|       |    /*
 4188|       |     * set the storage type to nonvolatile, and the status to ACTIVE 
 4189|       |     */
 4190|      8|    newUser->userStorageType = ST_NONVOLATILE;
  ------------------
  |  |   52|      8|#define ST_NONVOLATILE	3
  ------------------
 4191|      8|    newUser->userStatus = RS_ACTIVE;
  ------------------
  |  |   35|      8|#define RS_ACTIVE	        1
  ------------------
 4192|      8|    return newUser;
 4193|       |
 4194|      8|}                               /* end usm_clone_user() */
usm_parse_create_usmUser:
 5131|      6|{
 5132|      6|    const char *error = NULL;
 5133|      6|    usm_create_usmUser_from_string(line, &error);
 5134|      6|    if (error)
  ------------------
  |  Branch (5134:9): [True: 0, False: 6]
  ------------------
 5135|      0|        config_perror(error);
 5136|      6|}
get_default_authtype:
 5150|      6|{
 5151|      6|    if (defaultAuthType == NULL) {
  ------------------
  |  Branch (5151:9): [True: 2, False: 4]
  ------------------
 5152|      2|        defaultAuthType = SNMP_DEFAULT_AUTH_PROTO;
  ------------------
  |  |   94|      2|#define SNMP_DEFAULT_AUTH_PROTO     usmHMACMD5AuthProtocol
  ------------------
 5153|      2|        defaultAuthTypeLen = SNMP_DEFAULT_AUTH_PROTOLEN;
  ------------------
  |  |   98|      2|#define SNMP_DEFAULT_AUTH_PROTOLEN  OID_LENGTH(SNMP_DEFAULT_AUTH_PROTO)
  |  |  ------------------
  |  |  |  |   64|      2|    (sizeof(x) / sizeof((x)[0]) +                                       \
  |  |  |  |   65|      2|     sizeof(int[-__builtin_types_compatible_p(typeof(x), typeof(&(x)[0]))]))
  |  |  ------------------
  ------------------
 5154|      2|    }
 5155|      6|    if (len)
  ------------------
  |  Branch (5155:9): [True: 6, False: 0]
  ------------------
 5156|      6|        *len = defaultAuthTypeLen;
 5157|      6|    return defaultAuthType;
 5158|      6|}
get_default_privtype:
 5172|      6|{
 5173|      6|    if (defaultPrivType == NULL) {
  ------------------
  |  Branch (5173:9): [True: 2, False: 4]
  ------------------
 5174|      2|        defaultPrivType = SNMP_DEFAULT_PRIV_PROTO;
  ------------------
  |  |  100|      2|#define SNMP_DEFAULT_PRIV_PROTO     usmDESPrivProtocol
  ------------------
 5175|      2|        defaultPrivTypeLen = SNMP_DEFAULT_PRIV_PROTOLEN;
  ------------------
  |  |  104|      2|#define SNMP_DEFAULT_PRIV_PROTOLEN  OID_LENGTH(SNMP_DEFAULT_PRIV_PROTO)
  |  |  ------------------
  |  |  |  |   64|      2|    (sizeof(x) / sizeof((x)[0]) +                                       \
  |  |  |  |   65|      2|     sizeof(int[-__builtin_types_compatible_p(typeof(x), typeof(&(x)[0]))]))
  |  |  ------------------
  ------------------
 5176|      2|    }
 5177|      6|    if (len)
  ------------------
  |  Branch (5177:9): [True: 6, False: 0]
  ------------------
 5178|      6|        *len = defaultPrivTypeLen;
 5179|      6|    return defaultPrivType;
 5180|      6|}
init_usm:
 5272|      2|{
 5273|      2|    struct snmp_secmod_def *def;
 5274|      2|    char *type;
 5275|       |
 5276|      2|    DEBUGMSGTL(("init_usm", "unit_usm: %" NETSNMP_PRIo "u %" NETSNMP_PRIo "u\n",
  ------------------
  |  |   66|      2|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      2|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 2]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 2]
  |  |  ------------------
  ------------------
 5277|      2|                usmNoPrivProtocol[0], usmNoPrivProtocol[1]));
 5278|       |
 5279|      2|    sc_init();                  /* initialize scapi code */
 5280|       |
 5281|       |    /*
 5282|       |     * register ourselves as a security service
 5283|       |     */
 5284|      2|    def = SNMP_MALLOC_STRUCT(snmp_secmod_def);
  ------------------
  |  |   69|      2|#define SNMP_MALLOC_STRUCT(s)   (struct s *) calloc(1, sizeof(struct s))
  ------------------
 5285|      2|    if (def == NULL)
  ------------------
  |  Branch (5285:9): [True: 0, False: 2]
  ------------------
 5286|      0|        return;
 5287|       |    /*
 5288|       |     * XXX: def->init_sess_secmod move stuff from snmp_api.c
 5289|       |     */
 5290|      2|    def->encode_reverse = usm_secmod_rgenerate_out_msg;
 5291|      2|    def->encode_forward = usm_secmod_generate_out_msg;
 5292|      2|    def->decode = usm_secmod_process_in_msg;
 5293|      2|    def->pdu_clone = usm_clone;
 5294|      2|    def->pdu_free_state_ref = usm_free_usmStateReference;
 5295|      2|    def->session_setup = usm_session_init;
 5296|      2|    def->handle_report = usm_handle_report;
 5297|      2|    def->probe_engineid = usm_discover_engineid;
 5298|      2|    def->post_probe_engineid = usm_create_user_from_session_hook;
 5299|      2|    if (register_sec_mod(USM_SEC_MODEL_NUMBER, "usm", def) != SNMPERR_SUCCESS) {
  ------------------
  |  |   40|      2|#define USM_SEC_MODEL_NUMBER            SNMP_SEC_MODEL_USM
  |  |  ------------------
  |  |  |  |  295|      2|#define SNMP_SEC_MODEL_USM		3
  |  |  ------------------
  ------------------
                  if (register_sec_mod(USM_SEC_MODEL_NUMBER, "usm", def) != SNMPERR_SUCCESS) {
  ------------------
  |  |  184|      2|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
  |  Branch (5299:9): [True: 0, False: 2]
  ------------------
 5300|      0|        SNMP_FREE(def);
  ------------------
  |  |   62|      0|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 0, False: 0]
  |  |  |  Branch (62:66): [Folded, False: 0]
  |  |  ------------------
  ------------------
 5301|      0|        snmp_log(LOG_ERR, "could not register usm sec mod\n");
 5302|      0|        return;
 5303|      0|    }
 5304|       |
 5305|      2|    snmp_register_callback(SNMP_CALLBACK_LIBRARY,
  ------------------
  |  |   18|      2|#define SNMP_CALLBACK_LIBRARY     0
  ------------------
 5306|      2|                           SNMP_CALLBACK_POST_PREMIB_READ_CONFIG,
  ------------------
  |  |   27|      2|#define SNMP_CALLBACK_POST_PREMIB_READ_CONFIG	3
  ------------------
 5307|      2|                           init_usm_post_config, NULL);
 5308|       |
 5309|      2|    snmp_register_callback(SNMP_CALLBACK_LIBRARY,
  ------------------
  |  |   18|      2|#define SNMP_CALLBACK_LIBRARY     0
  ------------------
 5310|      2|                           SNMP_CALLBACK_SHUTDOWN,
  ------------------
  |  |   26|      2|#define SNMP_CALLBACK_SHUTDOWN		        2
  ------------------
 5311|      2|                           deinit_usm_post_config, NULL);
 5312|       |
 5313|      2|    snmp_register_callback(SNMP_CALLBACK_LIBRARY,
  ------------------
  |  |   18|      2|#define SNMP_CALLBACK_LIBRARY     0
  ------------------
 5314|      2|                           SNMP_CALLBACK_SHUTDOWN,
  ------------------
  |  |   26|      2|#define SNMP_CALLBACK_SHUTDOWN		        2
  ------------------
 5315|      2|                           free_engineID, NULL);
 5316|       |
 5317|      2|    register_config_handler("snmp", "defAuthType", snmpv3_authtype_conf,
 5318|      2|                            NULL, "MD5|SHA|SHA-512|SHA-384|SHA-256|SHA-224");
 5319|      2|    register_config_handler("snmp", "defPrivType", snmpv3_privtype_conf,
 5320|      2|                            NULL,
 5321|      2|                            "DES"
 5322|      2|#ifdef HAVE_AES
 5323|      2|                            "|AES|AES-128"
 5324|      2|#ifdef NETSNMP_DRAFT_BLUMENTHAL_AES_04
 5325|      2|                            "|AES-192|AES-256"
 5326|      2|#endif /* NETSNMP_DRAFT_BLUMENTHAL_AES_04 */
 5327|       |#else
 5328|       |                            " (AES support not available)"
 5329|       |#endif
 5330|      2|                           );
 5331|       |
 5332|       |    /*
 5333|       |     * Free stuff at shutdown time
 5334|       |     */
 5335|      2|    snmp_register_callback(SNMP_CALLBACK_LIBRARY,
  ------------------
  |  |   18|      2|#define SNMP_CALLBACK_LIBRARY     0
  ------------------
 5336|      2|                           SNMP_CALLBACK_SHUTDOWN,
  ------------------
  |  |   26|      2|#define SNMP_CALLBACK_SHUTDOWN		        2
  ------------------
 5337|      2|                           free_enginetime_on_shutdown, NULL);
 5338|       |
 5339|       |
 5340|      2|    type = netsnmp_ds_get_string(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_APPTYPE);
  ------------------
  |  |   48|      2|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
                  type = netsnmp_ds_get_string(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_APPTYPE);
  ------------------
  |  |  157|      2|#define NETSNMP_DS_LIB_APPTYPE           6
  ------------------
 5341|       |
 5342|      2|    register_config_handler(type, "userSetAuthPass", usm_set_password,
 5343|      2|                            NULL, NULL);
 5344|      2|    register_config_handler(type, "userSetPrivPass", usm_set_password,
 5345|      2|                            NULL, NULL);
 5346|      2|    register_config_handler(type, "userSetAuthKey", usm_set_password, NULL,
 5347|      2|                            NULL);
 5348|      2|    register_config_handler(type, "userSetPrivKey", usm_set_password, NULL,
 5349|      2|                            NULL);
 5350|      2|    register_config_handler(type, "userSetAuthLocalKey", usm_set_password,
 5351|      2|                            NULL, NULL);
 5352|      2|    register_config_handler(type, "userSetPrivLocalKey", usm_set_password,
 5353|      2|                            NULL, NULL);
 5354|      2|}
snmpusm.c:usm_get_user_from_list:
  482|  1.58k|{
  483|  1.58k|    struct usmUser *ptr;
  484|       |
  485|  6.32k|    for (ptr = puserList; ptr != NULL; ptr = ptr->next) {
  ------------------
  |  Branch (485:27): [True: 4.74k, False: 1.58k]
  ------------------
  486|  4.74k|        if (ptr->name && strlen(ptr->name) == nameLen &&
  ------------------
  |  Branch (486:13): [True: 4.74k, False: 0]
  |  Branch (486:26): [True: 104, False: 4.64k]
  ------------------
  487|    104|            memcmp(ptr->name, name, nameLen) == 0) {
  ------------------
  |  Branch (487:13): [True: 32, False: 72]
  ------------------
  488|     32|          DEBUGMSGTL(("usm", "match on user %s\n", ptr->name));
  ------------------
  |  |   66|     32|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     32|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 32]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 32]
  |  |  ------------------
  ------------------
  489|     32|          if (ptr->engineIDLen == engineIDLen &&
  ------------------
  |  Branch (489:15): [True: 24, False: 8]
  ------------------
  490|     24|            ((ptr->engineID == NULL && engineID == NULL) ||
  ------------------
  |  Branch (490:15): [True: 0, False: 24]
  |  Branch (490:40): [True: 0, False: 0]
  ------------------
  491|     24|             (ptr->engineID != NULL && engineID != NULL &&
  ------------------
  |  Branch (491:15): [True: 24, False: 0]
  |  Branch (491:40): [True: 24, False: 0]
  ------------------
  492|     24|              memcmp(ptr->engineID, engineID, engineIDLen) == 0)))
  ------------------
  |  Branch (492:15): [True: 0, False: 24]
  ------------------
  493|      0|            return ptr;
  494|     32|          DEBUGMSGTL(("usm", "no match on engineID ("));
  ------------------
  |  |   66|     32|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     32|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 32]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 32]
  |  |  ------------------
  ------------------
  495|     32|          if (engineID) {
  ------------------
  |  Branch (495:15): [True: 32, False: 0]
  ------------------
  496|     32|              DEBUGMSGHEX(("usm", engineID, engineIDLen));
  ------------------
  |  |   71|     32|#define DEBUGMSGHEX(x)     do {if (_DBG_IF_) {__DBGMSGHEX(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     32|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 32]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGHEX(x)     do {if (_DBG_IF_) {__DBGMSGHEX(x);} }while(0)
  |  |  ------------------
  |  |  |  |  169|      0|#define __DBGMSGHEX(x)     debugmsg_hex x
  |  |  ------------------
  |  |  |  Branch (71:71): [Folded, False: 32]
  |  |  ------------------
  ------------------
  497|     32|          } else {
  498|      0|              DEBUGMSGTL(("usm", "Empty EngineID"));
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
  499|      0|          }
  500|     32|          DEBUGMSG(("usm", ")\n"));
  ------------------
  |  |   61|     32|#define DEBUGMSG(x)        do {if (_DBG_IF_) {debugmsg x;} }while(0)
  |  |  ------------------
  |  |  |  |  144|     32|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 32]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (61:67): [Folded, False: 32]
  |  |  ------------------
  ------------------
  501|     32|        }
  502|  4.74k|    }
  503|       |
  504|       |    /*
  505|       |     * return "" user used to facilitate engineID discovery
  506|       |     */
  507|  1.58k|    if (use_default && !strcmp(name, "")) {
  ------------------
  |  Branch (507:9): [True: 1.58k, False: 0]
  |  Branch (507:24): [True: 1.29k, False: 283]
  ------------------
  508|  1.29k|        DEBUGMSGTL(("usm", "return noNameUser\n"));
  ------------------
  |  |   66|  1.29k|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|  1.29k|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 1.29k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 1.29k]
  |  |  ------------------
  ------------------
  509|  1.29k|        return noNameUser;
  510|  1.29k|    }
  511|    283|    return NULL;
  512|  1.58k|}
snmpusm.c:usm_add_user_to_list:
  536|      6|{
  537|      6|    struct usmUser *nptr, *pptr, *optr;
  538|       |
  539|       |    /*
  540|       |     * loop through puserList till we find the proper, sorted place to
  541|       |     * insert the new user
  542|       |     */
  543|       |    /* XXX - how to handle a NULL user->name ?? */
  544|       |    /* XXX - similarly for a NULL nptr->name ?? */
  545|     12|    for (nptr = puserList, pptr = NULL; nptr != NULL;
  ------------------
  |  Branch (545:41): [True: 6, False: 6]
  ------------------
  546|      6|         pptr = nptr, nptr = nptr->next) {
  547|      6|        if (nptr->engineIDLen > user->engineIDLen)
  ------------------
  |  Branch (547:13): [True: 0, False: 6]
  ------------------
  548|      0|            break;
  549|       |
  550|      6|        if (user->engineID == NULL && nptr->engineID != NULL)
  ------------------
  |  Branch (550:13): [True: 0, False: 6]
  |  Branch (550:39): [True: 0, False: 0]
  ------------------
  551|      0|            break;
  552|       |
  553|      6|        if (nptr->engineIDLen == user->engineIDLen &&
  ------------------
  |  Branch (553:13): [True: 6, False: 0]
  ------------------
  554|      6|            (nptr->engineID != NULL && user->engineID != NULL &&
  ------------------
  |  Branch (554:14): [True: 6, False: 0]
  |  Branch (554:40): [True: 6, False: 0]
  ------------------
  555|      6|             memcmp(nptr->engineID, user->engineID,
  ------------------
  |  Branch (555:14): [True: 0, False: 6]
  ------------------
  556|      6|                    user->engineIDLen) > 0))
  557|      0|            break;
  558|       |
  559|      6|        if (!(nptr->engineID == NULL && user->engineID != NULL)) {
  ------------------
  |  Branch (559:15): [True: 0, False: 6]
  |  Branch (559:41): [True: 0, False: 0]
  ------------------
  560|      6|            if (nptr->engineIDLen == user->engineIDLen &&
  ------------------
  |  Branch (560:17): [True: 6, False: 0]
  ------------------
  561|      6|                ((nptr->engineID == NULL && user->engineID == NULL) ||
  ------------------
  |  Branch (561:19): [True: 0, False: 6]
  |  Branch (561:45): [True: 0, False: 0]
  ------------------
  562|      6|                 memcmp(nptr->engineID, user->engineID,
  ------------------
  |  Branch (562:18): [True: 6, False: 0]
  ------------------
  563|      6|                        user->engineIDLen) == 0)
  564|      6|                && strlen(nptr->name) > strlen(user->name))
  ------------------
  |  Branch (564:20): [True: 0, False: 6]
  ------------------
  565|      0|                break;
  566|       |
  567|      6|            if (nptr->engineIDLen == user->engineIDLen &&
  ------------------
  |  Branch (567:17): [True: 6, False: 0]
  ------------------
  568|      6|                ((nptr->engineID == NULL && user->engineID == NULL) ||
  ------------------
  |  Branch (568:19): [True: 0, False: 6]
  |  Branch (568:45): [True: 0, False: 0]
  ------------------
  569|      6|                 memcmp(nptr->engineID, user->engineID,
  ------------------
  |  Branch (569:18): [True: 6, False: 0]
  ------------------
  570|      6|                        user->engineIDLen) == 0)
  571|      6|                && strlen(nptr->name) == strlen(user->name)
  ------------------
  |  Branch (571:20): [True: 2, False: 4]
  ------------------
  572|      2|                && strcmp(nptr->name, user->name) > 0)
  ------------------
  |  Branch (572:20): [True: 0, False: 2]
  ------------------
  573|      0|                break;
  574|       |
  575|      6|            if (nptr->engineIDLen == user->engineIDLen &&
  ------------------
  |  Branch (575:17): [True: 6, False: 0]
  ------------------
  576|      6|                ((nptr->engineID == NULL && user->engineID == NULL) ||
  ------------------
  |  Branch (576:19): [True: 0, False: 6]
  |  Branch (576:45): [True: 0, False: 0]
  ------------------
  577|      6|                 memcmp(nptr->engineID, user->engineID,
  ------------------
  |  Branch (577:18): [True: 6, False: 0]
  ------------------
  578|      6|                        user->engineIDLen) == 0)
  579|      6|                && strlen(nptr->name) == strlen(user->name)
  ------------------
  |  Branch (579:20): [True: 2, False: 4]
  ------------------
  580|      2|                && strcmp(nptr->name, user->name) == 0) {
  ------------------
  |  Branch (580:20): [True: 0, False: 2]
  ------------------
  581|       |                /*
  582|       |                 * the user is an exact match of a previous entry.
  583|       |                 * Credentials may be different, though, so remove
  584|       |                 * the old entry (and add the new one)!
  585|       |                 */
  586|      0|                if (pptr) { /* change prev's next pointer */
  ------------------
  |  Branch (586:21): [True: 0, False: 0]
  ------------------
  587|      0|                  pptr->next = nptr->next;
  588|      0|                }
  589|      0|                if (nptr->next) { /* change next's prev pointer */
  ------------------
  |  Branch (589:21): [True: 0, False: 0]
  ------------------
  590|      0|                  nptr->next->prev = pptr;
  591|      0|                }
  592|      0|                optr = nptr;
  593|      0|                nptr = optr->next; /* add new user at this position */
  594|       |                /* free the old user */
  595|      0|                optr->next=NULL;
  596|      0|                optr->prev=NULL;
  597|      0|                usm_free_user(optr);
  598|      0|                break; /* new user will be added below */
  599|      0|            }
  600|      6|        }
  601|      6|    }
  602|       |
  603|       |    /*
  604|       |     * nptr should now point to the user that we need to add ourselves
  605|       |     * in front of, and pptr should be our new 'prev'.
  606|       |     */
  607|       |
  608|       |    /*
  609|       |     * change our pointers
  610|       |     */
  611|      6|    user->prev = pptr;
  612|      6|    user->next = nptr;
  613|       |
  614|       |    /*
  615|       |     * change the next's prev pointer
  616|       |     */
  617|      6|    if (user->next)
  ------------------
  |  Branch (617:9): [True: 0, False: 6]
  ------------------
  618|      0|        user->next->prev = user;
  619|       |
  620|       |    /*
  621|       |     * change the prev's next pointer
  622|       |     */
  623|      6|    if (user->prev)
  ------------------
  |  Branch (623:9): [True: 4, False: 2]
  ------------------
  624|      4|        user->prev->next = user;
  625|       |
  626|       |    /*
  627|       |     * rewind to the head of the list and return it (since the new head
  628|       |     * could be us, we need to notify the above routine who the head now is.
  629|       |     */
  630|     12|    for (pptr = user; pptr->prev != NULL; pptr = pptr->prev);
  ------------------
  |  Branch (630:23): [True: 6, False: 6]
  ------------------
  631|      6|    return pptr;
  632|      6|}
snmpusm.c:usm_lookup_alg_type:
 4005|      8|{
 4006|      8|    int i, l;
 4007|      8|    l = strlen(str);
 4008|     24|    for (i = 0; types[i].label; ++i) {
  ------------------
  |  Branch (4008:17): [True: 24, False: 0]
  ------------------
 4009|     24|        if (0 == strncasecmp(types[i].label, str, l))
  ------------------
  |  Branch (4009:13): [True: 8, False: 16]
  ------------------
 4010|      8|            return types[i].value;
 4011|     24|    }
 4012|       |
 4013|      0|    return -1;
 4014|      8|}
snmpusm.c:usm_create_usmUser_from_string:
 4708|      6|{
 4709|      6|    char           *cp;
 4710|      6|    const char     *dummy;
 4711|      6|    char            buf[SNMP_MAXBUF_MEDIUM];
 4712|      6|    struct usmUser *newuser;
 4713|      6|    u_char          userKey[SNMP_MAXBUF_SMALL], *tmpp;
 4714|      6|    size_t          userKeyLen = SNMP_MAXBUF_SMALL;
  ------------------
  |  |   45|      6|#define SNMP_MAXBUF_SMALL	512
  ------------------
 4715|      6|    size_t          privKeySize;
 4716|      6|    size_t          ret;
 4717|      6|    int             ret2, properLen, properPrivKeyLen;
 4718|      6|    const oid      *def_auth_prot, *def_priv_prot;
 4719|      6|    size_t          def_auth_prot_len, def_priv_prot_len;
 4720|      6|    const netsnmp_priv_alg_info *pai;
 4721|       |
 4722|      6|    def_auth_prot = get_default_authtype(&def_auth_prot_len);
 4723|      6|    def_priv_prot = get_default_privtype(&def_priv_prot_len);
 4724|       |
 4725|      6|    if (NULL == line)
  ------------------
  |  Branch (4725:9): [True: 0, False: 6]
  ------------------
 4726|      0|        return NULL;
 4727|       |
 4728|       |#ifdef NETSNMP_ENABLE_TESTING_CODE
 4729|       |    DEBUGMSGTL(("usmUser", "new user %s\n", line)); /* logs passphrases */
 4730|       |#endif
 4731|       |
 4732|      6|    if (NULL == errorMsg)
  ------------------
  |  Branch (4732:9): [True: 0, False: 6]
  ------------------
 4733|      0|        errorMsg = &dummy;
 4734|      6|    *errorMsg = NULL; /* no errors yet */
 4735|       |
 4736|      6|    newuser = usm_create_user();
 4737|      6|    if (newuser == NULL) {
  ------------------
  |  Branch (4737:9): [True: 0, False: 6]
  ------------------
 4738|      0|        *errorMsg = "malloc failure creating new user";
 4739|      0|        goto fail;
 4740|      0|    }
 4741|       |
 4742|       |    /*
 4743|       |     * READ: Security Name 
 4744|       |     */
 4745|      6|    cp = copy_nword(line, buf, sizeof(buf));
 4746|       |
 4747|       |    /*
 4748|       |     * check for (undocumented) 'keep master key' flag. so far, this is
 4749|       |     * just used for users for informs (who need non-localized keys).
 4750|       |     */
 4751|      6|    if (strcmp(buf, "-M") == 0) {
  ------------------
  |  Branch (4751:9): [True: 0, False: 6]
  ------------------
 4752|      0|        newuser->flags |= USMUSER_FLAG_KEEP_MASTER_KEY;
  ------------------
  |  |   87|      0|#define USMUSER_FLAG_KEEP_MASTER_KEY             0x01
  ------------------
 4753|      0|        cp = copy_nword(cp, buf, sizeof(buf));
 4754|      0|    }
 4755|       |
 4756|       |    /*
 4757|       |     * might be a -e ENGINEID argument 
 4758|       |     */
 4759|      6|    if (strcmp(buf, "-e") == 0) {
  ------------------
  |  Branch (4759:9): [True: 0, False: 6]
  ------------------
 4760|      0|        size_t          ebuf_len = 32, eout_len = 0;
 4761|      0|        u_char         *ebuf = (u_char *) malloc(ebuf_len);
 4762|       |
 4763|      0|        if (ebuf == NULL) {
  ------------------
  |  Branch (4763:13): [True: 0, False: 0]
  ------------------
 4764|      0|            *errorMsg = "malloc failure processing -e flag";
 4765|      0|            goto fail;
 4766|      0|        }
 4767|       |
 4768|       |        /*
 4769|       |         * Get the specified engineid from the line.  
 4770|       |         */
 4771|      0|        cp = copy_nword(cp, buf, sizeof(buf));
 4772|      0|        if (!snmp_hex_to_binary(&ebuf, &ebuf_len, &eout_len, 1, buf)) {
  ------------------
  |  Branch (4772:13): [True: 0, False: 0]
  ------------------
 4773|      0|            *errorMsg = "invalid EngineID argument to -e";
 4774|      0|            SNMP_FREE(ebuf);
  ------------------
  |  |   62|      0|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 0, False: 0]
  |  |  |  Branch (62:66): [Folded, False: 0]
  |  |  ------------------
  ------------------
 4775|      0|            goto fail;
 4776|      0|        }
 4777|       |
 4778|      0|        newuser->engineID = ebuf;
 4779|      0|        newuser->engineIDLen = eout_len;
 4780|       |
 4781|       |        /*
 4782|       |        * set the lcd entry for this engineID to the minimum boots/time
 4783|       |        * values so that its a known engineid and won't return a report pdu.
 4784|       |        * This is mostly important when receiving v3 traps so that the usm
 4785|       |        * will at least continue processing them.
 4786|       |        * Note: We do this at the end so that it only runs if the parsing
 4787|       |        * was successful
 4788|       |        */
 4789|      0|        set_enginetime(newuser->engineID, newuser->engineIDLen, 1, 0, 0);
 4790|       |
 4791|       |
 4792|      0|        cp = copy_nword(cp, buf, sizeof(buf));        
 4793|      6|    } else {
 4794|      6|        newuser->engineID = snmpv3_generate_engineID(&ret);
 4795|      6|        if (ret == 0) {
  ------------------
  |  Branch (4795:13): [True: 0, False: 6]
  ------------------
 4796|      0|            goto fail;
 4797|      0|        }
 4798|      6|        newuser->engineIDLen = ret;
 4799|      6|    }
 4800|       |
 4801|      6|    newuser->secName = strdup(buf);
 4802|      6|    newuser->name = strdup(buf);
 4803|       |
 4804|      6|    if (!cp) {
  ------------------
  |  Branch (4804:9): [True: 2, False: 4]
  ------------------
 4805|       |#ifdef NETSNMP_FORCE_SYSTEM_V3_AUTHPRIV
 4806|       |        /** no passwords ok iff defaults are noauth/nopriv */
 4807|       |        if (snmp_oid_compare(usmNoAuthProtocol, OID_LENGTH(usmNoAuthProtocol),
 4808|       |                             def_auth_prot, def_auth_prot_len) != 0) {
 4809|       |            *errorMsg = "no authentication pass phrase";
 4810|       |            goto fail;
 4811|       |        }
 4812|       |        if (snmp_oid_compare(usmNoPrivProtocol, OID_LENGTH(usmNoPrivProtocol),
 4813|       |                             def_priv_prot, def_priv_prot_len) != 0) {
 4814|       |            *errorMsg = "no privacy pass phrase";
 4815|       |            goto fail;
 4816|       |        }
 4817|       |#endif /* NETSNMP_FORCE_SYSTEM_V3_AUTHPRIV */
 4818|      2|        goto add;               /* no authentication or privacy type */
 4819|      2|    }
 4820|       |
 4821|       |    /*
 4822|       |     * READ: Authentication Type 
 4823|       |     */
 4824|      4|    newuser->authProtocol[0] = 0;
 4825|      4|    cp = copy_nword(cp, buf, sizeof(buf));
 4826|       |    /* If no authentication protocol was specified, or it was explicitly
 4827|       |     * set to use the default, use the default auth protocol
 4828|       |     */
 4829|      4|    if (buf[0] == '\0' || strcmp(buf, "default") == 0) {
  ------------------
  |  Branch (4829:9): [True: 0, False: 4]
  |  Branch (4829:27): [True: 0, False: 4]
  ------------------
 4830|      0|        SNMP_FREE(newuser->authProtocol);
  ------------------
  |  |   62|      0|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 0, False: 0]
  |  |  |  Branch (62:66): [Folded, False: 0]
  |  |  ------------------
  ------------------
 4831|      0|        if (!def_auth_prot) {
  ------------------
  |  Branch (4831:13): [True: 0, False: 0]
  ------------------
 4832|      0|            *errorMsg = "def_auth_prot == NULL";
 4833|      0|            goto fail;
 4834|      0|        }
 4835|      0|        newuser->authProtocol = snmp_duplicate_objid(def_auth_prot,
 4836|      0|                                                     def_auth_prot_len);
 4837|      0|        if (newuser->authProtocol == NULL) {
  ------------------
  |  Branch (4837:13): [True: 0, False: 0]
  ------------------
 4838|      0|            *errorMsg = "malloc failed";
 4839|      0|            goto fail;
 4840|      0|        }
 4841|      0|        newuser->authProtocolLen = def_auth_prot_len;
 4842|      4|    } else {
 4843|      4|        const oid *auth_prot;
 4844|      4|        int auth_type = usm_lookup_auth_type(buf);
 4845|      4|        if (auth_type < 0) {
  ------------------
  |  Branch (4845:13): [True: 0, False: 4]
  ------------------
 4846|      0|            *errorMsg = "unknown authProtocol";
 4847|      0|            goto fail;
 4848|      0|        }
 4849|      4|        auth_prot = sc_get_auth_oid(auth_type, &newuser->authProtocolLen);
 4850|      4|        if (auth_prot) {
  ------------------
  |  Branch (4850:13): [True: 4, False: 0]
  ------------------
 4851|      4|            SNMP_FREE(newuser->authProtocol);
  ------------------
  |  |   62|      4|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 4, False: 0]
  |  |  |  Branch (62:66): [Folded, False: 4]
  |  |  ------------------
  ------------------
 4852|      4|            newuser->authProtocol =
 4853|      4|                snmp_duplicate_objid(auth_prot, newuser->authProtocolLen);
 4854|      4|        }
 4855|      4|        if (newuser->authProtocol == NULL) {
  ------------------
  |  Branch (4855:13): [True: 0, False: 4]
  ------------------
 4856|      0|            *errorMsg = "malloc failed";
 4857|      0|            goto fail;
 4858|      0|        }
 4859|      4|    }
 4860|      4|    if (0 == newuser->authProtocol[0]) {
  ------------------
  |  Branch (4860:9): [True: 0, False: 4]
  ------------------
 4861|      0|        *errorMsg = "Unknown authentication protocol";
 4862|      0|        goto fail;
 4863|      0|    }
 4864|       |#ifdef NETSNMP_FORCE_SYSTEM_V3_AUTHPRIV
 4865|       |    if (snmp_oid_compare(newuser->authProtocol, newuser->authProtocolLen,
 4866|       |                         def_auth_prot, def_auth_prot_len) != 0) {
 4867|       |        *errorMsg = "auth protocol does not match system policy";
 4868|       |        goto fail;
 4869|       |    }
 4870|       |#endif /* NETSNMP_FORCE_SYSTEM_V3_AUTHPRIV */
 4871|       |
 4872|       |    /*
 4873|       |     * READ: Authentication Pass Phrase or key
 4874|       |     */
 4875|      4|    cp = copy_nword(cp, buf, sizeof(buf));
 4876|      4|    if (strcmp(buf,"-m") == 0) {
  ------------------
  |  Branch (4876:9): [True: 0, False: 4]
  ------------------
 4877|       |        /* a master key is specified */
 4878|      0|        cp = copy_nword(cp, buf, sizeof(buf));
 4879|      0|        ret = sizeof(userKey);
 4880|      0|        tmpp = userKey;
 4881|      0|        userKeyLen = 0;
 4882|      0|        if (!snmp_hex_to_binary(&tmpp, &ret, &userKeyLen, 0, buf)) {
  ------------------
  |  Branch (4882:13): [True: 0, False: 0]
  ------------------
 4883|      0|            *errorMsg = "invalid key value argument to -m";
 4884|      0|            goto fail;
 4885|      0|        }
 4886|       |        /* save master key */
 4887|      0|        if (newuser->flags & USMUSER_FLAG_KEEP_MASTER_KEY) {
  ------------------
  |  |   87|      0|#define USMUSER_FLAG_KEEP_MASTER_KEY             0x01
  ------------------
  |  Branch (4887:13): [True: 0, False: 0]
  ------------------
 4888|      0|            newuser->authKeyKu = netsnmp_memdup(userKey, userKeyLen);
 4889|      0|            newuser->authKeyKuLen = userKeyLen;
 4890|      0|        }
 4891|      4|    } else if (strcmp(buf,"-l") != 0) {
  ------------------
  |  Branch (4891:16): [True: 4, False: 0]
  ------------------
 4892|       |        /* a password is specified */
 4893|      4|        userKeyLen = sizeof(userKey);
 4894|      4|        ret2 = generate_Ku(newuser->authProtocol, newuser->authProtocolLen,
 4895|      4|                          (u_char *) buf, strlen(buf), userKey, &userKeyLen);
 4896|      4|        if (ret2 != SNMPERR_SUCCESS) {
  ------------------
  |  |  184|      4|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
  |  Branch (4896:13): [True: 0, False: 4]
  ------------------
 4897|      0|            *errorMsg = "could not generate the authentication key from the supplied pass phrase.";
 4898|      0|            goto fail;
 4899|      0|        }
 4900|       |        /* save master key */
 4901|      4|        if (newuser->flags & USMUSER_FLAG_KEEP_MASTER_KEY) {
  ------------------
  |  |   87|      4|#define USMUSER_FLAG_KEEP_MASTER_KEY             0x01
  ------------------
  |  Branch (4901:13): [True: 0, False: 4]
  ------------------
 4902|      0|            newuser->authKeyKu = netsnmp_memdup(userKey, userKeyLen);
 4903|      0|            newuser->authKeyKuLen = userKeyLen;
 4904|      0|        }
 4905|      4|    }        
 4906|       |        
 4907|       |    /*
 4908|       |     * And turn it into a localized key 
 4909|       |     */
 4910|      4|    properLen = sc_get_proper_auth_length_bytype(
 4911|      4|        sc_get_authtype(newuser->authProtocol, newuser->authProtocolLen));
 4912|      4|    if (properLen <= 0) {
  ------------------
  |  Branch (4912:9): [True: 0, False: 4]
  ------------------
 4913|      0|        *errorMsg = "Could not get proper authentication protocol key length";
 4914|      0|        goto fail;
 4915|      0|    }
 4916|      4|    newuser->authKey = malloc(properLen);
 4917|      4|    newuser->authKeyLen = properLen;
 4918|       |
 4919|      4|    if (strcmp(buf,"-l") == 0) {
  ------------------
  |  Branch (4919:9): [True: 0, False: 4]
  ------------------
 4920|       |        /* a local key is directly specified */
 4921|      0|        cp = copy_nword(cp, buf, sizeof(buf));
 4922|      0|        ret = newuser->authKeyLen;
 4923|      0|        newuser->authKeyLen = 0;
 4924|      0|        if (!snmp_hex_to_binary(&newuser->authKey, &ret,
  ------------------
  |  Branch (4924:13): [True: 0, False: 0]
  ------------------
 4925|      0|                                &newuser->authKeyLen, 0, buf)) {
 4926|      0|            *errorMsg = "invalid key value argument to -l";
 4927|      0|            goto fail;
 4928|      0|        }
 4929|      0|        if (properLen != newuser->authKeyLen) {
  ------------------
  |  Branch (4929:13): [True: 0, False: 0]
  ------------------
 4930|      0|            *errorMsg = "improper key length to -l";
 4931|      0|            goto fail;
 4932|      0|        }
 4933|      4|    } else {
 4934|      4|        ret2 = generate_kul(newuser->authProtocol, newuser->authProtocolLen,
 4935|      4|                           newuser->engineID, newuser->engineIDLen,
 4936|      4|                           userKey, userKeyLen,
 4937|      4|                           newuser->authKey, &newuser->authKeyLen);
 4938|      4|        if (ret2 != SNMPERR_SUCCESS) {
  ------------------
  |  |  184|      4|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
  |  Branch (4938:13): [True: 0, False: 4]
  ------------------
 4939|      0|            *errorMsg = "could not generate localized authentication key (Kul) from the master key (Ku).";
 4940|      0|            goto fail;
 4941|      0|        }
 4942|      4|    }
 4943|       |
 4944|      4|    if (!cp) {
  ------------------
  |  Branch (4944:9): [True: 0, False: 4]
  ------------------
 4945|      0|#ifndef NETSNMP_FORCE_SYSTEM_V3_AUTHPRIV
 4946|      0|        goto add;               /* no privacy type (which is legal) */
 4947|       |#else
 4948|       |        if (snmp_oid_compare(usmNoPrivProtocol, OID_LENGTH(usmNoPrivProtocol),
 4949|       |                             def_priv_prot, def_priv_prot_len) == 0)
 4950|       |            goto add;
 4951|       |        else {
 4952|       |            *errorMsg = "priv protocol does not match system policy";
 4953|       |            goto fail;
 4954|       |        }
 4955|       |#endif /* NETSNMP_FORCE_SYSTEM_V3_AUTHPRIV */
 4956|      0|    }
 4957|       |
 4958|       |    /*
 4959|       |     * READ: Privacy Type 
 4960|       |     */
 4961|      4|    newuser->privProtocol[0] = 0;
 4962|      4|    cp = copy_nword(cp, buf, sizeof(buf));
 4963|      4|    if ((strncmp(buf, "default", 7) == 0) && (NULL != def_priv_prot)) {
  ------------------
  |  Branch (4963:9): [True: 0, False: 4]
  |  Branch (4963:46): [True: 0, False: 0]
  ------------------
 4964|      0|        SNMP_FREE(newuser->privProtocol);
  ------------------
  |  |   62|      0|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 0, False: 0]
  |  |  |  Branch (62:66): [Folded, False: 0]
  |  |  ------------------
  ------------------
 4965|      0|        newuser->privProtocol =
 4966|      0|            snmp_duplicate_objid(def_priv_prot, def_priv_prot_len);
 4967|      0|        if (newuser->privProtocol == NULL) {
  ------------------
  |  Branch (4967:13): [True: 0, False: 0]
  ------------------
 4968|      0|            *errorMsg = "malloc failed";
 4969|      0|            goto fail;
 4970|      0|        }
 4971|      0|        newuser->privProtocolLen = def_priv_prot_len;
 4972|      0|        pai = sc_get_priv_alg_byoid(newuser->privProtocol,
 4973|      0|                                    newuser->privProtocolLen);
 4974|      4|    } else {
 4975|      4|        int priv_type = usm_lookup_priv_type(buf);
 4976|      4|        if (priv_type < 0) {
  ------------------
  |  Branch (4976:13): [True: 0, False: 4]
  ------------------
 4977|      0|            *errorMsg = "unknown privProtocol";
 4978|      0|            DEBUGMSGTL(("usmUser", "%s %s\n", *errorMsg, buf));
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
 4979|      0|            goto fail;
 4980|      0|        }
 4981|      4|        DEBUGMSGTL(("9:usmUser", "privProtocol %s\n", buf));
  ------------------
  |  |   66|      4|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      4|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 4]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 4]
  |  |  ------------------
  ------------------
 4982|      4|        pai = sc_get_priv_alg_bytype(priv_type);
 4983|      4|        if (pai) {
  ------------------
  |  Branch (4983:13): [True: 4, False: 0]
  ------------------
 4984|      4|            SNMP_FREE(newuser->privProtocol);
  ------------------
  |  |   62|      4|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 4, False: 0]
  |  |  |  Branch (62:66): [Folded, False: 4]
  |  |  ------------------
  ------------------
 4985|      4|            newuser->privProtocolLen = pai->oid_len;
 4986|      4|            newuser->privProtocol =
 4987|      4|                snmp_duplicate_objid(pai->alg_oid, newuser->privProtocolLen);
 4988|      4|            DEBUGMSGTL(("9:usmUser", "pai %s\n", pai->name));
  ------------------
  |  |   66|      4|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      4|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 4]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 4]
  |  |  ------------------
  ------------------
 4989|      4|            if (newuser->privProtocol == NULL) {
  ------------------
  |  Branch (4989:17): [True: 0, False: 4]
  ------------------
 4990|      0|                *errorMsg = "malloc failed";
 4991|      0|                goto fail;
 4992|      0|            }
 4993|      4|        }
 4994|      4|    }
 4995|      4|    if (NULL == pai) {
  ------------------
  |  Branch (4995:9): [True: 0, False: 4]
  ------------------
 4996|      0|        *errorMsg = "priv protocol lookup failed";
 4997|      0|        goto fail;
 4998|      0|    }
 4999|       |
 5000|      4|    if (0 == newuser->privProtocol[0] && NULL == *errorMsg)
  ------------------
  |  Branch (5000:9): [True: 0, False: 4]
  |  Branch (5000:42): [True: 0, False: 0]
  ------------------
 5001|      0|        *errorMsg = "Unknown privacy protocol";
 5002|      4|    if (NULL != *errorMsg)
  ------------------
  |  Branch (5002:9): [True: 0, False: 4]
  ------------------
 5003|      0|        goto fail;
 5004|       |#ifdef NETSNMP_FORCE_SYSTEM_V3_AUTHPRIV
 5005|       |    if (snmp_oid_compare(newuser->privProtocol, newuser->privProtocolLen,
 5006|       |                         def_priv_prot, def_priv_prot_len) != 0) {
 5007|       |        *errorMsg = "priv protocol does not match system policy";
 5008|       |        goto fail;
 5009|       |    }
 5010|       |#endif /* NETSNMP_FORCE_SYSTEM_V3_AUTHPRIV */
 5011|       |
 5012|      4|    properPrivKeyLen = pai->proper_length;
 5013|      4|    if (USM_CREATE_USER_PRIV_DES == pai->type)
  ------------------
  |  |  172|      4|#define USM_CREATE_USER_PRIV_DES            0x01
  ------------------
  |  Branch (5013:9): [True: 2, False: 2]
  ------------------
 5014|      2|        properPrivKeyLen *= 2; /* ?? we store salt with key */
 5015|       |
 5016|       |    /*
 5017|       |     * READ: Encryption Pass Phrase or key
 5018|       |     */
 5019|      4|    if (!cp) {
  ------------------
  |  Branch (5019:9): [True: 0, False: 4]
  ------------------
 5020|       |        /*
 5021|       |         * assume the same as the authentication key 
 5022|       |         */
 5023|      0|        newuser->privKey = netsnmp_memdup(newuser->authKey,
 5024|      0|                                          newuser->authKeyLen);
 5025|      0|        privKeySize = newuser->privKeyLen = newuser->authKeyLen;
 5026|      0|        if (newuser->flags & USMUSER_FLAG_KEEP_MASTER_KEY) {
  ------------------
  |  |   87|      0|#define USMUSER_FLAG_KEEP_MASTER_KEY             0x01
  ------------------
  |  Branch (5026:13): [True: 0, False: 0]
  ------------------
 5027|      0|            newuser->privKeyKu = netsnmp_memdup(newuser->authKeyKu,
 5028|      0|                                                newuser->authKeyKuLen);
 5029|      0|            newuser->privKeyKuLen = newuser->authKeyKuLen;
 5030|      0|        }
 5031|      4|    } else {
 5032|      4|        cp = copy_nword(cp, buf, sizeof(buf));
 5033|       |        
 5034|      4|        if (strcmp(buf,"-m") == 0) {
  ------------------
  |  Branch (5034:13): [True: 0, False: 4]
  ------------------
 5035|       |            /* a master key is specified */
 5036|      0|            cp = copy_nword(cp, buf, sizeof(buf));
 5037|      0|            ret = sizeof(userKey);
 5038|      0|            tmpp = userKey;
 5039|      0|            userKeyLen = 0;
 5040|      0|            if (!snmp_hex_to_binary(&tmpp, &ret, &userKeyLen, 0, buf)) {
  ------------------
  |  Branch (5040:17): [True: 0, False: 0]
  ------------------
 5041|      0|                *errorMsg = "invalid key value argument to -m";
 5042|      0|                goto fail;
 5043|      0|            }
 5044|       |            /* save master key */
 5045|      0|            if (newuser->flags & USMUSER_FLAG_KEEP_MASTER_KEY) {
  ------------------
  |  |   87|      0|#define USMUSER_FLAG_KEEP_MASTER_KEY             0x01
  ------------------
  |  Branch (5045:17): [True: 0, False: 0]
  ------------------
 5046|      0|                newuser->privKeyKu = netsnmp_memdup(userKey, userKeyLen);
 5047|      0|                newuser->privKeyKuLen = userKeyLen;
 5048|      0|            }
 5049|      4|        } else if (strcmp(buf,"-l") != 0) {
  ------------------
  |  Branch (5049:20): [True: 4, False: 0]
  ------------------
 5050|       |            /* a password is specified */
 5051|      4|            userKeyLen = sizeof(userKey);
 5052|      4|            ret2 = generate_Ku(newuser->authProtocol, newuser->authProtocolLen,
 5053|      4|                              (u_char*)buf, strlen(buf), userKey, &userKeyLen);
 5054|      4|            if (ret2 != SNMPERR_SUCCESS) {
  ------------------
  |  |  184|      4|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
  |  Branch (5054:17): [True: 0, False: 4]
  ------------------
 5055|      0|                *errorMsg = "could not generate the privacy key from the supplied pass phrase.";
 5056|      0|                goto fail;
 5057|      0|            }
 5058|       |            /* save master key */
 5059|      4|            if (newuser->flags & USMUSER_FLAG_KEEP_MASTER_KEY) {
  ------------------
  |  |   87|      4|#define USMUSER_FLAG_KEEP_MASTER_KEY             0x01
  ------------------
  |  Branch (5059:17): [True: 0, False: 4]
  ------------------
 5060|      0|                newuser->privKeyKu = netsnmp_memdup(userKey, userKeyLen);
 5061|      0|                newuser->privKeyKuLen = userKeyLen;
 5062|      0|            }
 5063|      4|        }
 5064|       |
 5065|       |        /*
 5066|       |         * And turn it into a localized key
 5067|       |         * Allocate enough space for greater of auth mac and privKey len.
 5068|       |         */
 5069|      4|        privKeySize = SNMP_MAX(properPrivKeyLen, properLen);
  ------------------
  |  |  107|      4|#define SNMP_MAX(a,b) ((a) > (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (107:24): [True: 0, False: 4]
  |  |  ------------------
  ------------------
 5070|      4|        newuser->privKey = malloc(privKeySize);
 5071|      4|        newuser->privKeyLen = privKeySize;
 5072|       |
 5073|      4|        if (strcmp(buf,"-l") == 0) {
  ------------------
  |  Branch (5073:13): [True: 0, False: 4]
  ------------------
 5074|       |            /* a local key is directly specified */
 5075|      0|            cp = copy_nword(cp, buf, sizeof(buf));
 5076|      0|            ret = newuser->privKeyLen;
 5077|      0|            newuser->privKeyLen = 0;
 5078|      0|            if (!snmp_hex_to_binary(&newuser->privKey, &ret,
  ------------------
  |  Branch (5078:17): [True: 0, False: 0]
  ------------------
 5079|      0|                                    &newuser->privKeyLen, 0, buf)) {
 5080|      0|                *errorMsg = "invalid key value argument to -l";
 5081|      0|                goto fail;
 5082|      0|            }
 5083|      4|        } else {
 5084|      4|            ret2 = generate_kul(newuser->authProtocol, newuser->authProtocolLen,
 5085|      4|                               newuser->engineID, newuser->engineIDLen,
 5086|      4|                               userKey, userKeyLen,
 5087|      4|                               newuser->privKey, &newuser->privKeyLen);
 5088|      4|            if (ret2 != SNMPERR_SUCCESS) {
  ------------------
  |  |  184|      4|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
  |  Branch (5088:17): [True: 0, False: 4]
  ------------------
 5089|      0|                *errorMsg = "could not generate localized privacy key (Kul) from the master key (Ku).";
 5090|      0|                goto fail;
 5091|      0|            }
 5092|      4|        }
 5093|       |
 5094|      4|        if (newuser->privKeyLen < properPrivKeyLen) {
  ------------------
  |  Branch (5094:13): [True: 0, False: 4]
  ------------------
 5095|      0|            ret = usm_extend_user_kul(newuser, properPrivKeyLen);
 5096|      0|            if (ret != SNMPERR_SUCCESS) {
  ------------------
  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
  |  Branch (5096:17): [True: 0, False: 0]
  ------------------
 5097|      0|                *errorMsg = "could not extend localized privacy key to required length.";
 5098|      0|                goto fail;
 5099|      0|            }
 5100|      0|        }
 5101|      4|    }
 5102|       |
 5103|      4|    if ((newuser->privKeyLen >= properPrivKeyLen) || (properPrivKeyLen == 0)){
  ------------------
  |  Branch (5103:9): [True: 4, False: 0]
  |  Branch (5103:54): [True: 0, False: 0]
  ------------------
 5104|      4|        DEBUGMSGTL(("9:usmUser", "truncating privKeyLen from %" NETSNMP_PRIz "d to %d\n",
  ------------------
  |  |   66|      4|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      4|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 4]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 4]
  |  |  ------------------
  ------------------
 5105|      4|                    newuser->privKeyLen, properPrivKeyLen));
 5106|      4|        newuser->privKeyLen = properPrivKeyLen;
 5107|      4|    }
 5108|      0|    else {
 5109|      0|        DEBUGMSGTL(("usmUser",
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
 5110|      0|                    "privKey length %" NETSNMP_PRIz "d < %d required by privProtocol\n",
 5111|      0|                    newuser->privKeyLen, properPrivKeyLen));
 5112|      0|      *errorMsg = "privKey length is less than required by privProtocol";
 5113|      0|      goto fail;
 5114|      0|    }
 5115|       |
 5116|      6|  add:
 5117|      6|    usm_add_user(newuser);
 5118|      6|    DEBUGMSGTL(("usmUser", "created a new user %s at ", newuser->secName));
  ------------------
  |  |   66|      6|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      6|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 6]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 6]
  |  |  ------------------
  ------------------
 5119|      6|    DEBUGMSGHEX(("usmUser", newuser->engineID, newuser->engineIDLen));
  ------------------
  |  |   71|      6|#define DEBUGMSGHEX(x)     do {if (_DBG_IF_) {__DBGMSGHEX(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      6|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 6]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGHEX(x)     do {if (_DBG_IF_) {__DBGMSGHEX(x);} }while(0)
  |  |  ------------------
  |  |  |  |  169|      0|#define __DBGMSGHEX(x)     debugmsg_hex x
  |  |  ------------------
  |  |  |  Branch (71:71): [Folded, False: 6]
  |  |  ------------------
  ------------------
 5120|      6|    DEBUGMSG(("usmUser", "\n"));
  ------------------
  |  |   61|      6|#define DEBUGMSG(x)        do {if (_DBG_IF_) {debugmsg x;} }while(0)
  |  |  ------------------
  |  |  |  |  144|      6|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 6]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (61:67): [Folded, False: 6]
  |  |  ------------------
  ------------------
 5121|       |
 5122|      6|    return newuser;
 5123|       |
 5124|      0|  fail:
 5125|      0|    usm_free_user(newuser);
 5126|       |    return NULL;
 5127|      4|}
snmpusm.c:usm_secmod_process_in_msg:
 3360|  1.83k|{
 3361|  1.83k|    if (!parms)
  ------------------
  |  Branch (3361:9): [True: 0, False: 1.83k]
  ------------------
 3362|      0|        return SNMPERR_GENERR;
  ------------------
  |  |  185|      0|#define SNMPERR_GENERR			(-1)
  ------------------
 3363|       |
 3364|  1.83k|    return usm_process_in_msg(parms->msgProcModel,
 3365|  1.83k|                              parms->maxMsgSize,
 3366|  1.83k|                              parms->secParams,
 3367|  1.83k|                              parms->secModel,
 3368|  1.83k|                              parms->secLevel,
 3369|  1.83k|                              parms->wholeMsg,
 3370|  1.83k|                              parms->wholeMsgLen,
 3371|  1.83k|                              parms->secEngineID,
 3372|  1.83k|                              parms->secEngineIDLen,
 3373|  1.83k|                              parms->secName,
 3374|  1.83k|                              parms->secNameLen,
 3375|  1.83k|                              parms->scopedPdu,
 3376|  1.83k|                              parms->scopedPduLen,
 3377|  1.83k|                              parms->maxSizeResponse,
 3378|  1.83k|                              parms->secStateRef,
 3379|  1.83k|                              parms->sess, parms->msg_flags);
 3380|  1.83k|}
snmpusm.c:usm_process_in_msg:
 2958|  1.83k|{                               /* IN     - v3 Message flags.              */
 2959|  1.83k|    size_t          remaining = wholeMsgLen - (secParams - wholeMsg);
 2960|  1.83k|    u_int           boots_uint;
 2961|  1.83k|    u_int           time_uint;
 2962|  1.83k|#ifdef HAVE_AES
 2963|  1.83k|    u_int           net_boots, net_time;
 2964|  1.83k|#endif
 2965|  1.83k|#ifndef NETSNMP_DISABLE_DES
 2966|  1.83k|    int             i;
 2967|  1.83k|#endif
 2968|  1.83k|    u_char          signature[USM_MAX_AUTHSIZE];
 2969|  1.83k|    size_t          signature_length = USM_MAX_AUTHSIZE;
  ------------------
  |  |   38|  1.83k|#define USM_MAX_AUTHSIZE                USM_HMAC384SHA512_AUTH_LEN
  |  |  ------------------
  |  |  |  |   37|  1.83k|#define USM_HMAC384SHA512_AUTH_LEN      48      /* SHOULD */
  |  |  ------------------
  ------------------
 2970|  1.83k|    u_char          salt[BYTESIZE(USM_MAX_SALT_LENGTH)];
 2971|  1.83k|    size_t          salt_length = BYTESIZE(USM_MAX_SALT_LENGTH);
  ------------------
  |  |   55|  1.83k|#define BYTESIZE(bitsize)       ((bitsize + 7) >> 3)
  ------------------
 2972|  1.83k|    u_char          iv[BYTESIZE(USM_MAX_SALT_LENGTH)];
 2973|  1.83k|    u_int           iv_length = BYTESIZE(USM_MAX_SALT_LENGTH);
  ------------------
  |  |   55|  1.83k|#define BYTESIZE(bitsize)       ((bitsize + 7) >> 3)
  ------------------
 2974|  1.83k|    u_char         *data_ptr;
 2975|  1.83k|    u_char         *value_ptr;
 2976|  1.83k|    u_char          type_value;
 2977|  1.83k|    u_char         *end_of_overhead = NULL;
 2978|  1.83k|    int             error;
 2979|  1.83k|    int             rc = 0;
 2980|  1.83k|    struct usmStateReference **secStateRef =
 2981|  1.83k|        (struct usmStateReference **) secStateRf;
 2982|       |
 2983|  1.83k|    struct usmUser *user;
 2984|       |
 2985|       |
 2986|  1.83k|    DEBUGMSGTL(("usm", "USM processing begun...\n"));
  ------------------
  |  |   66|  1.83k|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|  1.83k|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 1.83k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 1.83k]
  |  |  ------------------
  ------------------
 2987|       |
 2988|  1.83k|    netsnmp_assert(secStateRef);
  ------------------
  |  |   47|  1.83k|#      define netsnmp_assert(x)  do { \
  |  |   48|  1.83k|              if ( x ) \
  |  |  ------------------
  |  |  |  Branch (48:20): [True: 1.83k, False: 0]
  |  |  ------------------
  |  |   49|  1.83k|                 ; \
  |  |   50|  1.83k|              else \
  |  |   51|  1.83k|                 snmp_log(LOG_ERR, \
  |  |   52|      0|                          "netsnmp_assert %s failed %s:%d" NETSNMP_FUNC_FMT, \
  |  |  ------------------
  |  |  |  |   40|      0|#          define NETSNMP_FUNC_FMT " %s()\n"
  |  |  ------------------
  |  |   53|      0|                          __STRING(x),__FILE__,__LINE__, \
  |  |   54|      0|                          NETSNMP_FUNC_PARAM); \
  |  |  ------------------
  |  |  |  |   41|      0|#          define NETSNMP_FUNC_PARAM NETSNMP_FUNCTION
  |  |  |  |  ------------------
  |  |  |  |  |  | 1727|      0|#define NETSNMP_FUNCTION __func__
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   55|  1.83k|           }while(0)
  |  |  ------------------
  |  |  |  Branch (55:19): [Folded, False: 1.83k]
  |  |  ------------------
  ------------------
 2989|       |
 2990|  1.83k|    usm_free_usmStateReference(*secStateRef);
 2991|  1.83k|    *secStateRef = usm_malloc_usmStateReference();
 2992|  1.83k|    if (*secStateRef == NULL) {
  ------------------
  |  Branch (2992:9): [True: 0, False: 1.83k]
  ------------------
 2993|      0|        DEBUGMSGTL(("usm", "Out of memory.\n"));
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
 2994|      0|        return SNMPERR_USM_GENERICERROR;
  ------------------
  |  |  226|      0|#define SNMPERR_USM_GENERICERROR		(-42)
  ------------------
 2995|      0|    }
 2996|       |
 2997|       |    /*
 2998|       |     * Make sure the *secParms is an OCTET STRING.
 2999|       |     * Extract the user name, engine ID, and security level.
 3000|       |     */
 3001|  1.83k|    if ((rc = usm_parse_security_parameters(secParams, remaining,
  ------------------
  |  Branch (3001:9): [True: 242, False: 1.58k]
  ------------------
 3002|  1.83k|                                            secEngineID, secEngineIDLen,
 3003|  1.83k|                                            &boots_uint, &time_uint,
 3004|  1.83k|                                            secName, secNameLen,
 3005|  1.83k|                                            signature, &signature_length,
 3006|  1.83k|                                            salt, &salt_length,
 3007|  1.83k|                                            &data_ptr)) < 0) {
 3008|    242|        DEBUGMSGTL(("usm", "Parsing failed (rc %d).\n", rc));
  ------------------
  |  |   66|    242|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|    242|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 242]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 242]
  |  |  ------------------
  ------------------
 3009|    242|        if (rc == -2) {
  ------------------
  |  Branch (3009:13): [True: 8, False: 234]
  ------------------
 3010|       |            /*
 3011|       |             * This indicates a decryptionError.  
 3012|       |             */
 3013|      8|            snmp_increment_statistic(STAT_USMSTATSDECRYPTIONERRORS);
  ------------------
  |  |  625|      8|#define   STAT_USMSTATSDECRYPTIONERRORS      8
  ------------------
 3014|      8|            error = SNMPERR_USM_DECRYPTIONERROR;
  ------------------
  |  |  234|      8|#define SNMPERR_USM_DECRYPTIONERROR		(-50)
  ------------------
 3015|    234|        } else {
 3016|    234|            snmp_increment_statistic(STAT_SNMPINASNPARSEERRS);
  ------------------
  |  |  637|    234|#define  STAT_SNMPINASNPARSEERRS             14
  ------------------
 3017|    234|            error = SNMPERR_USM_PARSEERROR;
  ------------------
  |  |  231|    234|#define SNMPERR_USM_PARSEERROR			(-47)
  ------------------
 3018|    234|        }
 3019|    242|        goto err;
 3020|    242|    }
 3021|       |
 3022|       |    /*
 3023|       |     * RFC 2574 section 8.3.2
 3024|       |     * 1)  If the privParameters field is not an 8-octet OCTET STRING,
 3025|       |     * then an error indication (decryptionError) is returned to the
 3026|       |     * calling module.
 3027|       |     */
 3028|  1.58k|    if ((secLevel == SNMP_SEC_LEVEL_AUTHPRIV) && (salt_length != 8)) {
  ------------------
  |  |  301|  1.58k|#define SNMP_SEC_LEVEL_AUTHPRIV		3
  ------------------
  |  Branch (3028:9): [True: 8, False: 1.58k]
  |  Branch (3028:50): [True: 6, False: 2]
  ------------------
 3029|      6|        snmp_increment_statistic(STAT_USMSTATSDECRYPTIONERRORS);
  ------------------
  |  |  625|      6|#define   STAT_USMSTATSDECRYPTIONERRORS      8
  ------------------
 3030|      6|        error = SNMPERR_USM_DECRYPTIONERROR;
  ------------------
  |  |  234|      6|#define SNMPERR_USM_DECRYPTIONERROR		(-50)
  ------------------
 3031|      6|        goto err;
 3032|      6|    }
 3033|       |
 3034|  1.58k|    if (secLevel != SNMP_SEC_LEVEL_AUTHPRIV) {
  ------------------
  |  |  301|  1.58k|#define SNMP_SEC_LEVEL_AUTHPRIV		3
  ------------------
  |  Branch (3034:9): [True: 1.58k, False: 2]
  ------------------
 3035|       |        /*
 3036|       |         * pull these out now so reports can use them 
 3037|       |         */
 3038|  1.58k|        *scopedPdu = data_ptr;
 3039|  1.58k|        *scopedPduLen = wholeMsgLen - (data_ptr - wholeMsg);
 3040|  1.58k|        end_of_overhead = data_ptr;
 3041|  1.58k|    }
 3042|       |
 3043|       |    /*
 3044|       |     * Cache the name, engine ID, and security level,
 3045|       |     * * per step 2 (section 3.2)
 3046|       |     */
 3047|  1.58k|    if (usm_set_usmStateReference_name
  ------------------
  |  Branch (3047:9): [True: 0, False: 1.58k]
  ------------------
 3048|  1.58k|        (*secStateRef, secName, *secNameLen) == -1) {
 3049|      0|        DEBUGMSGTL(("usm", "%s\n", "Couldn't cache name."));
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
 3050|      0|        error = SNMPERR_USM_GENERICERROR;
  ------------------
  |  |  226|      0|#define SNMPERR_USM_GENERICERROR		(-42)
  ------------------
 3051|      0|        goto err;
 3052|      0|    }
 3053|       |
 3054|  1.58k|    if (usm_set_usmStateReference_engine_id
  ------------------
  |  Branch (3054:9): [True: 0, False: 1.58k]
  ------------------
 3055|  1.58k|        (*secStateRef, secEngineID, *secEngineIDLen) == -1) {
 3056|      0|        DEBUGMSGTL(("usm", "%s\n", "Couldn't cache engine id."));
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
 3057|      0|        error = SNMPERR_USM_GENERICERROR;
  ------------------
  |  |  226|      0|#define SNMPERR_USM_GENERICERROR		(-42)
  ------------------
 3058|      0|        goto err;
 3059|      0|    }
 3060|       |
 3061|  1.58k|    if (usm_set_usmStateReference_sec_level(*secStateRef, secLevel) ==
  ------------------
  |  Branch (3061:9): [True: 0, False: 1.58k]
  ------------------
 3062|  1.58k|        -1) {
 3063|      0|        DEBUGMSGTL(("usm", "%s\n", "Couldn't cache security level."));
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
 3064|      0|        error = SNMPERR_USM_GENERICERROR;
  ------------------
  |  |  226|      0|#define SNMPERR_USM_GENERICERROR		(-42)
  ------------------
 3065|      0|        goto err;
 3066|      0|    }
 3067|       |
 3068|       |    /*
 3069|       |     * Locate the engine ID record.
 3070|       |     * If it is unknown, then either create one or note this as an error.
 3071|       |     */
 3072|  1.58k|    if ((sess && (sess->isAuthoritative == SNMP_SESS_AUTHORITATIVE ||
  ------------------
  |  |  125|  3.16k|#define SNMP_SESS_AUTHORITATIVE    1    /* don't learn engineIDs */
  ------------------
  |  Branch (3072:10): [True: 1.58k, False: 0]
  |  Branch (3072:19): [True: 0, False: 1.58k]
  ------------------
 3073|  1.58k|                  (sess->isAuthoritative == SNMP_SESS_UNKNOWNAUTH &&
  ------------------
  |  |  126|  3.16k|#define SNMP_SESS_UNKNOWNAUTH      2    /* sometimes (like NRs) */
  ------------------
  |  Branch (3073:20): [True: 0, False: 1.58k]
  ------------------
 3074|      0|                   (msg_flags & SNMP_MSG_FLAG_RPRT_BIT)))) ||
  ------------------
  |  |  305|      0|#define SNMP_MSG_FLAG_RPRT_BIT          0x04
  ------------------
  |  Branch (3074:20): [True: 0, False: 0]
  ------------------
 3075|  1.58k|        (!sess && (msg_flags & SNMP_MSG_FLAG_RPRT_BIT))) {
  ------------------
  |  |  305|      0|#define SNMP_MSG_FLAG_RPRT_BIT          0x04
  ------------------
  |  Branch (3075:10): [True: 0, False: 1.58k]
  |  Branch (3075:19): [True: 0, False: 0]
  ------------------
 3076|      0|        if (ISENGINEKNOWN(secEngineID, *secEngineIDLen) == FALSE) {
  ------------------
  |  |   82|      0|	( (get_enginetime(e, e_l,				\
  |  |  ------------------
  |  |  |  Branch (82:4): [True: 0, False: 0]
  |  |  ------------------
  |  |   83|      0|		&dummy_eboot, &dummy_etime, TRUE) == SNMPERR_SUCCESS)	\
  |  |  ------------------
  |  |  |  |  128|      0|#define TRUE  1
  |  |  ------------------
  |  |               		&dummy_eboot, &dummy_etime, TRUE) == SNMPERR_SUCCESS)	\
  |  |  ------------------
  |  |  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  ------------------
  |  |   84|      0|		? TRUE						\
  |  |  ------------------
  |  |  |  |  128|      0|#define TRUE  1
  |  |  ------------------
  |  |   85|      0|		: FALSE )
  |  |  ------------------
  |  |  |  |  125|      0|#define FALSE 0
  |  |  ------------------
  ------------------
                      if (ISENGINEKNOWN(secEngineID, *secEngineIDLen) == FALSE) {
  ------------------
  |  |  125|      0|#define FALSE 0
  ------------------
  |  Branch (3076:13): [True: 0, False: 0]
  ------------------
 3077|      0|            DEBUGMSGTL(("usm", "Unknown Engine ID.\n"));
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
 3078|      0|            snmp_increment_statistic(STAT_USMSTATSUNKNOWNENGINEIDS);
  ------------------
  |  |  623|      0|#define   STAT_USMSTATSUNKNOWNENGINEIDS      6
  ------------------
 3079|      0|            error = SNMPERR_USM_UNKNOWNENGINEID;
  ------------------
  |  |  232|      0|#define SNMPERR_USM_UNKNOWNENGINEID		(-48)
  ------------------
 3080|      0|            goto err;
 3081|      0|        }
 3082|  1.58k|    } else {
 3083|  1.58k|        if (ENSURE_ENGINE_RECORD(secEngineID, *secEngineIDLen)
  ------------------
  |  |   88|  1.58k|	( (set_enginetime(e, e_l, 0, 0, FALSE) == SNMPERR_SUCCESS)	\
  |  |  ------------------
  |  |  |  |  125|  1.58k|#define FALSE 0
  |  |  ------------------
  |  |               	( (set_enginetime(e, e_l, 0, 0, FALSE) == SNMPERR_SUCCESS)	\
  |  |  ------------------
  |  |  |  |  184|  1.58k|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  ------------------
  |  |  |  Branch (88:4): [True: 1.58k, False: 0]
  |  |  ------------------
  |  |   89|  1.58k|		? SNMPERR_SUCCESS				\
  |  |  ------------------
  |  |  |  |  184|  1.58k|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  ------------------
  |  |   90|  1.58k|		: SNMPERR_GENERR )
  |  |  ------------------
  |  |  |  |  185|      0|#define SNMPERR_GENERR			(-1)
  |  |  ------------------
  ------------------
  |  Branch (3083:13): [True: 0, False: 1.58k]
  ------------------
 3084|  1.58k|            != SNMPERR_SUCCESS) {
  ------------------
  |  |  184|  1.58k|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
 3085|      0|            DEBUGMSGTL(("usm", "%s\n", "Couldn't ensure engine record."));
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
 3086|      0|            error = SNMPERR_USM_GENERICERROR;
  ------------------
  |  |  226|      0|#define SNMPERR_USM_GENERICERROR		(-42)
  ------------------
 3087|      0|            goto err;
 3088|      0|        }
 3089|       |
 3090|  1.58k|    }
 3091|       |
 3092|       |
 3093|       |    /*
 3094|       |     * Locate the User record.
 3095|       |     * If the user/engine ID is unknown, report this as an error.
 3096|       |     */
 3097|  1.58k|    if (sess && sess->sessUser)
  ------------------
  |  Branch (3097:9): [True: 1.58k, False: 0]
  |  Branch (3097:17): [True: 0, False: 1.58k]
  ------------------
 3098|      0|        user = sess->sessUser;
 3099|  1.58k|    else
 3100|  1.58k|        user = usm_get_user_from_list(secEngineID, *secEngineIDLen,
 3101|  1.58k|                                       secName, *secNameLen, userList,
 3102|  1.58k|                                       (((sess && sess->isAuthoritative ==
  ------------------
  |  Branch (3102:43): [True: 1.58k, False: 0]
  |  Branch (3102:51): [True: 0, False: 1.58k]
  ------------------
 3103|  1.58k|                                          SNMP_SESS_AUTHORITATIVE) ||
  ------------------
  |  |  125|  1.58k|#define SNMP_SESS_AUTHORITATIVE    1    /* don't learn engineIDs */
  ------------------
 3104|  1.58k|                                         (!sess)) ? 0 : 1));
  ------------------
  |  Branch (3104:42): [True: 0, False: 1.58k]
  ------------------
 3105|       |
 3106|  1.58k|    if (user == NULL) {
  ------------------
  |  Branch (3106:9): [True: 283, False: 1.29k]
  ------------------
 3107|    283|        DEBUGMSGTL(("usm", "Unknown User(%s)\n", secName));
  ------------------
  |  |   66|    283|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|    283|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 283]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 283]
  |  |  ------------------
  ------------------
 3108|    283|        snmp_increment_statistic(STAT_USMSTATSUNKNOWNUSERNAMES);
  ------------------
  |  |  622|    283|#define   STAT_USMSTATSUNKNOWNUSERNAMES      5
  ------------------
 3109|    283|        error = SNMPERR_USM_UNKNOWNSECURITYNAME;
  ------------------
  |  |  227|    283|#define SNMPERR_USM_UNKNOWNSECURITYNAME		(-43)
  ------------------
 3110|    283|        goto err;
 3111|    283|    }
 3112|       |
 3113|       |    /* ensure the user is active */
 3114|  1.29k|    if (user->userStatus != RS_ACTIVE) {
  ------------------
  |  |   35|  1.29k|#define RS_ACTIVE	        1
  ------------------
  |  Branch (3114:9): [True: 0, False: 1.29k]
  ------------------
 3115|      0|        DEBUGMSGTL(("usm", "Attempt to use an inactive user.\n"));
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
 3116|      0|        error = SNMPERR_USM_UNKNOWNSECURITYNAME;
  ------------------
  |  |  227|      0|#define SNMPERR_USM_UNKNOWNSECURITYNAME		(-43)
  ------------------
 3117|      0|        goto err;
 3118|      0|    }
 3119|       |
 3120|       |    /*
 3121|       |     * Make sure the security level is appropriate.
 3122|       |     */
 3123|       |
 3124|  1.29k|    rc = usm_check_secLevel(secLevel, user);
 3125|  1.29k|    if (1 == rc) {
  ------------------
  |  Branch (3125:9): [True: 0, False: 1.29k]
  ------------------
 3126|      0|        DEBUGMSGTL(("usm", "Unsupported Security Level (%d).\n",
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
 3127|      0|                    secLevel));
 3128|      0|        snmp_increment_statistic(STAT_USMSTATSUNSUPPORTEDSECLEVELS);
  ------------------
  |  |  620|      0|#define   STAT_USMSTATSUNSUPPORTEDSECLEVELS  3
  ------------------
 3129|      0|        error = SNMPERR_USM_UNSUPPORTEDSECURITYLEVEL;
  ------------------
  |  |  228|      0|#define SNMPERR_USM_UNSUPPORTEDSECURITYLEVEL	(-44)
  ------------------
 3130|      0|        goto err;
 3131|  1.29k|    } else if (rc != 0) {
  ------------------
  |  Branch (3131:16): [True: 0, False: 1.29k]
  ------------------
 3132|      0|        DEBUGMSGTL(("usm", "Unknown issue.\n"));
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
 3133|      0|        error = SNMPERR_USM_GENERICERROR;
  ------------------
  |  |  226|      0|#define SNMPERR_USM_GENERICERROR		(-42)
  ------------------
 3134|      0|        goto err;
 3135|      0|    }
 3136|       |
 3137|       |    /*
 3138|       |     * Check the authentication credentials of the message.
 3139|       |     */
 3140|  1.29k|    if (secLevel == SNMP_SEC_LEVEL_AUTHNOPRIV
  ------------------
  |  |  300|  2.59k|#define SNMP_SEC_LEVEL_AUTHNOPRIV	2
  ------------------
  |  Branch (3140:9): [True: 526, False: 773]
  ------------------
 3141|    773|        || secLevel == SNMP_SEC_LEVEL_AUTHPRIV) {
  ------------------
  |  |  301|    773|#define SNMP_SEC_LEVEL_AUTHPRIV		3
  ------------------
  |  Branch (3141:12): [True: 2, False: 771]
  ------------------
 3142|    528|        if (sc_check_keyed_hash(user->authProtocol, user->authProtocolLen,
  ------------------
  |  Branch (3142:13): [True: 528, False: 0]
  ------------------
 3143|    528|                                user->authKey, user->authKeyLen,
 3144|    528|                                wholeMsg, wholeMsgLen,
 3145|    528|                                signature, signature_length)
 3146|    528|            != SNMP_ERR_NOERROR) {
  ------------------
  |  |  212|    528|#define SNMP_ERR_NOERROR                (0)     /* XXX  Used only for PDUs? */
  ------------------
 3147|    528|            DEBUGMSGTL(("usm", "Verification failed.\n"));
  ------------------
  |  |   66|    528|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|    528|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 528]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 528]
  |  |  ------------------
  ------------------
 3148|    528|            snmp_increment_statistic(STAT_USMSTATSWRONGDIGESTS);
  ------------------
  |  |  624|    528|#define   STAT_USMSTATSWRONGDIGESTS          7
  ------------------
 3149|    528|	    snmp_log(LOG_WARNING, "Authentication failed for %s\n",
 3150|    528|				user->name);
 3151|    528|            error = SNMPERR_USM_AUTHENTICATIONFAILURE;
  ------------------
  |  |  230|    528|#define SNMPERR_USM_AUTHENTICATIONFAILURE	(-46)
  ------------------
 3152|    528|            goto err;
 3153|    528|        }
 3154|       |
 3155|      0|        DEBUGMSGTL(("usm", "Verification succeeded.\n"));
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
 3156|      0|    }
 3157|       |
 3158|       |
 3159|       |    /*
 3160|       |     * Steps 10-11  user is already set - relocated before timeliness 
 3161|       |     * check in case it fails - still save user data for response.
 3162|       |     *
 3163|       |     * Cache the keys and protocol oids, per step 11 (s3.2).
 3164|       |     */
 3165|    771|    if (usm_set_usmStateReference_auth_protocol(*secStateRef,
  ------------------
  |  Branch (3165:9): [True: 0, False: 771]
  ------------------
 3166|    771|                                                user->authProtocol,
 3167|    771|                                                user->
 3168|    771|                                                authProtocolLen) == -1) {
 3169|      0|        DEBUGMSGTL(("usm", "%s\n",
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
 3170|      0|                    "Couldn't cache authentication protocol."));
 3171|      0|        error = SNMPERR_USM_GENERICERROR;
  ------------------
  |  |  226|      0|#define SNMPERR_USM_GENERICERROR		(-42)
  ------------------
 3172|      0|        goto err;
 3173|      0|    }
 3174|       |
 3175|    771|    if (usm_set_usmStateReference_auth_key(*secStateRef,
  ------------------
  |  Branch (3175:9): [True: 0, False: 771]
  ------------------
 3176|    771|                                           user->authKey,
 3177|    771|                                           user->authKeyLen) == -1) {
 3178|      0|        DEBUGMSGTL(("usm", "%s\n",
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
 3179|      0|                    "Couldn't cache authentication key."));
 3180|      0|        error = SNMPERR_USM_GENERICERROR;
  ------------------
  |  |  226|      0|#define SNMPERR_USM_GENERICERROR		(-42)
  ------------------
 3181|      0|        goto err;
 3182|      0|    }
 3183|       |
 3184|    771|    if (usm_set_usmStateReference_priv_protocol(*secStateRef,
  ------------------
  |  Branch (3184:9): [True: 0, False: 771]
  ------------------
 3185|    771|                                                user->privProtocol,
 3186|    771|                                                user->
 3187|    771|                                                privProtocolLen) == -1) {
 3188|      0|        DEBUGMSGTL(("usm", "%s\n",
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
 3189|      0|                    "Couldn't cache privacy protocol."));
 3190|      0|        error = SNMPERR_USM_GENERICERROR;
  ------------------
  |  |  226|      0|#define SNMPERR_USM_GENERICERROR		(-42)
  ------------------
 3191|      0|        goto err;
 3192|      0|    }
 3193|       |
 3194|    771|    if (usm_set_usmStateReference_priv_key(*secStateRef,
  ------------------
  |  Branch (3194:9): [True: 0, False: 771]
  ------------------
 3195|    771|                                           user->privKey,
 3196|    771|                                           user->privKeyLen) == -1) {
 3197|      0|        DEBUGMSGTL(("usm", "%s\n", "Couldn't cache privacy key."));
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
 3198|      0|        error = SNMPERR_USM_GENERICERROR;
  ------------------
  |  |  226|      0|#define SNMPERR_USM_GENERICERROR		(-42)
  ------------------
 3199|      0|        goto err;
 3200|      0|    }
 3201|       |
 3202|       |
 3203|       |    /*
 3204|       |     * Perform the timeliness/time manager functions.
 3205|       |     */
 3206|    771|    if (secLevel == SNMP_SEC_LEVEL_AUTHNOPRIV
  ------------------
  |  |  300|  1.54k|#define SNMP_SEC_LEVEL_AUTHNOPRIV	2
  ------------------
  |  Branch (3206:9): [True: 0, False: 771]
  ------------------
 3207|    771|        || secLevel == SNMP_SEC_LEVEL_AUTHPRIV) {
  ------------------
  |  |  301|    771|#define SNMP_SEC_LEVEL_AUTHPRIV		3
  ------------------
  |  Branch (3207:12): [True: 0, False: 771]
  ------------------
 3208|      0|        if (usm_check_and_update_timeliness(secEngineID, *secEngineIDLen,
  ------------------
  |  Branch (3208:13): [True: 0, False: 0]
  ------------------
 3209|      0|                                            boots_uint, time_uint,
 3210|      0|                                            &error) == -1) {
 3211|      0|            goto err;
 3212|      0|        }
 3213|      0|    }
 3214|    771|#ifdef							LCD_TIME_SYNC_OPT
 3215|       |    /*
 3216|       |     * Cache the unauthenticated time to use in case we don't have
 3217|       |     * anything better - this guess will be no worse than (0,0)
 3218|       |     * that we normally use.
 3219|       |     */
 3220|    771|    else {
 3221|    771|        set_enginetime(secEngineID, *secEngineIDLen,
 3222|    771|                       boots_uint, time_uint, FALSE);
  ------------------
  |  |  125|    771|#define FALSE 0
  ------------------
 3223|    771|    }
 3224|    771|#endif                          /* LCD_TIME_SYNC_OPT */
 3225|       |
 3226|       |
 3227|       |    /*
 3228|       |     * If needed, decrypt the scoped PDU.
 3229|       |     */
 3230|    771|    if (secLevel == SNMP_SEC_LEVEL_AUTHPRIV) {
  ------------------
  |  |  301|    771|#define SNMP_SEC_LEVEL_AUTHPRIV		3
  ------------------
  |  Branch (3230:9): [True: 0, False: 771]
  ------------------
 3231|      0|        int priv_type = sc_get_privtype(user->privProtocol,
 3232|      0|                                        user->privProtocolLen);
 3233|      0|        remaining = wholeMsgLen - (data_ptr - wholeMsg);
 3234|       |
 3235|      0|        if ((value_ptr = asn_parse_sequence(data_ptr, &remaining,
  ------------------
  |  Branch (3235:13): [True: 0, False: 0]
  ------------------
 3236|      0|                                            &type_value,
 3237|      0|                                            (ASN_UNIVERSAL | ASN_PRIMITIVE
  ------------------
  |  |   90|      0|#define ASN_UNIVERSAL	    0x00U
  ------------------
                                                          (ASN_UNIVERSAL | ASN_PRIMITIVE
  ------------------
  |  |   95|      0|#define ASN_PRIMITIVE	    0x00U
  ------------------
 3238|      0|                                             | ASN_OCTET_STR),
  ------------------
  |  |   78|      0|#define ASN_OCTET_STR	    0x04U
  ------------------
 3239|      0|                                            "encrypted sPDU")) == NULL) {
 3240|      0|            DEBUGMSGTL(("usm", "%s\n",
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
 3241|      0|                        "Failed while parsing encrypted sPDU."));
 3242|      0|            snmp_increment_statistic(STAT_SNMPINASNPARSEERRS);
  ------------------
  |  |  637|      0|#define  STAT_SNMPINASNPARSEERRS             14
  ------------------
 3243|      0|            usm_free_usmStateReference(*secStateRef);
 3244|      0|            *secStateRef = NULL;
 3245|      0|            error = SNMPERR_USM_PARSEERROR;
  ------------------
  |  |  231|      0|#define SNMPERR_USM_PARSEERROR			(-47)
  ------------------
 3246|      0|            goto err;
 3247|      0|        }
 3248|       |
 3249|      0|#ifndef NETSNMP_DISABLE_DES
 3250|      0|        if (USM_CREATE_USER_PRIV_DES == (priv_type & USM_PRIV_MASK_ALG)) {
  ------------------
  |  |  172|      0|#define USM_CREATE_USER_PRIV_DES            0x01
  ------------------
                      if (USM_CREATE_USER_PRIV_DES == (priv_type & USM_PRIV_MASK_ALG)) {
  ------------------
  |  |  166|      0|#define USM_PRIV_MASK_ALG                   0x0000ff
  ------------------
  |  Branch (3250:13): [True: 0, False: 0]
  ------------------
 3251|       |            /*
 3252|       |             * From RFC2574:
 3253|       |             * 
 3254|       |             * "Before decryption, the encrypted data length is verified.
 3255|       |             * If the length of the OCTET STRING to be decrypted is not
 3256|       |             * an integral multiple of 8 octets, the decryption process
 3257|       |             * is halted and an appropriate exception noted."  
 3258|       |             */
 3259|       |
 3260|      0|            if (remaining % 8 != 0) {
  ------------------
  |  Branch (3260:17): [True: 0, False: 0]
  ------------------
 3261|      0|                DEBUGMSGTL(("usm",
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
 3262|      0|                            "Ciphertext is %lu bytes, not an integer multiple of 8 (rem %lu)\n",
 3263|      0|                            (unsigned long)remaining, (unsigned long)remaining % 8));
 3264|      0|                snmp_increment_statistic(STAT_USMSTATSDECRYPTIONERRORS);
  ------------------
  |  |  625|      0|#define   STAT_USMSTATSDECRYPTIONERRORS      8
  ------------------
 3265|      0|                usm_free_usmStateReference(*secStateRef);
 3266|      0|                *secStateRef = NULL;
 3267|      0|                error = SNMPERR_USM_DECRYPTIONERROR;
  ------------------
  |  |  234|      0|#define SNMPERR_USM_DECRYPTIONERROR		(-50)
  ------------------
 3268|      0|                goto err;
 3269|      0|            }
 3270|       |
 3271|      0|            end_of_overhead = value_ptr;
 3272|      0|            iv_length = BYTESIZE(USM_DES_SALT_LENGTH);
  ------------------
  |  |   55|      0|#define BYTESIZE(bitsize)       ((bitsize + 7) >> 3)
  ------------------
 3273|       |
 3274|      0|            if (!user->privKey || user->privKeyLen < 2 * iv_length ||
  ------------------
  |  Branch (3274:17): [True: 0, False: 0]
  |  Branch (3274:35): [True: 0, False: 0]
  ------------------
 3275|      0|                salt_length < iv_length) {
  ------------------
  |  Branch (3275:17): [True: 0, False: 0]
  ------------------
 3276|      0|                DEBUGMSGTL(("usm", "No privacy pass phrase for %s\n", user->secName));
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
 3277|      0|                snmp_increment_statistic(STAT_USMSTATSDECRYPTIONERRORS);
  ------------------
  |  |  625|      0|#define   STAT_USMSTATSDECRYPTIONERRORS      8
  ------------------
 3278|      0|                usm_free_usmStateReference(*secStateRef);
 3279|      0|                *secStateRef = NULL;
 3280|      0|                error = SNMPERR_USM_DECRYPTIONERROR;
  ------------------
  |  |  234|      0|#define SNMPERR_USM_DECRYPTIONERROR		(-50)
  ------------------
 3281|      0|                goto err;
 3282|      0|            }
 3283|       |
 3284|       |            /*
 3285|       |             * XOR the salt with the last (iv_length) bytes
 3286|       |             * of the priv_key to obtain the IV.
 3287|       |             */
 3288|      0|            for (i = 0; i < (int) iv_length; i++)
  ------------------
  |  Branch (3288:25): [True: 0, False: 0]
  ------------------
 3289|      0|                iv[i] = salt[i] ^ user->privKey[iv_length + i];
 3290|      0|        }
 3291|      0|#endif
 3292|      0|#ifdef HAVE_AES
 3293|      0|        if (USM_CREATE_USER_PRIV_AES == (priv_type & USM_PRIV_MASK_ALG)) {
  ------------------
  |  |  176|      0|#define USM_CREATE_USER_PRIV_AES            0x02
  ------------------
                      if (USM_CREATE_USER_PRIV_AES == (priv_type & USM_PRIV_MASK_ALG)) {
  ------------------
  |  |  166|      0|#define USM_PRIV_MASK_ALG                   0x0000ff
  ------------------
  |  Branch (3293:13): [True: 0, False: 0]
  ------------------
 3294|      0|            iv_length = BYTESIZE(USM_AES_SALT_LENGTH);
  ------------------
  |  |   55|      0|#define BYTESIZE(bitsize)       ((bitsize + 7) >> 3)
  ------------------
 3295|      0|            net_boots = ntohl(boots_uint);
 3296|      0|            net_time = ntohl(time_uint);
 3297|      0|            memcpy(iv, &net_boots, 4);
 3298|      0|            memcpy(iv+4, &net_time, 4);
 3299|      0|            memcpy(iv+8, salt, salt_length);
 3300|      0|        }
 3301|      0|#endif
 3302|       |
 3303|       |#ifdef NETSNMP_ENABLE_TESTING_CODE
 3304|       |        if (debug_is_token_registered("usm/dump") == SNMPERR_SUCCESS) {
 3305|       |            dump_chunk("usm/dump", "Cypher Text", value_ptr, remaining);
 3306|       |            dump_chunk("usm/dump", "salt + Encrypted form:",
 3307|       |                       salt, salt_length);
 3308|       |            dump_chunk("usm/dump", "IV + Encrypted form:", iv, iv_length);
 3309|       |        }
 3310|       |#endif
 3311|      0|        if (sc_decrypt(user->privProtocol, user->privProtocolLen,
  ------------------
  |  Branch (3311:13): [True: 0, False: 0]
  ------------------
 3312|      0|                       user->privKey, user->privKeyLen,
 3313|      0|                       iv, iv_length,
 3314|      0|                       value_ptr, remaining, *scopedPdu, scopedPduLen)
 3315|      0|            != SNMP_ERR_NOERROR) {
  ------------------
  |  |  212|      0|#define SNMP_ERR_NOERROR                (0)     /* XXX  Used only for PDUs? */
  ------------------
 3316|      0|            DEBUGMSGTL(("usm", "%s\n", "Failed decryption."));
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
 3317|      0|            snmp_increment_statistic(STAT_USMSTATSDECRYPTIONERRORS);
  ------------------
  |  |  625|      0|#define   STAT_USMSTATSDECRYPTIONERRORS      8
  ------------------
 3318|      0|            error = SNMPERR_USM_DECRYPTIONERROR;
  ------------------
  |  |  234|      0|#define SNMPERR_USM_DECRYPTIONERROR		(-50)
  ------------------
 3319|      0|            goto err;
 3320|      0|        }
 3321|       |#ifdef NETSNMP_ENABLE_TESTING_CODE
 3322|       |        if (debug_is_token_registered("usm/dump") == SNMPERR_SUCCESS) {
 3323|       |            dump_chunk("usm/dump", "Decrypted chunk:",
 3324|       |                       *scopedPdu, *scopedPduLen);
 3325|       |        }
 3326|       |#endif
 3327|      0|    }
 3328|       |    /*
 3329|       |     * sPDU is plaintext.
 3330|       |     */
 3331|    771|    else {
 3332|    771|        *scopedPdu = data_ptr;
 3333|    771|        *scopedPduLen = wholeMsgLen - (data_ptr - wholeMsg);
 3334|    771|        end_of_overhead = data_ptr;
 3335|       |
 3336|    771|    }                           /* endif -- PDU decryption */
 3337|       |
 3338|       |
 3339|       |    /*
 3340|       |     * Calculate the biggest sPDU for the response (i.e., whole - ovrhd).
 3341|       |     *
 3342|       |     * FIX  Correct? 
 3343|       |     */
 3344|    771|    *maxSizeResponse = maxMsgSize - (end_of_overhead - wholeMsg);
 3345|       |
 3346|       |
 3347|    771|    DEBUGMSGTL(("usm", "USM processing completed.\n"));
  ------------------
  |  |   66|    771|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|    771|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 771]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 771]
  |  |  ------------------
  ------------------
 3348|       |
 3349|    771|    return SNMPERR_SUCCESS;
  ------------------
  |  |  184|    771|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
 3350|       |
 3351|  1.05k|err:
 3352|  1.05k|    usm_free_usmStateReference(*secStateRef);
 3353|  1.05k|    *secStateRef = NULL;
 3354|       |    netsnmp_assert(error != SNMPERR_SUCCESS);
  ------------------
  |  |   47|  1.05k|#      define netsnmp_assert(x)  do { \
  |  |   48|  1.05k|              if ( x ) \
  |  |  ------------------
  |  |  |  Branch (48:20): [True: 1.05k, False: 0]
  |  |  ------------------
  |  |   49|  1.05k|                 ; \
  |  |   50|  1.05k|              else \
  |  |   51|  1.05k|                 snmp_log(LOG_ERR, \
  |  |   52|      0|                          "netsnmp_assert %s failed %s:%d" NETSNMP_FUNC_FMT, \
  |  |  ------------------
  |  |  |  |   40|      0|#          define NETSNMP_FUNC_FMT " %s()\n"
  |  |  ------------------
  |  |   53|      0|                          __STRING(x),__FILE__,__LINE__, \
  |  |   54|      0|                          NETSNMP_FUNC_PARAM); \
  |  |  ------------------
  |  |  |  |   41|      0|#          define NETSNMP_FUNC_PARAM NETSNMP_FUNCTION
  |  |  |  |  ------------------
  |  |  |  |  |  | 1727|      0|#define NETSNMP_FUNCTION __func__
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   55|  1.05k|           }while(0)
  |  |  ------------------
  |  |  |  Branch (55:19): [Folded, False: 1.05k]
  |  |  ------------------
  ------------------
 3355|  1.05k|    return error;
 3356|    771|}                               /* end usm_process_in_msg() */
snmpusm.c:usm_malloc_usmStateReference:
  288|  1.83k|{
  289|  1.83k|    struct usmStateReference *retval;
  290|       |
  291|  1.83k|    retval = calloc(1, sizeof(struct usmStateReference));
  292|  1.83k|    if (retval)
  ------------------
  |  Branch (292:9): [True: 1.83k, False: 0]
  ------------------
  293|  1.83k|        retval->refcnt = 1;
  294|       |
  295|  1.83k|    return retval;
  296|  1.83k|}                               /* end usm_malloc_usmStateReference() */
snmpusm.c:usm_parse_security_parameters:
 2477|  1.83k|{
 2478|  1.83k|    u_char         *parse_ptr = secParams;
 2479|  1.83k|    u_char         *value_ptr;
 2480|  1.83k|    u_char         *next_ptr;
 2481|  1.83k|    u_char          type_value;
 2482|       |
 2483|  1.83k|    size_t          octet_string_length = remaining;
 2484|  1.83k|    size_t          sequence_length;
 2485|  1.83k|    size_t          remaining_bytes;
 2486|       |
 2487|  1.83k|    long            boots_long;
 2488|  1.83k|    long            time_long;
 2489|       |
 2490|  1.83k|    u_int           origNameLen;
 2491|       |
 2492|       |
 2493|       |    /*
 2494|       |     * Eat the first octet header.
 2495|       |     */
 2496|  1.83k|    if ((value_ptr = asn_parse_sequence(parse_ptr, &octet_string_length,
  ------------------
  |  Branch (2496:9): [True: 3, False: 1.82k]
  ------------------
 2497|  1.83k|                                        &type_value,
 2498|  1.83k|                                        (ASN_UNIVERSAL | ASN_PRIMITIVE |
  ------------------
  |  |   90|  1.83k|#define ASN_UNIVERSAL	    0x00U
  ------------------
                                                      (ASN_UNIVERSAL | ASN_PRIMITIVE |
  ------------------
  |  |   95|  1.83k|#define ASN_PRIMITIVE	    0x00U
  ------------------
 2499|  1.83k|                                         ASN_OCTET_STR),
  ------------------
  |  |   78|  1.83k|#define ASN_OCTET_STR	    0x04U
  ------------------
 2500|  1.83k|                                        "usm first octet")) == NULL) {
 2501|       |        /*
 2502|       |         * RETURN parse error 
 2503|      3|         */ return -1;
 2504|      3|    }
 2505|       |
 2506|       |
 2507|       |    /*
 2508|       |     * Eat the sequence header.
 2509|       |     */
 2510|  1.82k|    parse_ptr = value_ptr;
 2511|  1.82k|    sequence_length = octet_string_length;
 2512|       |
 2513|  1.82k|    if ((value_ptr = asn_parse_sequence(parse_ptr, &sequence_length,
  ------------------
  |  Branch (2513:9): [True: 3, False: 1.82k]
  ------------------
 2514|  1.82k|                                        &type_value,
 2515|  1.82k|                                        (ASN_SEQUENCE | ASN_CONSTRUCTOR),
  ------------------
  |  |   84|  1.82k|#define ASN_SEQUENCE	    0x10U
  ------------------
                                                      (ASN_SEQUENCE | ASN_CONSTRUCTOR),
  ------------------
  |  |   96|  1.82k|#define ASN_CONSTRUCTOR	    0x20U
  ------------------
 2516|  1.82k|                                        "usm sequence")) == NULL) {
 2517|       |        /*
 2518|       |         * RETURN parse error 
 2519|      3|         */ return -1;
 2520|      3|    }
 2521|       |
 2522|       |
 2523|       |    /*
 2524|       |     * Retrieve the engineID.
 2525|       |     */
 2526|  1.82k|    parse_ptr = value_ptr;
 2527|  1.82k|    remaining_bytes = sequence_length;
 2528|       |
 2529|  1.82k|    DEBUGDUMPHEADER("recv", "msgAuthoritativeEngineID");
  ------------------
  |  |   79|  1.82k|	do {if (_DBG_IF_) {__DBGDUMPHEADER(token,x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|  1.82k|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 1.82k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               	do {if (_DBG_IF_) {__DBGDUMPHEADER(token,x);} }while(0)
  |  |  ------------------
  |  |  |  |  178|      0|        __DBGPRINTINDENT("dumph_" token); \
  |  |  |  |  ------------------
  |  |  |  |  |  |  175|      0|#define __DBGPRINTINDENT(token) __DBGMSGTL((token, "%*s", __DBGINDENT(), ""))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  179|      0|        debugmsg("dumph_" token,x); \
  |  |  |  |  180|      0|        if (debug_is_token_registered("dumpx" token) == SNMPERR_SUCCESS ||    \
  |  |  |  |  ------------------
  |  |  |  |  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (180:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  181|      0|            debug_is_token_registered("dumpv" token) == SNMPERR_SUCCESS ||    \
  |  |  |  |  ------------------
  |  |  |  |  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (181:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  182|      0|            (debug_is_token_registered("dumpx_" token) != SNMPERR_SUCCESS &&  \
  |  |  |  |  ------------------
  |  |  |  |  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (182:14): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  183|      0|             debug_is_token_registered("dumpv_" token) != SNMPERR_SUCCESS)) { \
  |  |  |  |  ------------------
  |  |  |  |  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:14): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  184|      0|            debugmsg("dumph_" token,"\n"); \
  |  |  |  |  185|      0|        } else { \
  |  |  |  |  186|      0|            debugmsg("dumph_" token,"  "); \
  |  |  |  |  187|      0|        } \
  |  |  |  |  188|      0|        __DBGINDENTMORE()
  |  |  |  |  ------------------
  |  |  |  |  |  |  173|      0|#define __DBGINDENTMORE()  debug_indent_add(2)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (79:55): [Folded, False: 1.82k]
  |  |  ------------------
  ------------------
 2530|  1.82k|    if ((next_ptr
  ------------------
  |  Branch (2530:9): [True: 1, False: 1.82k]
  ------------------
 2531|  1.82k|         = asn_parse_string(parse_ptr, &remaining_bytes, &type_value,
 2532|  1.82k|                            secEngineID, secEngineIDLen)) == NULL) {
 2533|      1|        DEBUGINDENTLESS();
  ------------------
  |  |   75|      1|#define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  144|      1|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 1]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  174|      0|#define __DBGINDENTLESS()  debug_indent_add(-2)
  |  |  ------------------
  |  |  |  Branch (75:74): [Folded, False: 1]
  |  |  ------------------
  ------------------
 2534|       |        /*
 2535|       |         * RETURN parse error 
 2536|      1|         */ return -1;
 2537|      1|    }
 2538|  1.82k|    DEBUGINDENTLESS();
  ------------------
  |  |   75|  1.82k|#define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  144|  1.82k|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 1.82k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  174|      0|#define __DBGINDENTLESS()  debug_indent_add(-2)
  |  |  ------------------
  |  |  |  Branch (75:74): [Folded, False: 1.82k]
  |  |  ------------------
  ------------------
 2539|       |
 2540|  1.82k|    if (type_value !=
  ------------------
  |  Branch (2540:9): [True: 2, False: 1.82k]
  ------------------
 2541|  1.82k|        (u_char) (ASN_UNIVERSAL | ASN_PRIMITIVE | ASN_OCTET_STR)) {
  ------------------
  |  |   90|  1.82k|#define ASN_UNIVERSAL	    0x00U
  ------------------
                      (u_char) (ASN_UNIVERSAL | ASN_PRIMITIVE | ASN_OCTET_STR)) {
  ------------------
  |  |   95|  1.82k|#define ASN_PRIMITIVE	    0x00U
  ------------------
                      (u_char) (ASN_UNIVERSAL | ASN_PRIMITIVE | ASN_OCTET_STR)) {
  ------------------
  |  |   78|  1.82k|#define ASN_OCTET_STR	    0x04U
  ------------------
 2542|       |        /*
 2543|       |         * RETURN parse error 
 2544|      2|         */ return -1;
 2545|      2|    }
 2546|       |
 2547|       |
 2548|       |    /*
 2549|       |     * Retrieve the engine boots, notice switch in the way next_ptr and
 2550|       |     * remaining_bytes are used (to accommodate the asn code).
 2551|       |     */
 2552|  1.82k|    DEBUGDUMPHEADER("recv", "msgAuthoritativeEngineBoots");
  ------------------
  |  |   79|  1.82k|	do {if (_DBG_IF_) {__DBGDUMPHEADER(token,x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|  1.82k|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 1.82k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               	do {if (_DBG_IF_) {__DBGDUMPHEADER(token,x);} }while(0)
  |  |  ------------------
  |  |  |  |  178|      0|        __DBGPRINTINDENT("dumph_" token); \
  |  |  |  |  ------------------
  |  |  |  |  |  |  175|      0|#define __DBGPRINTINDENT(token) __DBGMSGTL((token, "%*s", __DBGINDENT(), ""))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  179|      0|        debugmsg("dumph_" token,x); \
  |  |  |  |  180|      0|        if (debug_is_token_registered("dumpx" token) == SNMPERR_SUCCESS ||    \
  |  |  |  |  ------------------
  |  |  |  |  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (180:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  181|      0|            debug_is_token_registered("dumpv" token) == SNMPERR_SUCCESS ||    \
  |  |  |  |  ------------------
  |  |  |  |  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (181:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  182|      0|            (debug_is_token_registered("dumpx_" token) != SNMPERR_SUCCESS &&  \
  |  |  |  |  ------------------
  |  |  |  |  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (182:14): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  183|      0|             debug_is_token_registered("dumpv_" token) != SNMPERR_SUCCESS)) { \
  |  |  |  |  ------------------
  |  |  |  |  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:14): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  184|      0|            debugmsg("dumph_" token,"\n"); \
  |  |  |  |  185|      0|        } else { \
  |  |  |  |  186|      0|            debugmsg("dumph_" token,"  "); \
  |  |  |  |  187|      0|        } \
  |  |  |  |  188|      0|        __DBGINDENTMORE()
  |  |  |  |  ------------------
  |  |  |  |  |  |  173|      0|#define __DBGINDENTMORE()  debug_indent_add(2)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (79:55): [Folded, False: 1.82k]
  |  |  ------------------
  ------------------
 2553|  1.82k|    if ((next_ptr = asn_parse_int(next_ptr, &remaining_bytes, &type_value,
  ------------------
  |  Branch (2553:9): [True: 3, False: 1.81k]
  ------------------
 2554|  1.82k|                                  &boots_long, sizeof(long))) == NULL) {
 2555|      3|        DEBUGINDENTLESS();
  ------------------
  |  |   75|      3|#define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  144|      3|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 3]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  174|      0|#define __DBGINDENTLESS()  debug_indent_add(-2)
  |  |  ------------------
  |  |  |  Branch (75:74): [Folded, False: 3]
  |  |  ------------------
  ------------------
 2556|       |        /*
 2557|       |         * RETURN parse error 
 2558|      3|         */ return -1;
 2559|      3|    }
 2560|  1.81k|    DEBUGINDENTLESS();
  ------------------
  |  |   75|  1.81k|#define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  144|  1.81k|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 1.81k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  174|      0|#define __DBGINDENTLESS()  debug_indent_add(-2)
  |  |  ------------------
  |  |  |  Branch (75:74): [Folded, False: 1.81k]
  |  |  ------------------
  ------------------
 2561|       |
 2562|  1.81k|    if (type_value !=
  ------------------
  |  Branch (2562:9): [True: 0, False: 1.81k]
  ------------------
 2563|  1.81k|        (u_char) (ASN_UNIVERSAL | ASN_PRIMITIVE | ASN_INTEGER)) {
  ------------------
  |  |   90|  1.81k|#define ASN_UNIVERSAL	    0x00U
  ------------------
                      (u_char) (ASN_UNIVERSAL | ASN_PRIMITIVE | ASN_INTEGER)) {
  ------------------
  |  |   95|  1.81k|#define ASN_PRIMITIVE	    0x00U
  ------------------
                      (u_char) (ASN_UNIVERSAL | ASN_PRIMITIVE | ASN_INTEGER)) {
  ------------------
  |  |   75|  1.81k|#define ASN_INTEGER	    0x02U
  ------------------
 2564|      0|        DEBUGINDENTLESS();
  ------------------
  |  |   75|      0|#define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  174|      0|#define __DBGINDENTLESS()  debug_indent_add(-2)
  |  |  ------------------
  |  |  |  Branch (75:74): [Folded, False: 0]
  |  |  ------------------
  ------------------
 2565|       |        /*
 2566|       |         * RETURN parse error 
 2567|      0|         */ return -1;
 2568|      0|    }
 2569|       |
 2570|  1.81k|    *boots_uint = (u_int) boots_long;
 2571|       |
 2572|       |
 2573|       |    /*
 2574|       |     * Retrieve the time value.
 2575|       |     */
 2576|  1.81k|    DEBUGDUMPHEADER("recv", "msgAuthoritativeEngineTime");
  ------------------
  |  |   79|  1.81k|	do {if (_DBG_IF_) {__DBGDUMPHEADER(token,x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|  1.81k|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 1.81k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               	do {if (_DBG_IF_) {__DBGDUMPHEADER(token,x);} }while(0)
  |  |  ------------------
  |  |  |  |  178|      0|        __DBGPRINTINDENT("dumph_" token); \
  |  |  |  |  ------------------
  |  |  |  |  |  |  175|      0|#define __DBGPRINTINDENT(token) __DBGMSGTL((token, "%*s", __DBGINDENT(), ""))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  179|      0|        debugmsg("dumph_" token,x); \
  |  |  |  |  180|      0|        if (debug_is_token_registered("dumpx" token) == SNMPERR_SUCCESS ||    \
  |  |  |  |  ------------------
  |  |  |  |  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (180:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  181|      0|            debug_is_token_registered("dumpv" token) == SNMPERR_SUCCESS ||    \
  |  |  |  |  ------------------
  |  |  |  |  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (181:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  182|      0|            (debug_is_token_registered("dumpx_" token) != SNMPERR_SUCCESS &&  \
  |  |  |  |  ------------------
  |  |  |  |  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (182:14): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  183|      0|             debug_is_token_registered("dumpv_" token) != SNMPERR_SUCCESS)) { \
  |  |  |  |  ------------------
  |  |  |  |  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:14): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  184|      0|            debugmsg("dumph_" token,"\n"); \
  |  |  |  |  185|      0|        } else { \
  |  |  |  |  186|      0|            debugmsg("dumph_" token,"  "); \
  |  |  |  |  187|      0|        } \
  |  |  |  |  188|      0|        __DBGINDENTMORE()
  |  |  |  |  ------------------
  |  |  |  |  |  |  173|      0|#define __DBGINDENTMORE()  debug_indent_add(2)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (79:55): [Folded, False: 1.81k]
  |  |  ------------------
  ------------------
 2577|  1.81k|    if ((next_ptr = asn_parse_int(next_ptr, &remaining_bytes, &type_value,
  ------------------
  |  Branch (2577:9): [True: 3, False: 1.81k]
  ------------------
 2578|  1.81k|                                  &time_long, sizeof(long))) == NULL) {
 2579|       |        /*
 2580|       |         * RETURN parse error 
 2581|      3|         */ return -1;
 2582|      3|    }
 2583|  1.81k|    DEBUGINDENTLESS();
  ------------------
  |  |   75|  1.81k|#define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  144|  1.81k|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 1.81k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  174|      0|#define __DBGINDENTLESS()  debug_indent_add(-2)
  |  |  ------------------
  |  |  |  Branch (75:74): [Folded, False: 1.81k]
  |  |  ------------------
  ------------------
 2584|       |
 2585|  1.81k|    if (type_value !=
  ------------------
  |  Branch (2585:9): [True: 0, False: 1.81k]
  ------------------
 2586|  1.81k|        (u_char) (ASN_UNIVERSAL | ASN_PRIMITIVE | ASN_INTEGER)) {
  ------------------
  |  |   90|  1.81k|#define ASN_UNIVERSAL	    0x00U
  ------------------
                      (u_char) (ASN_UNIVERSAL | ASN_PRIMITIVE | ASN_INTEGER)) {
  ------------------
  |  |   95|  1.81k|#define ASN_PRIMITIVE	    0x00U
  ------------------
                      (u_char) (ASN_UNIVERSAL | ASN_PRIMITIVE | ASN_INTEGER)) {
  ------------------
  |  |   75|  1.81k|#define ASN_INTEGER	    0x02U
  ------------------
 2587|       |        /*
 2588|       |         * RETURN parse error 
 2589|      0|         */ return -1;
 2590|      0|    }
 2591|       |
 2592|  1.81k|    *time_uint = (u_int) time_long;
 2593|       |
 2594|  1.81k|    if (boots_long < 0 || boots_long > ENGINEBOOT_MAX ||
  ------------------
  |  |  183|  3.57k|#define ENGINEBOOT_MAX	2147483647      /* ((2^31)-1) */
  ------------------
  |  Branch (2594:9): [True: 51, False: 1.76k]
  |  Branch (2594:27): [True: 8, False: 1.75k]
  ------------------
 2595|  1.75k|        time_long < 0 || time_long > ENGINETIME_MAX) {
  ------------------
  |  |  182|  1.69k|#define ENGINETIME_MAX	2147483647      /* ((2^31)-1) */
  ------------------
  |  Branch (2595:9): [True: 61, False: 1.69k]
  |  Branch (2595:26): [True: 11, False: 1.68k]
  ------------------
 2596|    131|        return -1;
 2597|    131|    }
 2598|       |
 2599|       |    /*
 2600|       |     * Retrieve the secName.
 2601|       |     */
 2602|  1.68k|    origNameLen = *secNameLen;
 2603|       |
 2604|       |
 2605|  1.68k|    DEBUGDUMPHEADER("recv", "msgUserName");
  ------------------
  |  |   79|  1.68k|	do {if (_DBG_IF_) {__DBGDUMPHEADER(token,x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|  1.68k|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 1.68k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               	do {if (_DBG_IF_) {__DBGDUMPHEADER(token,x);} }while(0)
  |  |  ------------------
  |  |  |  |  178|      0|        __DBGPRINTINDENT("dumph_" token); \
  |  |  |  |  ------------------
  |  |  |  |  |  |  175|      0|#define __DBGPRINTINDENT(token) __DBGMSGTL((token, "%*s", __DBGINDENT(), ""))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  179|      0|        debugmsg("dumph_" token,x); \
  |  |  |  |  180|      0|        if (debug_is_token_registered("dumpx" token) == SNMPERR_SUCCESS ||    \
  |  |  |  |  ------------------
  |  |  |  |  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (180:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  181|      0|            debug_is_token_registered("dumpv" token) == SNMPERR_SUCCESS ||    \
  |  |  |  |  ------------------
  |  |  |  |  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (181:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  182|      0|            (debug_is_token_registered("dumpx_" token) != SNMPERR_SUCCESS &&  \
  |  |  |  |  ------------------
  |  |  |  |  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (182:14): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  183|      0|             debug_is_token_registered("dumpv_" token) != SNMPERR_SUCCESS)) { \
  |  |  |  |  ------------------
  |  |  |  |  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:14): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  184|      0|            debugmsg("dumph_" token,"\n"); \
  |  |  |  |  185|      0|        } else { \
  |  |  |  |  186|      0|            debugmsg("dumph_" token,"  "); \
  |  |  |  |  187|      0|        } \
  |  |  |  |  188|      0|        __DBGINDENTMORE()
  |  |  |  |  ------------------
  |  |  |  |  |  |  173|      0|#define __DBGINDENTMORE()  debug_indent_add(2)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (79:55): [Folded, False: 1.68k]
  |  |  ------------------
  ------------------
 2606|  1.68k|    if ((next_ptr
  ------------------
  |  Branch (2606:9): [True: 70, False: 1.61k]
  ------------------
 2607|  1.68k|         = asn_parse_string(next_ptr, &remaining_bytes, &type_value,
 2608|  1.68k|                            (u_char *) secName, secNameLen)) == NULL) {
 2609|     70|        DEBUGINDENTLESS();
  ------------------
  |  |   75|     70|#define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  144|     70|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 70]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  174|      0|#define __DBGINDENTLESS()  debug_indent_add(-2)
  |  |  ------------------
  |  |  |  Branch (75:74): [Folded, False: 70]
  |  |  ------------------
  ------------------
 2610|       |        /*
 2611|       |         * RETURN parse error 
 2612|     70|         */ return -1;
 2613|     70|    }
 2614|  1.61k|    DEBUGINDENTLESS();
  ------------------
  |  |   75|  1.61k|#define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  144|  1.61k|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 1.61k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  174|      0|#define __DBGINDENTLESS()  debug_indent_add(-2)
  |  |  ------------------
  |  |  |  Branch (75:74): [Folded, False: 1.61k]
  |  |  ------------------
  ------------------
 2615|       |
 2616|       |    /*
 2617|       |     * FIX -- doesn't this also indicate a buffer overrun?
 2618|       |     */
 2619|  1.61k|    if (origNameLen < *secNameLen + 1) {
  ------------------
  |  Branch (2619:9): [True: 0, False: 1.61k]
  ------------------
 2620|       |        /*
 2621|       |         * RETURN parse error, but it's really a parameter error 
 2622|       |         */
 2623|      0|        return -1;
 2624|      0|    }
 2625|       |
 2626|  1.61k|    if (*secNameLen > 32) {
  ------------------
  |  Branch (2626:9): [True: 3, False: 1.61k]
  ------------------
 2627|       |        /*
 2628|       |         * This is a USM-specific limitation over and above the above
 2629|       |         * limitation (which will probably default to the length of an
 2630|       |         * SnmpAdminString, i.e. 255).  See RFC 2574, sec. 2.4.  
 2631|       |         */
 2632|      3|        return -1;
 2633|      3|    }
 2634|       |
 2635|  1.61k|    secName[*secNameLen] = '\0';
 2636|       |
 2637|  1.61k|    if (type_value !=
  ------------------
  |  Branch (2637:9): [True: 3, False: 1.60k]
  ------------------
 2638|  1.61k|        (u_char) (ASN_UNIVERSAL | ASN_PRIMITIVE | ASN_OCTET_STR)) {
  ------------------
  |  |   90|  1.61k|#define ASN_UNIVERSAL	    0x00U
  ------------------
                      (u_char) (ASN_UNIVERSAL | ASN_PRIMITIVE | ASN_OCTET_STR)) {
  ------------------
  |  |   95|  1.61k|#define ASN_PRIMITIVE	    0x00U
  ------------------
                      (u_char) (ASN_UNIVERSAL | ASN_PRIMITIVE | ASN_OCTET_STR)) {
  ------------------
  |  |   78|  1.61k|#define ASN_OCTET_STR	    0x04U
  ------------------
 2639|       |        /*
 2640|       |         * RETURN parse error 
 2641|      3|         */ return -1;
 2642|      3|    }
 2643|       |
 2644|       |
 2645|       |    /*
 2646|       |     * Retrieve the signature and blank it if there.
 2647|       |     */
 2648|  1.60k|    DEBUGDUMPHEADER("recv", "msgAuthenticationParameters");
  ------------------
  |  |   79|  1.60k|	do {if (_DBG_IF_) {__DBGDUMPHEADER(token,x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|  1.60k|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 1.60k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               	do {if (_DBG_IF_) {__DBGDUMPHEADER(token,x);} }while(0)
  |  |  ------------------
  |  |  |  |  178|      0|        __DBGPRINTINDENT("dumph_" token); \
  |  |  |  |  ------------------
  |  |  |  |  |  |  175|      0|#define __DBGPRINTINDENT(token) __DBGMSGTL((token, "%*s", __DBGINDENT(), ""))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  179|      0|        debugmsg("dumph_" token,x); \
  |  |  |  |  180|      0|        if (debug_is_token_registered("dumpx" token) == SNMPERR_SUCCESS ||    \
  |  |  |  |  ------------------
  |  |  |  |  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (180:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  181|      0|            debug_is_token_registered("dumpv" token) == SNMPERR_SUCCESS ||    \
  |  |  |  |  ------------------
  |  |  |  |  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (181:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  182|      0|            (debug_is_token_registered("dumpx_" token) != SNMPERR_SUCCESS &&  \
  |  |  |  |  ------------------
  |  |  |  |  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (182:14): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  183|      0|             debug_is_token_registered("dumpv_" token) != SNMPERR_SUCCESS)) { \
  |  |  |  |  ------------------
  |  |  |  |  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:14): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  184|      0|            debugmsg("dumph_" token,"\n"); \
  |  |  |  |  185|      0|        } else { \
  |  |  |  |  186|      0|            debugmsg("dumph_" token,"  "); \
  |  |  |  |  187|      0|        } \
  |  |  |  |  188|      0|        __DBGINDENTMORE()
  |  |  |  |  ------------------
  |  |  |  |  |  |  173|      0|#define __DBGINDENTMORE()  debug_indent_add(2)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (79:55): [Folded, False: 1.60k]
  |  |  ------------------
  ------------------
 2649|  1.60k|    if ((next_ptr
  ------------------
  |  Branch (2649:9): [True: 10, False: 1.59k]
  ------------------
 2650|  1.60k|         = asn_parse_string(next_ptr, &remaining_bytes, &type_value,
 2651|  1.60k|                            signature, signature_length)) == NULL) {
 2652|     10|        DEBUGINDENTLESS();
  ------------------
  |  |   75|     10|#define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  144|     10|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 10]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  174|      0|#define __DBGINDENTLESS()  debug_indent_add(-2)
  |  |  ------------------
  |  |  |  Branch (75:74): [Folded, False: 10]
  |  |  ------------------
  ------------------
 2653|       |        /*
 2654|       |         * RETURN parse error 
 2655|     10|         */ return -1;
 2656|     10|    }
 2657|  1.59k|    DEBUGINDENTLESS();
  ------------------
  |  |   75|  1.59k|#define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  144|  1.59k|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 1.59k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  174|      0|#define __DBGINDENTLESS()  debug_indent_add(-2)
  |  |  ------------------
  |  |  |  Branch (75:74): [Folded, False: 1.59k]
  |  |  ------------------
  ------------------
 2658|       |
 2659|  1.59k|    if (type_value !=
  ------------------
  |  Branch (2659:9): [True: 2, False: 1.59k]
  ------------------
 2660|  1.59k|        (u_char) (ASN_UNIVERSAL | ASN_PRIMITIVE | ASN_OCTET_STR)) {
  ------------------
  |  |   90|  1.59k|#define ASN_UNIVERSAL	    0x00U
  ------------------
                      (u_char) (ASN_UNIVERSAL | ASN_PRIMITIVE | ASN_OCTET_STR)) {
  ------------------
  |  |   95|  1.59k|#define ASN_PRIMITIVE	    0x00U
  ------------------
                      (u_char) (ASN_UNIVERSAL | ASN_PRIMITIVE | ASN_OCTET_STR)) {
  ------------------
  |  |   78|  1.59k|#define ASN_OCTET_STR	    0x04U
  ------------------
 2661|       |        /*
 2662|       |         * RETURN parse error 
 2663|      2|         */ return -1;
 2664|      2|    }
 2665|       |
 2666|  1.59k|    if (*signature_length != 0) {       /* Blanking for authentication step later */
  ------------------
  |  Branch (2666:9): [True: 64, False: 1.53k]
  ------------------
 2667|     64|        memset(next_ptr - (u_long) * signature_length,
 2668|     64|               0, *signature_length);
 2669|     64|    }
 2670|       |
 2671|       |
 2672|       |    /*
 2673|       |     * Retrieve the salt.
 2674|       |     *
 2675|       |     * Note that the next ptr is where the data section starts.
 2676|       |     */
 2677|  1.59k|    DEBUGDUMPHEADER("recv", "msgPrivacyParameters");
  ------------------
  |  |   79|  1.59k|	do {if (_DBG_IF_) {__DBGDUMPHEADER(token,x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|  1.59k|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 1.59k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               	do {if (_DBG_IF_) {__DBGDUMPHEADER(token,x);} }while(0)
  |  |  ------------------
  |  |  |  |  178|      0|        __DBGPRINTINDENT("dumph_" token); \
  |  |  |  |  ------------------
  |  |  |  |  |  |  175|      0|#define __DBGPRINTINDENT(token) __DBGMSGTL((token, "%*s", __DBGINDENT(), ""))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  179|      0|        debugmsg("dumph_" token,x); \
  |  |  |  |  180|      0|        if (debug_is_token_registered("dumpx" token) == SNMPERR_SUCCESS ||    \
  |  |  |  |  ------------------
  |  |  |  |  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (180:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  181|      0|            debug_is_token_registered("dumpv" token) == SNMPERR_SUCCESS ||    \
  |  |  |  |  ------------------
  |  |  |  |  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (181:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  182|      0|            (debug_is_token_registered("dumpx_" token) != SNMPERR_SUCCESS &&  \
  |  |  |  |  ------------------
  |  |  |  |  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (182:14): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  183|      0|             debug_is_token_registered("dumpv_" token) != SNMPERR_SUCCESS)) { \
  |  |  |  |  ------------------
  |  |  |  |  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:14): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  184|      0|            debugmsg("dumph_" token,"\n"); \
  |  |  |  |  185|      0|        } else { \
  |  |  |  |  186|      0|            debugmsg("dumph_" token,"  "); \
  |  |  |  |  187|      0|        } \
  |  |  |  |  188|      0|        __DBGINDENTMORE()
  |  |  |  |  ------------------
  |  |  |  |  |  |  173|      0|#define __DBGINDENTMORE()  debug_indent_add(2)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (79:55): [Folded, False: 1.59k]
  |  |  ------------------
  ------------------
 2678|  1.59k|    if ((*data_ptr
  ------------------
  |  Branch (2678:9): [True: 6, False: 1.59k]
  ------------------
 2679|  1.59k|         = asn_parse_string(next_ptr, &remaining_bytes, &type_value,
 2680|  1.59k|                            salt, salt_length)) == NULL) {
 2681|      6|        DEBUGINDENTLESS();
  ------------------
  |  |   75|      6|#define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  144|      6|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 6]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  174|      0|#define __DBGINDENTLESS()  debug_indent_add(-2)
  |  |  ------------------
  |  |  |  Branch (75:74): [Folded, False: 6]
  |  |  ------------------
  ------------------
 2682|       |        /*
 2683|       |         * RETURN parse error 
 2684|      6|         */ return -2;
 2685|      6|    }
 2686|  1.59k|    DEBUGINDENTLESS();
  ------------------
  |  |   75|  1.59k|#define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  144|  1.59k|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 1.59k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  174|      0|#define __DBGINDENTLESS()  debug_indent_add(-2)
  |  |  ------------------
  |  |  |  Branch (75:74): [Folded, False: 1.59k]
  |  |  ------------------
  ------------------
 2687|       |
 2688|  1.59k|    if (type_value !=
  ------------------
  |  Branch (2688:9): [True: 2, False: 1.58k]
  ------------------
 2689|  1.59k|        (u_char) (ASN_UNIVERSAL | ASN_PRIMITIVE | ASN_OCTET_STR)) {
  ------------------
  |  |   90|  1.59k|#define ASN_UNIVERSAL	    0x00U
  ------------------
                      (u_char) (ASN_UNIVERSAL | ASN_PRIMITIVE | ASN_OCTET_STR)) {
  ------------------
  |  |   95|  1.59k|#define ASN_PRIMITIVE	    0x00U
  ------------------
                      (u_char) (ASN_UNIVERSAL | ASN_PRIMITIVE | ASN_OCTET_STR)) {
  ------------------
  |  |   78|  1.59k|#define ASN_OCTET_STR	    0x04U
  ------------------
 2690|       |        /*
 2691|       |         * RETURN parse error 
 2692|      2|         */ return -2;
 2693|      2|    }
 2694|       |
 2695|  1.58k|    return 0;
 2696|       |
 2697|  1.59k|}                               /* end usm_parse_security_parameters() */
snmpusm.c:usm_set_usmStateReference_name:
  356|  1.58k|{
  357|       |    MAKE_ENTRY(ref, char, name, name_len, usr_name, usr_name_length);
  ------------------
  |  |  248|  1.58k|#define MAKE_ENTRY(ref, type, item, len, field, field_len)      \
  |  |  249|  1.58k|do {                                                            \
  |  |  250|  1.58k|	if (ref == NULL)                                        \
  |  |  ------------------
  |  |  |  Branch (250:6): [True: 0, False: 1.58k]
  |  |  ------------------
  |  |  251|  1.58k|		return -1;                                      \
  |  |  252|  1.58k|	if (ref->field != NULL)	{                               \
  |  |  ------------------
  |  |  |  Branch (252:6): [True: 0, False: 1.58k]
  |  |  ------------------
  |  |  253|      0|		SNMP_ZERO(ref->field, ref->field_len);          \
  |  |  ------------------
  |  |  |  |   77|      0|#define SNMP_ZERO(s,l)	do { if (s) memset(s, 0, l); } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (77:33): [True: 0, False: 0]
  |  |  |  |  |  Branch (77:61): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  254|      0|		SNMP_FREE(ref->field);                          \
  |  |  ------------------
  |  |  |  |   62|      0|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (62:34): [True: 0, False: 0]
  |  |  |  |  |  Branch (62:66): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  255|      0|	}                                                       \
  |  |  256|  1.58k|	ref->field_len = 0;                                     \
  |  |  257|  1.58k|        if (len == 0 || item == NULL)                           \
  |  |  ------------------
  |  |  |  Branch (257:13): [True: 1.22k, False: 360]
  |  |  |  Branch (257:25): [True: 0, False: 360]
  |  |  ------------------
  |  |  258|  1.58k|		return 0;                                       \
  |  |  259|  1.58k|	ref->field = netsnmp_memdup(item, len * sizeof(type));  \
  |  |  260|    360|        if (ref->field == NULL)                                 \
  |  |  ------------------
  |  |  |  Branch (260:13): [True: 0, False: 360]
  |  |  ------------------
  |  |  261|    360|		return -1;                                      \
  |  |  262|    360|                                                                \
  |  |  263|    360|	ref->field_len = len;                                   \
  |  |  264|    360|	return 0;                                               \
  |  |  265|    360|} while (0)
  |  |  ------------------
  |  |  |  Branch (265:10): [Folded, False: 0]
  |  |  ------------------
  ------------------
  358|  1.58k|}
snmpusm.c:usm_set_usmStateReference_engine_id:
  364|  1.58k|{
  365|       |    MAKE_ENTRY(ref, u_char, engine_id, engine_id_len,
  ------------------
  |  |  248|  1.58k|#define MAKE_ENTRY(ref, type, item, len, field, field_len)      \
  |  |  249|  1.58k|do {                                                            \
  |  |  250|  1.58k|	if (ref == NULL)                                        \
  |  |  ------------------
  |  |  |  Branch (250:6): [True: 0, False: 1.58k]
  |  |  ------------------
  |  |  251|  1.58k|		return -1;                                      \
  |  |  252|  1.58k|	if (ref->field != NULL)	{                               \
  |  |  ------------------
  |  |  |  Branch (252:6): [True: 0, False: 1.58k]
  |  |  ------------------
  |  |  253|      0|		SNMP_ZERO(ref->field, ref->field_len);          \
  |  |  ------------------
  |  |  |  |   77|      0|#define SNMP_ZERO(s,l)	do { if (s) memset(s, 0, l); } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (77:33): [True: 0, False: 0]
  |  |  |  |  |  Branch (77:61): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  254|      0|		SNMP_FREE(ref->field);                          \
  |  |  ------------------
  |  |  |  |   62|      0|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (62:34): [True: 0, False: 0]
  |  |  |  |  |  Branch (62:66): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  255|      0|	}                                                       \
  |  |  256|  1.58k|	ref->field_len = 0;                                     \
  |  |  257|  1.58k|        if (len == 0 || item == NULL)                           \
  |  |  ------------------
  |  |  |  Branch (257:13): [True: 1.21k, False: 371]
  |  |  |  Branch (257:25): [True: 0, False: 371]
  |  |  ------------------
  |  |  258|  1.58k|		return 0;                                       \
  |  |  259|  1.58k|	ref->field = netsnmp_memdup(item, len * sizeof(type));  \
  |  |  260|    371|        if (ref->field == NULL)                                 \
  |  |  ------------------
  |  |  |  Branch (260:13): [True: 0, False: 371]
  |  |  ------------------
  |  |  261|    371|		return -1;                                      \
  |  |  262|    371|                                                                \
  |  |  263|    371|	ref->field_len = len;                                   \
  |  |  264|    371|	return 0;                                               \
  |  |  265|    371|} while (0)
  |  |  ------------------
  |  |  |  Branch (265:10): [Folded, False: 0]
  |  |  ------------------
  ------------------
  366|  1.58k|               usr_engine_id, usr_engine_id_length);
  367|  1.58k|}
snmpusm.c:usm_set_usmStateReference_sec_level:
  406|  1.58k|{
  407|  1.58k|    if (ref == NULL)
  ------------------
  |  Branch (407:9): [True: 0, False: 1.58k]
  ------------------
  408|      0|        return -1;
  409|  1.58k|    ref->usr_sec_level = sec_level;
  410|  1.58k|    return 0;
  411|  1.58k|}
snmpusm.c:usm_check_secLevel:
 2876|  1.29k|{
 2877|       |
 2878|  1.29k|    if (user->userStatus != RS_ACTIVE)
  ------------------
  |  |   35|  1.29k|#define RS_ACTIVE	        1
  ------------------
  |  Branch (2878:9): [True: 0, False: 1.29k]
  ------------------
 2879|      0|        return -1;
 2880|       |
 2881|  1.29k|    DEBUGMSGTL(("comparex", "Comparing: %" NETSNMP_PRIo "u %" NETSNMP_PRIo "u ",
  ------------------
  |  |   66|  1.29k|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|  1.29k|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 1.29k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 1.29k]
  |  |  ------------------
  ------------------
 2882|  1.29k|                usmNoPrivProtocol[0], usmNoPrivProtocol[1]));
 2883|  1.29k|    DEBUGMSGOID(("comparex", usmNoPrivProtocol,
  ------------------
  |  |   67|  1.29k|#define DEBUGMSGOID(x)     do {if (_DBG_IF_) {__DBGMSGOID(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|  1.29k|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 1.29k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGOID(x)     do {if (_DBG_IF_) {__DBGMSGOID(x);} }while(0)
  |  |  ------------------
  |  |  |  |  165|      0|#define __DBGMSGOID(x)     debugmsg_oid x
  |  |  ------------------
  |  |  |  Branch (67:71): [Folded, False: 1.29k]
  |  |  ------------------
  ------------------
 2884|  1.29k|                 OID_LENGTH(usmNoPrivProtocol)));
 2885|  1.29k|    DEBUGMSG(("comparex", "\n"));
  ------------------
  |  |   61|  1.29k|#define DEBUGMSG(x)        do {if (_DBG_IF_) {debugmsg x;} }while(0)
  |  |  ------------------
  |  |  |  |  144|  1.29k|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 1.29k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (61:67): [Folded, False: 1.29k]
  |  |  ------------------
  ------------------
 2886|  1.29k|    if (level == SNMP_SEC_LEVEL_AUTHPRIV
  ------------------
  |  |  301|  2.59k|#define SNMP_SEC_LEVEL_AUTHPRIV		3
  ------------------
  |  Branch (2886:9): [True: 2, False: 1.29k]
  ------------------
 2887|      2|        && (netsnmp_oid_equals(user->privProtocol, user->privProtocolLen,
  ------------------
  |  Branch (2887:12): [True: 0, False: 2]
  ------------------
 2888|      2|                             usmNoPrivProtocol,
 2889|      2|                             OID_LENGTH(usmNoPrivProtocol)) ==
  ------------------
  |  |   64|      2|    (sizeof(x) / sizeof((x)[0]) +                                       \
  |  |   65|      2|     sizeof(int[-__builtin_types_compatible_p(typeof(x), typeof(&(x)[0]))]))
  ------------------
 2890|      2|            0)) {
 2891|      0|        DEBUGMSGTL(("usm", "Level: %d\n", level));
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
 2892|      0|        DEBUGMSGTL(("usm", "User (%s) Auth Protocol: ", user->name));
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
 2893|      0|        DEBUGMSGOID(("usm", user->authProtocol, user->authProtocolLen));
  ------------------
  |  |   67|      0|#define DEBUGMSGOID(x)     do {if (_DBG_IF_) {__DBGMSGOID(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGOID(x)     do {if (_DBG_IF_) {__DBGMSGOID(x);} }while(0)
  |  |  ------------------
  |  |  |  |  165|      0|#define __DBGMSGOID(x)     debugmsg_oid x
  |  |  ------------------
  |  |  |  Branch (67:71): [Folded, False: 0]
  |  |  ------------------
  ------------------
 2894|      0|        DEBUGMSG(("usm", ", User Priv Protocol: "));
  ------------------
  |  |   61|      0|#define DEBUGMSG(x)        do {if (_DBG_IF_) {debugmsg x;} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (61:67): [Folded, False: 0]
  |  |  ------------------
  ------------------
 2895|      0|        DEBUGMSGOID(("usm", user->privProtocol, user->privProtocolLen));
  ------------------
  |  |   67|      0|#define DEBUGMSGOID(x)     do {if (_DBG_IF_) {__DBGMSGOID(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGOID(x)     do {if (_DBG_IF_) {__DBGMSGOID(x);} }while(0)
  |  |  ------------------
  |  |  |  |  165|      0|#define __DBGMSGOID(x)     debugmsg_oid x
  |  |  ------------------
  |  |  |  Branch (67:71): [Folded, False: 0]
  |  |  ------------------
  ------------------
 2896|      0|        DEBUGMSG(("usm", "\n"));
  ------------------
  |  |   61|      0|#define DEBUGMSG(x)        do {if (_DBG_IF_) {debugmsg x;} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (61:67): [Folded, False: 0]
  |  |  ------------------
  ------------------
 2897|      0|        return 1;
 2898|      0|    }
 2899|  1.29k|    if ((level == SNMP_SEC_LEVEL_AUTHPRIV
  ------------------
  |  |  301|  2.59k|#define SNMP_SEC_LEVEL_AUTHPRIV		3
  ------------------
  |  Branch (2899:10): [True: 2, False: 1.29k]
  ------------------
 2900|  1.29k|         || level == SNMP_SEC_LEVEL_AUTHNOPRIV)
  ------------------
  |  |  300|  1.29k|#define SNMP_SEC_LEVEL_AUTHNOPRIV	2
  ------------------
  |  Branch (2900:13): [True: 526, False: 771]
  ------------------
 2901|    528|        &&
 2902|    528|        (netsnmp_oid_equals
  ------------------
  |  Branch (2902:9): [True: 0, False: 528]
  ------------------
 2903|    528|         (user->authProtocol, user->authProtocolLen, usmNoAuthProtocol,
 2904|    528|          OID_LENGTH(usmNoAuthProtocol)) == 0)) {
  ------------------
  |  |   64|    528|    (sizeof(x) / sizeof((x)[0]) +                                       \
  |  |   65|    528|     sizeof(int[-__builtin_types_compatible_p(typeof(x), typeof(&(x)[0]))]))
  ------------------
 2905|      0|        DEBUGMSGTL(("usm", "Level: %d\n", level));
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
 2906|      0|        DEBUGMSGTL(("usm", "User (%s) Auth Protocol: ", user->name));
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
 2907|      0|        DEBUGMSGOID(("usm", user->authProtocol, user->authProtocolLen));
  ------------------
  |  |   67|      0|#define DEBUGMSGOID(x)     do {if (_DBG_IF_) {__DBGMSGOID(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGOID(x)     do {if (_DBG_IF_) {__DBGMSGOID(x);} }while(0)
  |  |  ------------------
  |  |  |  |  165|      0|#define __DBGMSGOID(x)     debugmsg_oid x
  |  |  ------------------
  |  |  |  Branch (67:71): [Folded, False: 0]
  |  |  ------------------
  ------------------
 2908|      0|        DEBUGMSG(("usm", ", User Priv Protocol: "));
  ------------------
  |  |   61|      0|#define DEBUGMSG(x)        do {if (_DBG_IF_) {debugmsg x;} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (61:67): [Folded, False: 0]
  |  |  ------------------
  ------------------
 2909|      0|        DEBUGMSGOID(("usm", user->privProtocol, user->privProtocolLen));
  ------------------
  |  |   67|      0|#define DEBUGMSGOID(x)     do {if (_DBG_IF_) {__DBGMSGOID(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGOID(x)     do {if (_DBG_IF_) {__DBGMSGOID(x);} }while(0)
  |  |  ------------------
  |  |  |  |  165|      0|#define __DBGMSGOID(x)     debugmsg_oid x
  |  |  ------------------
  |  |  |  Branch (67:71): [Folded, False: 0]
  |  |  ------------------
  ------------------
 2910|      0|        DEBUGMSG(("usm", "\n"));
  ------------------
  |  |   61|      0|#define DEBUGMSG(x)        do {if (_DBG_IF_) {debugmsg x;} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (61:67): [Folded, False: 0]
  |  |  ------------------
  ------------------
 2911|      0|        return 1;
 2912|      0|    }
 2913|       |
 2914|  1.29k|    return 0;
 2915|  1.29k|}                               /* end usm_check_secLevel() */
snmpusm.c:usm_set_usmStateReference_auth_protocol:
  373|    771|{
  374|       |    MAKE_ENTRY(ref, oid, auth_protocol, auth_protocol_len,
  ------------------
  |  |  248|    771|#define MAKE_ENTRY(ref, type, item, len, field, field_len)      \
  |  |  249|    771|do {                                                            \
  |  |  250|    771|	if (ref == NULL)                                        \
  |  |  ------------------
  |  |  |  Branch (250:6): [True: 0, False: 771]
  |  |  ------------------
  |  |  251|    771|		return -1;                                      \
  |  |  252|    771|	if (ref->field != NULL)	{                               \
  |  |  ------------------
  |  |  |  Branch (252:6): [True: 0, False: 771]
  |  |  ------------------
  |  |  253|      0|		SNMP_ZERO(ref->field, ref->field_len);          \
  |  |  ------------------
  |  |  |  |   77|      0|#define SNMP_ZERO(s,l)	do { if (s) memset(s, 0, l); } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (77:33): [True: 0, False: 0]
  |  |  |  |  |  Branch (77:61): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  254|      0|		SNMP_FREE(ref->field);                          \
  |  |  ------------------
  |  |  |  |   62|      0|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (62:34): [True: 0, False: 0]
  |  |  |  |  |  Branch (62:66): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  255|      0|	}                                                       \
  |  |  256|    771|	ref->field_len = 0;                                     \
  |  |  257|    771|        if (len == 0 || item == NULL)                           \
  |  |  ------------------
  |  |  |  Branch (257:13): [True: 0, False: 771]
  |  |  |  Branch (257:25): [True: 0, False: 771]
  |  |  ------------------
  |  |  258|    771|		return 0;                                       \
  |  |  259|    771|	ref->field = netsnmp_memdup(item, len * sizeof(type));  \
  |  |  260|    771|        if (ref->field == NULL)                                 \
  |  |  ------------------
  |  |  |  Branch (260:13): [True: 0, False: 771]
  |  |  ------------------
  |  |  261|    771|		return -1;                                      \
  |  |  262|    771|                                                                \
  |  |  263|    771|	ref->field_len = len;                                   \
  |  |  264|    771|	return 0;                                               \
  |  |  265|    771|} while (0)
  |  |  ------------------
  |  |  |  Branch (265:10): [Folded, False: 0]
  |  |  ------------------
  ------------------
  375|    771|               usr_auth_protocol, usr_auth_protocol_length);
  376|    771|}
snmpusm.c:usm_set_usmStateReference_auth_key:
  381|    771|{
  382|       |    MAKE_ENTRY(ref, u_char, auth_key, auth_key_len,
  ------------------
  |  |  248|    771|#define MAKE_ENTRY(ref, type, item, len, field, field_len)      \
  |  |  249|    771|do {                                                            \
  |  |  250|    771|	if (ref == NULL)                                        \
  |  |  ------------------
  |  |  |  Branch (250:6): [True: 0, False: 771]
  |  |  ------------------
  |  |  251|    771|		return -1;                                      \
  |  |  252|    771|	if (ref->field != NULL)	{                               \
  |  |  ------------------
  |  |  |  Branch (252:6): [True: 0, False: 771]
  |  |  ------------------
  |  |  253|      0|		SNMP_ZERO(ref->field, ref->field_len);          \
  |  |  ------------------
  |  |  |  |   77|      0|#define SNMP_ZERO(s,l)	do { if (s) memset(s, 0, l); } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (77:33): [True: 0, False: 0]
  |  |  |  |  |  Branch (77:61): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  254|      0|		SNMP_FREE(ref->field);                          \
  |  |  ------------------
  |  |  |  |   62|      0|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (62:34): [True: 0, False: 0]
  |  |  |  |  |  Branch (62:66): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  255|      0|	}                                                       \
  |  |  256|    771|	ref->field_len = 0;                                     \
  |  |  257|    771|        if (len == 0 || item == NULL)                           \
  |  |  ------------------
  |  |  |  Branch (257:13): [True: 771, False: 0]
  |  |  |  Branch (257:25): [True: 0, False: 0]
  |  |  ------------------
  |  |  258|    771|		return 0;                                       \
  |  |  259|    771|	ref->field = netsnmp_memdup(item, len * sizeof(type));  \
  |  |  260|      0|        if (ref->field == NULL)                                 \
  |  |  ------------------
  |  |  |  Branch (260:13): [True: 0, False: 0]
  |  |  ------------------
  |  |  261|      0|		return -1;                                      \
  |  |  262|      0|                                                                \
  |  |  263|      0|	ref->field_len = len;                                   \
  |  |  264|      0|	return 0;                                               \
  |  |  265|      0|} while (0)
  |  |  ------------------
  |  |  |  Branch (265:10): [Folded, False: 0]
  |  |  ------------------
  ------------------
  383|    771|               usr_auth_key, usr_auth_key_length);
  384|    771|}
snmpusm.c:usm_set_usmStateReference_priv_protocol:
  390|    771|{
  391|       |    MAKE_ENTRY(ref, oid, priv_protocol, priv_protocol_len,
  ------------------
  |  |  248|    771|#define MAKE_ENTRY(ref, type, item, len, field, field_len)      \
  |  |  249|    771|do {                                                            \
  |  |  250|    771|	if (ref == NULL)                                        \
  |  |  ------------------
  |  |  |  Branch (250:6): [True: 0, False: 771]
  |  |  ------------------
  |  |  251|    771|		return -1;                                      \
  |  |  252|    771|	if (ref->field != NULL)	{                               \
  |  |  ------------------
  |  |  |  Branch (252:6): [True: 0, False: 771]
  |  |  ------------------
  |  |  253|      0|		SNMP_ZERO(ref->field, ref->field_len);          \
  |  |  ------------------
  |  |  |  |   77|      0|#define SNMP_ZERO(s,l)	do { if (s) memset(s, 0, l); } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (77:33): [True: 0, False: 0]
  |  |  |  |  |  Branch (77:61): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  254|      0|		SNMP_FREE(ref->field);                          \
  |  |  ------------------
  |  |  |  |   62|      0|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (62:34): [True: 0, False: 0]
  |  |  |  |  |  Branch (62:66): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  255|      0|	}                                                       \
  |  |  256|    771|	ref->field_len = 0;                                     \
  |  |  257|    771|        if (len == 0 || item == NULL)                           \
  |  |  ------------------
  |  |  |  Branch (257:13): [True: 0, False: 771]
  |  |  |  Branch (257:25): [True: 0, False: 771]
  |  |  ------------------
  |  |  258|    771|		return 0;                                       \
  |  |  259|    771|	ref->field = netsnmp_memdup(item, len * sizeof(type));  \
  |  |  260|    771|        if (ref->field == NULL)                                 \
  |  |  ------------------
  |  |  |  Branch (260:13): [True: 0, False: 771]
  |  |  ------------------
  |  |  261|    771|		return -1;                                      \
  |  |  262|    771|                                                                \
  |  |  263|    771|	ref->field_len = len;                                   \
  |  |  264|    771|	return 0;                                               \
  |  |  265|    771|} while (0)
  |  |  ------------------
  |  |  |  Branch (265:10): [Folded, False: 0]
  |  |  ------------------
  ------------------
  392|    771|               usr_priv_protocol, usr_priv_protocol_length);
  393|    771|}
snmpusm.c:usm_set_usmStateReference_priv_key:
  398|    771|{
  399|       |    MAKE_ENTRY(ref, u_char, priv_key, priv_key_len,
  ------------------
  |  |  248|    771|#define MAKE_ENTRY(ref, type, item, len, field, field_len)      \
  |  |  249|    771|do {                                                            \
  |  |  250|    771|	if (ref == NULL)                                        \
  |  |  ------------------
  |  |  |  Branch (250:6): [True: 0, False: 771]
  |  |  ------------------
  |  |  251|    771|		return -1;                                      \
  |  |  252|    771|	if (ref->field != NULL)	{                               \
  |  |  ------------------
  |  |  |  Branch (252:6): [True: 0, False: 771]
  |  |  ------------------
  |  |  253|      0|		SNMP_ZERO(ref->field, ref->field_len);          \
  |  |  ------------------
  |  |  |  |   77|      0|#define SNMP_ZERO(s,l)	do { if (s) memset(s, 0, l); } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (77:33): [True: 0, False: 0]
  |  |  |  |  |  Branch (77:61): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  254|      0|		SNMP_FREE(ref->field);                          \
  |  |  ------------------
  |  |  |  |   62|      0|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (62:34): [True: 0, False: 0]
  |  |  |  |  |  Branch (62:66): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  255|      0|	}                                                       \
  |  |  256|    771|	ref->field_len = 0;                                     \
  |  |  257|    771|        if (len == 0 || item == NULL)                           \
  |  |  ------------------
  |  |  |  Branch (257:13): [True: 771, False: 0]
  |  |  |  Branch (257:25): [True: 0, False: 0]
  |  |  ------------------
  |  |  258|    771|		return 0;                                       \
  |  |  259|    771|	ref->field = netsnmp_memdup(item, len * sizeof(type));  \
  |  |  260|      0|        if (ref->field == NULL)                                 \
  |  |  ------------------
  |  |  |  Branch (260:13): [True: 0, False: 0]
  |  |  ------------------
  |  |  261|      0|		return -1;                                      \
  |  |  262|      0|                                                                \
  |  |  263|      0|	ref->field_len = len;                                   \
  |  |  264|      0|	return 0;                                               \
  |  |  265|      0|} while (0)
  |  |  ------------------
  |  |  |  Branch (265:10): [Folded, False: 0]
  |  |  ------------------
  ------------------
  400|    771|               usr_priv_key, usr_priv_key_length);
  401|    771|}
snmpusm.c:usm_clone:
  300|     24|{
  301|     24|    struct usmStateReference *ref = pdu->securityStateRef;
  302|     24|    struct usmStateReference **new_ref =
  303|     24|        (struct usmStateReference **)&new_pdu->securityStateRef;
  304|     24|    int ret = 0;
  305|       |
  306|     24|    if (!ref)
  ------------------
  |  Branch (306:9): [True: 16, False: 8]
  ------------------
  307|     16|        return ret;
  308|       |
  309|      8|    if (pdu->command == SNMP_MSG_TRAP2) {
  ------------------
  |  |  142|      8|#define SNMP_MSG_TRAP2      (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x7) /* a7=167 */
  |  |  ------------------
  |  |  |  |   92|      8|#define ASN_CONTEXT	    0x80U
  |  |  ------------------
  |  |               #define SNMP_MSG_TRAP2      (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x7) /* a7=167 */
  |  |  ------------------
  |  |  |  |   96|      8|#define ASN_CONSTRUCTOR	    0x20U
  |  |  ------------------
  ------------------
  |  Branch (309:9): [True: 0, False: 8]
  ------------------
  310|      0|        ret = usm_clone_usmStateReference(ref, new_ref);
  311|      8|    } else {
  312|      8|        *new_ref = ref;
  313|      8|        ref->refcnt++;
  314|      8|    }
  315|       |
  316|      8|    return ret;
  317|     24|}
snmpusm.c:usm_free_usmStateReference:
  321|  3.66k|{
  322|  3.66k|    struct usmStateReference *ref = old;
  323|       |
  324|  3.66k|    if (!ref)
  ------------------
  |  Branch (324:9): [True: 1.83k, False: 1.83k]
  ------------------
  325|  1.83k|        return;
  326|       |
  327|  1.83k|    if (--ref->refcnt > 0)
  ------------------
  |  Branch (327:9): [True: 8, False: 1.83k]
  ------------------
  328|      8|        return;
  329|       |
  330|  1.83k|    SNMP_FREE(ref->usr_name);
  ------------------
  |  |   62|  1.83k|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 360, False: 1.47k]
  |  |  |  Branch (62:66): [Folded, False: 1.83k]
  |  |  ------------------
  ------------------
  331|  1.83k|    SNMP_FREE(ref->usr_engine_id);
  ------------------
  |  |   62|  1.83k|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 371, False: 1.45k]
  |  |  |  Branch (62:66): [Folded, False: 1.83k]
  |  |  ------------------
  ------------------
  332|  1.83k|    SNMP_FREE(ref->usr_auth_protocol);
  ------------------
  |  |   62|  1.83k|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 771, False: 1.05k]
  |  |  |  Branch (62:66): [Folded, False: 1.83k]
  |  |  ------------------
  ------------------
  333|  1.83k|    SNMP_FREE(ref->usr_priv_protocol);
  ------------------
  |  |   62|  1.83k|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 771, False: 1.05k]
  |  |  |  Branch (62:66): [Folded, False: 1.83k]
  |  |  ------------------
  ------------------
  334|       |
  335|  1.83k|    if (ref->usr_auth_key_length && ref->usr_auth_key) {
  ------------------
  |  Branch (335:9): [True: 0, False: 1.83k]
  |  Branch (335:37): [True: 0, False: 0]
  ------------------
  336|      0|        SNMP_ZERO(ref->usr_auth_key, ref->usr_auth_key_length);
  ------------------
  |  |   77|      0|#define SNMP_ZERO(s,l)	do { if (s) memset(s, 0, l); } while(0)
  |  |  ------------------
  |  |  |  Branch (77:33): [True: 0, False: 0]
  |  |  |  Branch (77:61): [Folded, False: 0]
  |  |  ------------------
  ------------------
  337|      0|        SNMP_FREE(ref->usr_auth_key);
  ------------------
  |  |   62|      0|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 0, False: 0]
  |  |  |  Branch (62:66): [Folded, False: 0]
  |  |  ------------------
  ------------------
  338|      0|    }
  339|  1.83k|    if (ref->usr_priv_key_length && ref->usr_priv_key) {
  ------------------
  |  Branch (339:9): [True: 0, False: 1.83k]
  |  Branch (339:37): [True: 0, False: 0]
  ------------------
  340|      0|        SNMP_ZERO(ref->usr_priv_key, ref->usr_priv_key_length);
  ------------------
  |  |   77|      0|#define SNMP_ZERO(s,l)	do { if (s) memset(s, 0, l); } while(0)
  |  |  ------------------
  |  |  |  Branch (77:33): [True: 0, False: 0]
  |  |  |  Branch (77:61): [Folded, False: 0]
  |  |  ------------------
  ------------------
  341|      0|        SNMP_FREE(ref->usr_priv_key);
  ------------------
  |  |   62|      0|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 0, False: 0]
  |  |  |  Branch (62:66): [Folded, False: 0]
  |  |  ------------------
  ------------------
  342|      0|    }
  343|       |
  344|       |    SNMP_FREE(ref);
  ------------------
  |  |   62|  1.83k|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 1.83k, False: 0]
  |  |  |  Branch (62:66): [Folded, False: 1.83k]
  |  |  ------------------
  ------------------
  345|  1.83k|}                               /* end usm_free_usmStateReference() */
snmpusm.c:init_usm_post_config:
 5208|      2|{
 5209|      2|    size_t          salt_integer_len = sizeof(salt_integer);
 5210|      2|    uint64_t        current_time;
 5211|       |
 5212|      2|    if (sc_random((u_char *) & salt_integer, &salt_integer_len) !=
  ------------------
  |  Branch (5212:9): [True: 0, False: 2]
  ------------------
 5213|      2|        SNMPERR_SUCCESS) {
  ------------------
  |  |  184|      2|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
 5214|      0|        DEBUGMSGTL(("usm", "sc_random() failed: using time() as salt.\n"));
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
 5215|      0|        current_time = time(NULL);
 5216|      0|        salt_integer = current_time;
 5217|      0|    }
 5218|       |
 5219|      2|#ifdef HAVE_AES
 5220|      2|    salt_integer_len = sizeof (salt_integer64_1);
 5221|      2|    if (sc_random((u_char *) & salt_integer64_1, &salt_integer_len) !=
  ------------------
  |  Branch (5221:9): [True: 0, False: 2]
  ------------------
 5222|      2|        SNMPERR_SUCCESS) {
  ------------------
  |  |  184|      2|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
 5223|      0|        DEBUGMSGTL(("usm", "sc_random() failed: using time() as aes1 salt.\n"));
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
 5224|      0|        current_time = time(NULL);
 5225|      0|        salt_integer64_1 = current_time;
 5226|      0|    }
 5227|      2|    salt_integer_len = sizeof (salt_integer64_1);
 5228|      2|    if (sc_random((u_char *) & salt_integer64_2, &salt_integer_len) !=
  ------------------
  |  Branch (5228:9): [True: 0, False: 2]
  ------------------
 5229|      2|        SNMPERR_SUCCESS) {
  ------------------
  |  |  184|      2|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
 5230|      0|        DEBUGMSGTL(("usm", "sc_random() failed: using time() as aes2 salt.\n"));
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
 5231|      0|        current_time = time(NULL);
 5232|      0|        salt_integer64_2 = current_time;
 5233|      0|    }
 5234|      2|#endif
 5235|       |
 5236|       |    // Free noNameUser before it is assigned
 5237|      2|    usm_free_user(noNameUser);
 5238|       |
 5239|      2|#ifndef NETSNMP_DISABLE_MD5
 5240|      2|    noNameUser = usm_create_initial_user("", usmHMACMD5AuthProtocol,
 5241|      2|                                         OID_LENGTH(usmHMACMD5AuthProtocol),
  ------------------
  |  |   64|      2|    (sizeof(x) / sizeof((x)[0]) +                                       \
  |  |   65|      2|     sizeof(int[-__builtin_types_compatible_p(typeof(x), typeof(&(x)[0]))]))
  ------------------
 5242|      2|                                         SNMP_DEFAULT_PRIV_PROTO,
  ------------------
  |  |  100|      2|#define SNMP_DEFAULT_PRIV_PROTO     usmDESPrivProtocol
  ------------------
 5243|      2|                                         SNMP_DEFAULT_PRIV_PROTOLEN);
  ------------------
  |  |  104|      2|#define SNMP_DEFAULT_PRIV_PROTOLEN  OID_LENGTH(SNMP_DEFAULT_PRIV_PROTO)
  |  |  ------------------
  |  |  |  |   64|      2|    (sizeof(x) / sizeof((x)[0]) +                                       \
  |  |  |  |   65|      2|     sizeof(int[-__builtin_types_compatible_p(typeof(x), typeof(&(x)[0]))]))
  |  |  ------------------
  ------------------
 5244|       |#else
 5245|       |    noNameUser = usm_create_initial_user("", usmHMACSHA1AuthProtocol,
 5246|       |                                         OID_LENGTH(usmHMACSHA1AuthProtocol),
 5247|       |                                         SNMP_DEFAULT_PRIV_PROTO,
 5248|       |                                         SNMP_DEFAULT_PRIV_PROTOLEN);
 5249|       |#endif
 5250|       |
 5251|      2|    if ( noNameUser ) {
  ------------------
  |  Branch (5251:10): [True: 2, False: 0]
  ------------------
 5252|      2|        SNMP_FREE(noNameUser->engineID);
  ------------------
  |  |   62|      2|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 2, False: 0]
  |  |  |  Branch (62:66): [Folded, False: 2]
  |  |  ------------------
  ------------------
 5253|      2|        noNameUser->engineIDLen = 0;
 5254|      2|    }
 5255|       |
 5256|      2|    return SNMPERR_SUCCESS;
  ------------------
  |  |  184|      2|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
 5257|      2|}                               /* end init_usm_post_config() */
snmpusm.c:usm_create_initial_user:
 4205|      2|{
 4206|      2|    struct usmUser *newUser = usm_create_user();
 4207|      2|    if (newUser == NULL)
  ------------------
  |  Branch (4207:9): [True: 0, False: 2]
  ------------------
 4208|      0|        return NULL;
 4209|       |
 4210|      2|    if ((newUser->name = strdup(name)) == NULL)
  ------------------
  |  Branch (4210:9): [True: 0, False: 2]
  ------------------
 4211|      0|        return usm_free_user(newUser);
 4212|       |
 4213|      2|    if ((newUser->secName = strdup(name)) == NULL)
  ------------------
  |  Branch (4213:9): [True: 0, False: 2]
  ------------------
 4214|      0|        return usm_free_user(newUser);
 4215|       |
 4216|      2|    if ((newUser->engineID =
  ------------------
  |  Branch (4216:9): [True: 0, False: 2]
  ------------------
 4217|      2|         snmpv3_generate_engineID(&newUser->engineIDLen)) == NULL)
 4218|      0|        return usm_free_user(newUser);
 4219|       |
 4220|      2|    if ((newUser->cloneFrom = (oid *) malloc(sizeof(oid) * 2)) == NULL)
  ------------------
  |  Branch (4220:9): [True: 0, False: 2]
  ------------------
 4221|      0|        return usm_free_user(newUser);
 4222|      2|    newUser->cloneFrom[0] = 0;
 4223|      2|    newUser->cloneFrom[1] = 0;
 4224|      2|    newUser->cloneFromLen = 2;
 4225|       |
 4226|      2|    SNMP_FREE(newUser->privProtocol);
  ------------------
  |  |   62|      2|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 2, False: 0]
  |  |  |  Branch (62:66): [Folded, False: 2]
  |  |  ------------------
  ------------------
 4227|      2|    if ((newUser->privProtocol = snmp_duplicate_objid(privProtocol,
  ------------------
  |  Branch (4227:9): [True: 0, False: 2]
  ------------------
 4228|      2|                                                      privProtocolLen)) ==
 4229|      2|        NULL) {
 4230|      0|        return usm_free_user(newUser);
 4231|      0|    }
 4232|      2|    newUser->privProtocolLen = privProtocolLen;
 4233|       |
 4234|      2|    SNMP_FREE(newUser->authProtocol);
  ------------------
  |  |   62|      2|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 2, False: 0]
  |  |  |  Branch (62:66): [Folded, False: 2]
  |  |  ------------------
  ------------------
 4235|      2|    if ((newUser->authProtocol = snmp_duplicate_objid(authProtocol,
  ------------------
  |  Branch (4235:9): [True: 0, False: 2]
  ------------------
 4236|      2|                                                      authProtocolLen)) ==
 4237|      2|        NULL) {
 4238|      0|        return usm_free_user(newUser);
 4239|      0|    }
 4240|      2|    newUser->authProtocolLen = authProtocolLen;
 4241|       |
 4242|      2|    newUser->userStatus = RS_ACTIVE;
  ------------------
  |  |   35|      2|#define RS_ACTIVE	        1
  ------------------
 4243|      2|    newUser->userStorageType = ST_READONLY;
  ------------------
  |  |   54|      2|#define ST_READONLY	5
  ------------------
 4244|       |
 4245|      2|    return newUser;
 4246|      2|}

setup_engineID:
  471|      2|{
  472|      2|    int             enterpriseid = htonl(NETSNMP_ENTERPRISE_OID),
  473|      2|        netsnmpoid = htonl(NETSNMP_OID),
  474|      2|        localsetup = (eidp) ? 0 : 1;
  ------------------
  |  Branch (474:22): [True: 0, False: 2]
  ------------------
  475|       |
  476|       |    /*
  477|       |     * Use local engineID if *eidp == NULL.  
  478|       |     */
  479|      2|#ifdef HAVE_GETHOSTNAME
  480|      2|    u_char          buf[SNMP_MAXBUF_SMALL];
  481|      2|    struct hostent *hent = NULL;
  482|      2|#endif
  483|      2|    u_char         *bufp = NULL;
  484|      2|    size_t          len;
  485|      2|    int             localEngineIDType = engineIDType;
  486|      2|    int             tmpint;
  487|      2|    time_t          tmptime;
  488|       |
  489|      2|    engineIDIsSet = 1;
  490|       |
  491|      2|#ifdef HAVE_GETHOSTNAME
  492|      2|#ifdef AF_INET6
  493|       |    /*
  494|       |     * see if they selected IPV4 or IPV6 support 
  495|       |     */
  496|      2|    if ((ENGINEID_TYPE_IPV6 == localEngineIDType) ||
  ------------------
  |  |   20|      2|#define ENGINEID_TYPE_IPV6    2
  ------------------
  |  Branch (496:9): [True: 0, False: 2]
  ------------------
  497|      2|        (ENGINEID_TYPE_IPV4 == localEngineIDType)) {
  ------------------
  |  |   19|      2|#define ENGINEID_TYPE_IPV4    1
  ------------------
  |  Branch (497:9): [True: 0, False: 2]
  ------------------
  498|       |        /*
  499|       |         * get the host name and save the information 
  500|       |         */
  501|      0|        gethostname((char *) buf, sizeof(buf));
  502|      0|        hent = netsnmp_gethostbyname((char *) buf);
  503|      0|        if (hent && hent->h_addrtype == AF_INET6) {
  ------------------
  |  Branch (503:13): [True: 0, False: 0]
  |  Branch (503:21): [True: 0, False: 0]
  ------------------
  504|      0|            localEngineIDType = ENGINEID_TYPE_IPV6;
  ------------------
  |  |   20|      0|#define ENGINEID_TYPE_IPV6    2
  ------------------
  505|      0|        } else {
  506|       |            /*
  507|       |             * Not IPV6 so we go with default 
  508|       |             */
  509|      0|            localEngineIDType = ENGINEID_TYPE_IPV4;
  ------------------
  |  |   19|      0|#define ENGINEID_TYPE_IPV4    1
  ------------------
  510|      0|        }
  511|      0|    }
  512|       |#else
  513|       |    /*
  514|       |     * No IPV6 support.  Check if they selected IPV6 engineID type.
  515|       |     *  If so make it IPV4 instead 
  516|       |     */
  517|       |    if (ENGINEID_TYPE_IPV6 == localEngineIDType) {
  518|       |        localEngineIDType = ENGINEID_TYPE_IPV4;
  519|       |    }
  520|       |    if (ENGINEID_TYPE_IPV4 == localEngineIDType) {
  521|       |        /*
  522|       |         * get the host name and save the information 
  523|       |         */
  524|       |        gethostname((char *) buf, sizeof(buf));
  525|       |        hent = netsnmp_gethostbyname((char *) buf);
  526|       |    }
  527|       |#endif
  528|      2|#endif                          /* HAVE_GETHOSTNAME */
  529|       |
  530|       |    /*
  531|       |     * Determine if we have text and if so setup our localEngineIDType
  532|       |     * * appropriately.  
  533|       |     */
  534|      2|    if (NULL != text) {
  ------------------
  |  Branch (534:9): [True: 0, False: 2]
  ------------------
  535|      0|        engineIDType = localEngineIDType = ENGINEID_TYPE_TEXT;
  ------------------
  |  |   22|      0|#define ENGINEID_TYPE_TEXT    4
  ------------------
  536|      0|    }
  537|       |    /*
  538|       |     * Determine length of the engineID string. 
  539|       |     */
  540|      2|    len = 5;                    /* always have 5 leading bytes */
  541|      2|    switch (localEngineIDType) {
  542|      0|    case ENGINEID_TYPE_TEXT:
  ------------------
  |  |   22|      0|#define ENGINEID_TYPE_TEXT    4
  ------------------
  |  Branch (542:5): [True: 0, False: 2]
  ------------------
  543|      0|        if (NULL == text) {
  ------------------
  |  Branch (543:13): [True: 0, False: 0]
  ------------------
  544|      0|            snmp_log(LOG_ERR,
  545|      0|                     "Can't set up engineID of type text from an empty string.\n");
  546|      0|            return -1;
  547|      0|        }
  548|      0|        len += strlen(text);    /* 5 leading bytes+text. No NULL char */
  549|      0|        break;
  550|      0|#if defined(IFHWADDRLEN) && defined(SIOCGIFHWADDR)
  551|      0|    case ENGINEID_TYPE_MACADDR:        /* MAC address */
  ------------------
  |  |   21|      0|#define ENGINEID_TYPE_MACADDR 3
  ------------------
  |  Branch (551:5): [True: 0, False: 2]
  ------------------
  552|      0|        len += 6;               /* + 6 bytes for MAC address */
  553|      0|        break;
  554|      0|#endif
  555|      0|    case ENGINEID_TYPE_IPV4:   /* IPv4 */
  ------------------
  |  |   19|      0|#define ENGINEID_TYPE_IPV4    1
  ------------------
  |  Branch (555:5): [True: 0, False: 2]
  ------------------
  556|      0|        len += 4;               /* + 4 byte IPV4 address */
  557|      0|        break;
  558|      0|    case ENGINEID_TYPE_IPV6:   /* IPv6 */
  ------------------
  |  |   20|      0|#define ENGINEID_TYPE_IPV6    2
  ------------------
  |  Branch (558:5): [True: 0, False: 2]
  ------------------
  559|      0|        len += 16;              /* + 16 byte IPV6 address */
  560|      0|        break;
  561|      2|    case ENGINEID_TYPE_NETSNMP_RND:        /* Net-SNMP specific encoding */
  ------------------
  |  |   24|      2|#define ENGINEID_TYPE_NETSNMP_RND 128
  ------------------
  |  Branch (561:5): [True: 2, False: 0]
  ------------------
  562|      2|        if (engineID)           /* already setup, keep current value */
  ------------------
  |  Branch (562:13): [True: 0, False: 2]
  ------------------
  563|      0|            return engineIDLength;
  564|      2|        if (oldEngineID) {
  ------------------
  |  Branch (564:13): [True: 0, False: 2]
  ------------------
  565|      0|            len = oldEngineIDLength;
  566|      2|        } else {
  567|      2|            len += sizeof(int) + sizeof(time_t);
  568|      2|        }
  569|      2|        break;
  570|      0|    default:
  ------------------
  |  Branch (570:5): [True: 0, False: 2]
  ------------------
  571|      0|        snmp_log(LOG_ERR,
  572|      0|                 "Unknown EngineID type requested for setup (%d).  Using IPv4.\n",
  573|      0|                 localEngineIDType);
  574|      0|        localEngineIDType = ENGINEID_TYPE_IPV4; /* make into IPV4 */
  ------------------
  |  |   19|      0|#define ENGINEID_TYPE_IPV4    1
  ------------------
  575|      0|        len += 4;               /* + 4 byte IPv4 address */
  576|      0|        break;
  577|      2|    }                           /* switch */
  578|       |
  579|       |
  580|       |    /*
  581|       |     * Allocate memory and store enterprise ID.
  582|       |     */
  583|      2|    if (len == 0) {
  ------------------
  |  Branch (583:9): [True: 0, False: 2]
  ------------------
  584|      0|        snmp_log(LOG_ERR, "%s(): len == 0\n", __func__);
  585|      0|        return -1;
  586|      0|    }
  587|      2|    bufp = calloc(1, len);
  588|      2|    if (bufp == NULL) {
  ------------------
  |  Branch (588:9): [True: 0, False: 2]
  ------------------
  589|      0|        snmp_log_perror("setup_engineID() calloc()");
  590|      0|        return -1;
  591|      0|    }
  592|      2|    if (localEngineIDType == ENGINEID_TYPE_NETSNMP_RND)
  ------------------
  |  |   24|      2|#define ENGINEID_TYPE_NETSNMP_RND 128
  ------------------
  |  Branch (592:9): [True: 2, False: 0]
  ------------------
  593|       |        /*
  594|       |         * we must use the net-snmp enterprise id here, regardless 
  595|       |         */
  596|      2|        memcpy(bufp, &netsnmpoid, sizeof(netsnmpoid));    /* XXX Must be 4 bytes! */
  597|      0|    else
  598|      0|        memcpy(bufp, &enterpriseid, sizeof(enterpriseid));      /* XXX Must be 4 bytes! */
  599|       |
  600|      2|    bufp[0] |= 0x80;
  601|       |
  602|       |
  603|       |    /*
  604|       |     * Store the given text  -OR-   the first found IP address
  605|       |     *  -OR-  the MAC address  -OR-  random elements
  606|       |     * (the latter being the recommended default)
  607|       |     */
  608|      2|    switch (localEngineIDType) {
  609|      2|    case ENGINEID_TYPE_NETSNMP_RND:
  ------------------
  |  |   24|      2|#define ENGINEID_TYPE_NETSNMP_RND 128
  ------------------
  |  Branch (609:5): [True: 2, False: 0]
  ------------------
  610|      2|        if (oldEngineID) {
  ------------------
  |  Branch (610:13): [True: 0, False: 2]
  ------------------
  611|       |            /*
  612|       |             * keep our previous notion of the engineID 
  613|       |             */
  614|      0|            memcpy(bufp, oldEngineID, oldEngineIDLength);
  615|      2|        } else {
  616|       |            /*
  617|       |             * Here we've desigend our own ENGINEID that is not based on
  618|       |             * an address which may change and may even become conflicting
  619|       |             * in the future like most of the default v3 engineID types
  620|       |             * suffer from.
  621|       |             * 
  622|       |             * Ours is built from 2 fairly random elements: a random number and
  623|       |             * the current time in seconds.  This method suffers from boxes
  624|       |             * that may not have a correct clock setting and random number
  625|       |             * seed at startup, but few OSes should have that problem.
  626|       |             */
  627|      2|            bufp[4] = ENGINEID_TYPE_NETSNMP_RND;
  ------------------
  |  |   24|      2|#define ENGINEID_TYPE_NETSNMP_RND 128
  ------------------
  628|      2|            tmpint = netsnmp_random();
  629|      2|            memcpy(bufp + 5, &tmpint, sizeof(tmpint));
  630|      2|            tmptime = time(NULL);
  631|      2|            memcpy(bufp + 5 + sizeof(tmpint), &tmptime, sizeof(tmptime));
  632|      2|        }
  633|      2|        break;
  634|      0|    case ENGINEID_TYPE_TEXT:
  ------------------
  |  |   22|      0|#define ENGINEID_TYPE_TEXT    4
  ------------------
  |  Branch (634:5): [True: 0, False: 2]
  ------------------
  635|      0|        bufp[4] = ENGINEID_TYPE_TEXT;
  ------------------
  |  |   22|      0|#define ENGINEID_TYPE_TEXT    4
  ------------------
  636|      0|        memcpy((char *) bufp + 5, (text), strlen(text));
  637|      0|        break;
  638|      0|#ifdef HAVE_GETHOSTNAME
  639|      0|#ifdef AF_INET6
  640|      0|    case ENGINEID_TYPE_IPV6:
  ------------------
  |  |   20|      0|#define ENGINEID_TYPE_IPV6    2
  ------------------
  |  Branch (640:5): [True: 0, False: 2]
  ------------------
  641|      0|        bufp[4] = ENGINEID_TYPE_IPV6;
  ------------------
  |  |   20|      0|#define ENGINEID_TYPE_IPV6    2
  ------------------
  642|      0|        if (hent)
  ------------------
  |  Branch (642:13): [True: 0, False: 0]
  ------------------
  643|      0|            memcpy(bufp + 5, hent->h_addr_list[0], hent->h_length);
  644|      0|        break;
  645|      0|#endif
  646|      0|#endif
  647|      0|#if defined(IFHWADDRLEN) && defined(SIOCGIFHWADDR)
  648|      0|    case ENGINEID_TYPE_MACADDR:
  ------------------
  |  |   21|      0|#define ENGINEID_TYPE_MACADDR 3
  ------------------
  |  Branch (648:5): [True: 0, False: 2]
  ------------------
  649|      0|        {
  650|      0|            int             x;
  651|      0|            bufp[4] = ENGINEID_TYPE_MACADDR;
  ------------------
  |  |   21|      0|#define ENGINEID_TYPE_MACADDR 3
  ------------------
  652|       |            /*
  653|       |             * use default NIC if none provided 
  654|       |             */
  655|      0|            if (NULL == engineIDNic) {
  ------------------
  |  Branch (655:17): [True: 0, False: 0]
  ------------------
  656|      0|	      x = getHwAddress(DEFAULT_NIC, (char *)&bufp[5]);
  ------------------
  |  |   26|      0|#define	DEFAULT_NIC "eth0"
  ------------------
  657|      0|            } else {
  658|      0|	      x = getHwAddress((char *)engineIDNic, (char *)&bufp[5]);
  659|      0|            }
  660|      0|            if (0 != x)
  ------------------
  |  Branch (660:17): [True: 0, False: 0]
  ------------------
  661|       |                /*
  662|       |                 * function failed fill MAC address with zeros 
  663|       |                 */
  664|      0|            {
  665|      0|                memset(&bufp[5], 0, 6);
  666|      0|            }
  667|      0|        }
  668|      0|        break;
  669|      0|#endif
  670|      0|    case ENGINEID_TYPE_IPV4:
  ------------------
  |  |   19|      0|#define ENGINEID_TYPE_IPV4    1
  ------------------
  |  Branch (670:5): [True: 0, False: 2]
  ------------------
  671|      0|    default:
  ------------------
  |  Branch (671:5): [True: 0, False: 2]
  ------------------
  672|      0|        bufp[4] = ENGINEID_TYPE_IPV4;
  ------------------
  |  |   19|      0|#define ENGINEID_TYPE_IPV4    1
  ------------------
  673|      0|#ifdef HAVE_GETHOSTNAME
  674|      0|        if (hent && hent->h_addrtype == AF_INET) {
  ------------------
  |  Branch (674:13): [True: 0, False: 0]
  |  Branch (674:21): [True: 0, False: 0]
  ------------------
  675|      0|            memcpy(bufp + 5, hent->h_addr_list[0], hent->h_length);
  676|      0|        } else {                /* Unknown address type.  Default to 127.0.0.1. */
  677|       |
  678|      0|            bufp[5] = 127;
  679|      0|            bufp[6] = 0;
  680|      0|            bufp[7] = 0;
  681|      0|            bufp[8] = 1;
  682|      0|        }
  683|       |#else                           /* HAVE_GETHOSTNAME */
  684|       |        /*
  685|       |         * Unknown address type.  Default to 127.0.0.1. 
  686|       |         */
  687|       |        bufp[5] = 127;
  688|       |        bufp[6] = 0;
  689|       |        bufp[7] = 0;
  690|       |        bufp[8] = 1;
  691|       |#endif                          /* HAVE_GETHOSTNAME */
  692|      0|        break;
  693|      2|    }
  694|       |
  695|       |    /*
  696|       |     * Pass the string back to the calling environment, or use it for
  697|       |     * our local engineID.
  698|       |     */
  699|      2|    if (localsetup) {
  ------------------
  |  Branch (699:9): [True: 2, False: 0]
  ------------------
  700|      2|        SNMP_FREE(engineID);
  ------------------
  |  |   62|      2|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 0, False: 2]
  |  |  |  Branch (62:66): [Folded, False: 2]
  |  |  ------------------
  ------------------
  701|      2|        engineID = bufp;
  702|      2|        engineIDLength = len;
  703|       |
  704|      2|    } else {
  705|      0|        *eidp = bufp;
  706|      0|    }
  707|       |
  708|       |
  709|      2|    return len;
  710|       |
  711|      2|}                               /* end setup_engineID() */
init_snmpv3:
  988|      2|{
  989|      2|    netsnmp_get_monotonic_clock(&snmpv3starttime);
  990|       |
  991|      2|    if (!type)
  ------------------
  |  Branch (991:9): [True: 0, False: 2]
  ------------------
  992|      0|        type = "__snmpapp__";
  993|       |
  994|       |    /*
  995|       |     * we need to be called back later 
  996|       |     */
  997|      2|    snmp_register_callback(SNMP_CALLBACK_LIBRARY,
  ------------------
  |  |   18|      2|#define SNMP_CALLBACK_LIBRARY     0
  ------------------
  998|      2|                           SNMP_CALLBACK_POST_READ_CONFIG,
  ------------------
  |  |   24|      2|#define SNMP_CALLBACK_POST_READ_CONFIG	        0
  ------------------
  999|      2|                           init_snmpv3_post_config, NULL);
 1000|       |
 1001|      2|    snmp_register_callback(SNMP_CALLBACK_LIBRARY,
  ------------------
  |  |   18|      2|#define SNMP_CALLBACK_LIBRARY     0
  ------------------
 1002|      2|                           SNMP_CALLBACK_POST_PREMIB_READ_CONFIG,
  ------------------
  |  |   27|      2|#define SNMP_CALLBACK_POST_PREMIB_READ_CONFIG	3
  ------------------
 1003|      2|                           init_snmpv3_post_premib_config, NULL);
 1004|       |    /*
 1005|       |     * we need to be called back later 
 1006|       |     */
 1007|      2|    snmp_register_callback(SNMP_CALLBACK_LIBRARY, SNMP_CALLBACK_STORE_DATA,
  ------------------
  |  |   18|      2|#define SNMP_CALLBACK_LIBRARY     0
  ------------------
                  snmp_register_callback(SNMP_CALLBACK_LIBRARY, SNMP_CALLBACK_STORE_DATA,
  ------------------
  |  |   25|      2|#define SNMP_CALLBACK_STORE_DATA	        1
  ------------------
 1008|      2|                           snmpv3_store, (void *) strdup(type));
 1009|       |
 1010|       |    /*
 1011|       |     * initialize submodules 
 1012|       |     */
 1013|       |    /*
 1014|       |     * NOTE: this must be after the callbacks are registered above,
 1015|       |     * since they need to be called before the USM callbacks. 
 1016|       |     */
 1017|      2|    init_secmod();
 1018|       |
 1019|       |    /*
 1020|       |     * register all our configuration handlers (ack, there's a lot) 
 1021|       |     */
 1022|       |
 1023|       |    /*
 1024|       |     * handle engineID setup before everything else which may depend on it 
 1025|       |     */
 1026|      2|    register_prenetsnmp_mib_handler(type, "engineID", engineID_conf, NULL,
 1027|      2|                                    "string");
 1028|      2|    register_prenetsnmp_mib_handler(type, "oldEngineID", oldengineID_conf,
 1029|      2|                                    NULL, NULL);
 1030|      2|    register_prenetsnmp_mib_handler(type, "exactEngineID", exactEngineID_conf,
 1031|      2|                                    NULL, NULL);
 1032|      2|    register_prenetsnmp_mib_handler(type, "engineIDType",
 1033|      2|                                    engineIDType_conf, NULL, "num");
 1034|      2|    register_prenetsnmp_mib_handler(type, "engineIDNic", engineIDNic_conf,
 1035|      2|                                    NULL, "string");
 1036|      2|    register_config_handler(type, "engineBoots", engineBoots_conf, NULL,
 1037|      2|                            NULL);
 1038|       |
 1039|       |    /*
 1040|       |     * default store config entries 
 1041|       |     */
 1042|      2|    netsnmp_ds_register_config(ASN_OCTET_STR, "snmp", "defSecurityName",
  ------------------
  |  |   78|      2|#define ASN_OCTET_STR	    0x04U
  ------------------
 1043|      2|			       NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_SECNAME);
  ------------------
  |  |   48|      2|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
              			       NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_SECNAME);
  ------------------
  |  |  151|      2|#define NETSNMP_DS_LIB_SECNAME           0
  ------------------
 1044|      2|    netsnmp_ds_register_config(ASN_OCTET_STR, "snmp", "defContext", 
  ------------------
  |  |   78|      2|#define ASN_OCTET_STR	    0x04U
  ------------------
 1045|      2|			       NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_CONTEXT);
  ------------------
  |  |   48|      2|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
              			       NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_CONTEXT);
  ------------------
  |  |  152|      2|#define NETSNMP_DS_LIB_CONTEXT           1
  ------------------
 1046|      2|    netsnmp_ds_register_config(ASN_OCTET_STR, "snmp", "defPassphrase",
  ------------------
  |  |   78|      2|#define ASN_OCTET_STR	    0x04U
  ------------------
 1047|      2|                               NETSNMP_DS_LIBRARY_ID,
  ------------------
  |  |   48|      2|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
 1048|      2|                               NETSNMP_DS_LIB_PASSPHRASE);
  ------------------
  |  |  153|      2|#define NETSNMP_DS_LIB_PASSPHRASE        2
  ------------------
 1049|      2|    netsnmp_ds_register_config(ASN_OCTET_STR, "snmp", "defAuthPassphrase",
  ------------------
  |  |   78|      2|#define ASN_OCTET_STR	    0x04U
  ------------------
 1050|      2|                               NETSNMP_DS_LIBRARY_ID,
  ------------------
  |  |   48|      2|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
 1051|      2|                               NETSNMP_DS_LIB_AUTHPASSPHRASE);
  ------------------
  |  |  154|      2|#define NETSNMP_DS_LIB_AUTHPASSPHRASE    3
  ------------------
 1052|      2|    netsnmp_ds_register_config(ASN_OCTET_STR, "snmp", "defPrivPassphrase",
  ------------------
  |  |   78|      2|#define ASN_OCTET_STR	    0x04U
  ------------------
 1053|      2|                               NETSNMP_DS_LIBRARY_ID,
  ------------------
  |  |   48|      2|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
 1054|      2|                               NETSNMP_DS_LIB_PRIVPASSPHRASE);
  ------------------
  |  |  155|      2|#define NETSNMP_DS_LIB_PRIVPASSPHRASE    4
  ------------------
 1055|      2|    netsnmp_ds_register_config(ASN_OCTET_STR, "snmp", "defAuthMasterKey",
  ------------------
  |  |   78|      2|#define ASN_OCTET_STR	    0x04U
  ------------------
 1056|      2|                               NETSNMP_DS_LIBRARY_ID,
  ------------------
  |  |   48|      2|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
 1057|      2|                               NETSNMP_DS_LIB_AUTHMASTERKEY);
  ------------------
  |  |  167|      2|#define NETSNMP_DS_LIB_AUTHMASTERKEY     16
  ------------------
 1058|      2|    netsnmp_ds_register_config(ASN_OCTET_STR, "snmp", "defPrivMasterKey",
  ------------------
  |  |   78|      2|#define ASN_OCTET_STR	    0x04U
  ------------------
 1059|      2|                               NETSNMP_DS_LIBRARY_ID,
  ------------------
  |  |   48|      2|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
 1060|      2|                               NETSNMP_DS_LIB_PRIVMASTERKEY);
  ------------------
  |  |  168|      2|#define NETSNMP_DS_LIB_PRIVMASTERKEY     17
  ------------------
 1061|      2|    netsnmp_ds_register_config(ASN_OCTET_STR, "snmp", "defAuthLocalizedKey",
  ------------------
  |  |   78|      2|#define ASN_OCTET_STR	    0x04U
  ------------------
 1062|      2|                               NETSNMP_DS_LIBRARY_ID,
  ------------------
  |  |   48|      2|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
 1063|      2|                               NETSNMP_DS_LIB_AUTHLOCALIZEDKEY);
  ------------------
  |  |  169|      2|#define NETSNMP_DS_LIB_AUTHLOCALIZEDKEY  18
  ------------------
 1064|      2|    netsnmp_ds_register_config(ASN_OCTET_STR, "snmp", "defPrivLocalizedKey",
  ------------------
  |  |   78|      2|#define ASN_OCTET_STR	    0x04U
  ------------------
 1065|      2|                               NETSNMP_DS_LIBRARY_ID,
  ------------------
  |  |   48|      2|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
 1066|      2|                               NETSNMP_DS_LIB_PRIVLOCALIZEDKEY);
  ------------------
  |  |  170|      2|#define NETSNMP_DS_LIB_PRIVLOCALIZEDKEY  19
  ------------------
 1067|      2|    register_config_handler("snmp", "defVersion", version_conf, NULL,
 1068|      2|                            "1|2c|3");
 1069|       |
 1070|      2|    register_config_handler("snmp", "defSecurityLevel",
 1071|       |                            snmpv3_secLevel_conf, NULL,
 1072|      2|                            "noAuthNoPriv|authNoPriv|authPriv");
 1073|      2|}
init_snmpv3_post_config:
 1083|      2|{
 1084|       |
 1085|      2|    size_t          engineIDLen;
 1086|      2|    u_char         *c_engineID;
 1087|      2|    u_long          localEngineTime;
 1088|      2|    u_long          localEngineBoots;
 1089|       |
 1090|      2|    c_engineID = snmpv3_generate_engineID(&engineIDLen);
 1091|       |
 1092|      2|    if (!c_engineID || engineIDLen == 0) {
  ------------------
  |  Branch (1092:9): [True: 0, False: 2]
  |  Branch (1092:24): [True: 0, False: 2]
  ------------------
 1093|       |        /*
 1094|       |         * Something went wrong - help! 
 1095|       |         */
 1096|      0|        SNMP_FREE(c_engineID);
  ------------------
  |  |   62|      0|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 0, False: 0]
  |  |  |  Branch (62:66): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1097|      0|        return SNMPERR_GENERR;
  ------------------
  |  |  185|      0|#define SNMPERR_GENERR			(-1)
  ------------------
 1098|      0|    }
 1099|       |
 1100|       |    /*
 1101|       |     * if our engineID has changed at all, the boots record must be set to 1 
 1102|       |     */
 1103|      2|    if (engineIDLen != oldEngineIDLength ||
  ------------------
  |  Branch (1103:9): [True: 2, False: 0]
  ------------------
 1104|      0|        oldEngineID == NULL || c_engineID == NULL ||
  ------------------
  |  Branch (1104:9): [True: 0, False: 0]
  |  Branch (1104:32): [True: 0, False: 0]
  ------------------
 1105|      2|        memcmp(oldEngineID, c_engineID, engineIDLen) != 0) {
  ------------------
  |  Branch (1105:9): [True: 0, False: 0]
  ------------------
 1106|      2|        engineBoots = 1;
 1107|      2|    }
 1108|       |
 1109|      2|#ifdef NETSNMP_SECMOD_USM
 1110|       |    /*
 1111|       |     * for USM set our local engineTime in the LCD timing cache 
 1112|       |     */
 1113|      2|    localEngineTime = snmpv3_local_snmpEngineTime();
 1114|      2|    localEngineBoots = snmpv3_local_snmpEngineBoots();
 1115|      2|    set_enginetime(c_engineID, engineIDLen,
 1116|      2|                   localEngineBoots,
 1117|      2|                   localEngineTime, TRUE);
  ------------------
  |  |  128|      2|#define TRUE  1
  ------------------
 1118|      2|#endif /* NETSNMP_SECMOD_USM */
 1119|       |
 1120|      2|    SNMP_FREE(c_engineID);
  ------------------
  |  |   62|      2|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 2, False: 0]
  |  |  |  Branch (62:66): [Folded, False: 2]
  |  |  ------------------
  ------------------
 1121|      2|    return SNMPERR_SUCCESS;
  ------------------
  |  |  184|      2|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
 1122|      2|}
init_snmpv3_post_premib_config:
 1127|      2|{
 1128|      2|    if (!engineIDIsSet)
  ------------------
  |  Branch (1128:9): [True: 2, False: 0]
  ------------------
 1129|      2|        setup_engineID(NULL, NULL);
 1130|       |
 1131|      2|    return SNMPERR_SUCCESS;
  ------------------
  |  |  184|      2|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
 1132|      2|}
snmpv3_local_snmpEngineBoots:
 1170|      2|{
 1171|      2|    return engineBoots;
 1172|      2|}
snmpv3_get_engineID:
 1192|     36|{
 1193|       |    /*
 1194|       |     * Sanity check.
 1195|       |     */
 1196|     36|    if (!buf || (buflen < engineIDLength)) {
  ------------------
  |  Branch (1196:9): [True: 0, False: 36]
  |  Branch (1196:17): [True: 0, False: 36]
  ------------------
 1197|      0|        return 0;
 1198|      0|    }
 1199|     36|    if (!engineID) {
  ------------------
  |  Branch (1199:9): [True: 0, False: 36]
  ------------------
 1200|      0|        return 0;
 1201|      0|    }
 1202|       |
 1203|     36|    memcpy(buf, engineID, engineIDLength);
 1204|     36|    return engineIDLength;
 1205|       |
 1206|     36|}                               /* end snmpv3_get_engineID() */
snmpv3_generate_engineID:
 1262|     10|{
 1263|     10|    u_char         *newID;
 1264|     10|    newID = (u_char *) malloc(engineIDLength);
 1265|       |
 1266|     10|    if (newID) {
  ------------------
  |  Branch (1266:9): [True: 10, False: 0]
  ------------------
 1267|     10|        *length = snmpv3_get_engineID(newID, engineIDLength);
 1268|     10|        if (*length == 0) {
  ------------------
  |  Branch (1268:13): [True: 0, False: 10]
  ------------------
 1269|      0|            SNMP_FREE(newID);
  ------------------
  |  |   62|      0|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 0, False: 0]
  |  |  |  Branch (62:66): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1270|      0|            newID = NULL;
 1271|      0|        }
 1272|     10|    }
 1273|     10|    return newID;
 1274|       |
 1275|     10|}                               /* end snmpv3_generate_engineID() */
snmpv3_local_snmpEngineTime:
 1289|    586|{
 1290|       |#ifdef NETSNMP_FEATURE_CHECKING
 1291|       |    netsnmp_feature_require(calculate_sectime_diff)
 1292|       |#endif /* NETSNMP_FEATURE_CHECKING */
 1293|       |
 1294|    586|    static uint32_t last_engineTime;
 1295|    586|    struct timeval  now;
 1296|    586|    uint32_t engineTime;
 1297|       |
 1298|    586|    netsnmp_get_monotonic_clock(&now);
 1299|    586|    engineTime = calculate_sectime_diff(&now, &snmpv3starttime) & 0x7fffffffL;
 1300|    586|    if (engineTime < last_engineTime)
  ------------------
  |  Branch (1300:9): [True: 0, False: 586]
  ------------------
 1301|      0|        engineBoots++;
 1302|    586|    last_engineTime = engineTime;
 1303|    586|    return engineTime;
 1304|    586|}

strlcpy:
   26|  10.2k|{ 
   27|  10.2k|	size_t src_len = strlen(src); 
   28|  10.2k|	size_t new_len; 
   29|       |
   30|  10.2k|	if (len == 0) {
  ------------------
  |  Branch (30:6): [True: 0, False: 10.2k]
  ------------------
   31|      0|		return (src_len);
   32|      0|	}
   33|       |
   34|  10.2k|        if (src_len >= len) {
  ------------------
  |  Branch (34:13): [True: 0, False: 10.2k]
  ------------------
   35|      0|		new_len = len - 1;
   36|  10.2k|	} else {
   37|  10.2k|                new_len = src_len;
   38|  10.2k|	}
   39|       |
   40|  10.2k|        memcpy(dest, src, new_len); 
   41|  10.2k|	dest[new_len] = '\0'; 
   42|  10.2k|	return (src_len); 
   43|  10.2k|}

calculate_sectime_diff:
 1210|    586|{
 1211|    586|    struct timeval  diff;
 1212|       |
 1213|    586|    NETSNMP_TIMERSUB(now, then, &diff);
  ------------------
  |  |  173|    586|#define NETSNMP_TIMERSUB(a, b, res) do {                        \
  |  |  174|    586|    (res)->tv_sec  = (a)->tv_sec  - (b)->tv_sec - 1;            \
  |  |  175|    586|    (res)->tv_usec = (a)->tv_usec - (b)->tv_usec + 1000000L;    \
  |  |  176|    586|    if ((res)->tv_usec >= 1000000L) {                           \
  |  |  ------------------
  |  |  |  Branch (176:9): [True: 586, False: 0]
  |  |  ------------------
  |  |  177|    586|        (res)->tv_usec -= 1000000L;                             \
  |  |  178|    586|        (res)->tv_sec++;                                        \
  |  |  179|    586|    }                                                           \
  |  |  180|    586|} while (0)
  |  |  ------------------
  |  |  |  Branch (180:10): [Folded, False: 586]
  |  |  ------------------
  ------------------
 1214|    586|    return (u_int)(diff.tv_sec + (diff.tv_usec >= 500000L));
 1215|    586|}

netsnmp_memdup:
  278|  5.81k|{
  279|  5.81k|    void *to = NULL;
  280|       |
  281|  5.81k|    if (from) {
  ------------------
  |  Branch (281:9): [True: 5.81k, False: 0]
  ------------------
  282|  5.81k|        to = malloc(size);
  283|  5.81k|        if (to)
  ------------------
  |  Branch (283:13): [True: 5.81k, False: 0]
  ------------------
  284|  5.81k|            memcpy(to, from, size);
  285|  5.81k|    }
  286|  5.81k|    return to;
  287|  5.81k|}                               /* end netsnmp_memdup() */
netsnmp_memdup_nt:
  306|  1.27k|{
  307|  1.27k|    char *to = NULL;
  308|       |
  309|  1.27k|    if (from) {
  ------------------
  |  Branch (309:9): [True: 1.27k, False: 0]
  ------------------
  310|  1.27k|        to = malloc(from_size+1);
  311|  1.27k|        if (to) {
  ------------------
  |  Branch (311:13): [True: 1.27k, False: 0]
  ------------------
  312|  1.27k|            memcpy(to, from, from_size);
  313|  1.27k|            to[from_size] = 0;
  314|  1.27k|            if (to_size)
  ------------------
  |  Branch (314:17): [True: 1.27k, False: 0]
  ------------------
  315|  1.27k|               *to_size = from_size;
  316|  1.27k|        }
  317|  1.27k|    }
  318|  1.27k|    return to;
  319|  1.27k|}                               /* end netsnmp_memdupNT() */
netsnmp_get_monotonic_clock:
  947|    590|{
  948|    590|#if defined(HAVE_CLOCK_GETTIME) && defined(CLOCK_MONOTONIC)
  949|    590|    struct timespec ts;
  950|    590|    int res;
  951|       |
  952|    590|    res = clock_gettime(CLOCK_MONOTONIC, &ts);
  953|    590|    if (res >= 0) {
  ------------------
  |  Branch (953:9): [True: 590, False: 0]
  ------------------
  954|    590|        tv->tv_sec = ts.tv_sec;
  955|    590|        tv->tv_usec = ts.tv_nsec / 1000;
  956|    590|    } else {
  957|      0|        gettimeofday(tv, NULL);
  958|      0|    }
  959|       |#elif defined(WIN32)
  960|       |    /*
  961|       |     * Windows: return tick count. Note: the rate at which the tick count
  962|       |     * increases is not adjusted by the time synchronization algorithm, so
  963|       |     * expect an error of <= 100 ppm for the rate at which this clock
  964|       |     * increases.
  965|       |     */
  966|       |    typedef ULONGLONG (WINAPI * pfGetTickCount64)(void);
  967|       |    static int s_initialized;
  968|       |    static pfGetTickCount64 s_pfGetTickCount64;
  969|       |    uint64_t now64;
  970|       |
  971|       |    if (!s_initialized) {
  972|       |        HMODULE hKernel32 = GetModuleHandle("kernel32");
  973|       |        s_pfGetTickCount64 =
  974|       |            (pfGetTickCount64) GetProcAddress(hKernel32, "GetTickCount64");
  975|       |        s_initialized = TRUE;
  976|       |    }
  977|       |
  978|       |    if (s_pfGetTickCount64) {
  979|       |        /* Windows Vista, Windows 2008 or any later Windows version */
  980|       |        now64 = (*s_pfGetTickCount64)();
  981|       |    } else {
  982|       |        /* Windows XP, Windows 2003 or any earlier Windows version */
  983|       |        static uint32_t s_wraps, s_last;
  984|       |        uint32_t now;
  985|       |
  986|       |        now = GetTickCount();
  987|       |        if (now < s_last)
  988|       |            s_wraps++;
  989|       |        s_last = now;
  990|       |        now64 = ((uint64_t)s_wraps << 32) | now;
  991|       |    }
  992|       |    tv->tv_sec = now64 / 1000;
  993|       |    tv->tv_usec = (now64 % 1000) * 1000;
  994|       |#else
  995|       |    /* At least FreeBSD 4 doesn't provide monotonic clock support. */
  996|       |#warning Not sure how to query a monotonically increasing clock on your system. \
  997|       |Timers will not work correctly if the system clock is adjusted by e.g. ntpd.
  998|       |    gettimeofday(tv, NULL);
  999|       |#endif
 1000|    590|}
netsnmp_getenv:
 1186|     14|{
 1187|     14|#if !defined (WIN32) && !defined (cygwin)
 1188|     14|  return (getenv(name));
 1189|       |#else
 1190|       |  char *temp = NULL;  
 1191|       |  HKEY hKey;
 1192|       |  unsigned char * key_value = NULL;
 1193|       |  DWORD key_value_size = 0;
 1194|       |  DWORD key_value_type = 0;
 1195|       |  DWORD getenv_worked = 0;
 1196|       |
 1197|       |  DEBUGMSGTL(("read_config", "netsnmp_getenv called with name: %s\n",name));
 1198|       |
 1199|       |  if (!(name))
 1200|       |    return NULL;
 1201|       |  
 1202|       |  /* Try environment variable first */ 
 1203|       |  temp = getenv(name);
 1204|       |  if (temp) {
 1205|       |    getenv_worked = 1;
 1206|       |    DEBUGMSGTL(("read_config", "netsnmp_getenv will return from ENV: %s\n",temp));
 1207|       |  }
 1208|       |  
 1209|       |  /* Next try HKCU */
 1210|       |  if (temp == NULL)
 1211|       |  {
 1212|       |    if (getenv("SNMP_IGNORE_WINDOWS_REGISTRY"))
 1213|       |      return NULL;
 1214|       |
 1215|       |    if (RegOpenKeyExA(
 1216|       |          HKEY_CURRENT_USER, 
 1217|       |          "SOFTWARE\\Net-SNMP", 
 1218|       |          0, 
 1219|       |          KEY_QUERY_VALUE, 
 1220|       |          &hKey) == ERROR_SUCCESS) {   
 1221|       |      
 1222|       |      if (RegQueryValueExA(
 1223|       |            hKey, 
 1224|       |            name, 
 1225|       |            NULL, 
 1226|       |            &key_value_type, 
 1227|       |            NULL,               /* Just get the size */
 1228|       |            &key_value_size) == ERROR_SUCCESS) {
 1229|       |
 1230|       |        SNMP_FREE(key_value);
 1231|       |
 1232|       |        /* Allocate memory needed +1 to allow RegQueryValueExA to NULL terminate the
 1233|       |         * string data in registry is missing one (which is unlikely).
 1234|       |         */
 1235|       |        key_value = malloc((sizeof(char) * key_value_size)+sizeof(char));
 1236|       |        
 1237|       |        if (RegQueryValueExA(
 1238|       |              hKey, 
 1239|       |              name, 
 1240|       |              NULL, 
 1241|       |              &key_value_type, 
 1242|       |              key_value, 
 1243|       |              &key_value_size) == ERROR_SUCCESS) {
 1244|       |        }
 1245|       |        temp = (char *) key_value;
 1246|       |      }
 1247|       |      RegCloseKey(hKey);
 1248|       |      if (temp)
 1249|       |        DEBUGMSGTL(("read_config", "netsnmp_getenv will return from HKCU: %s\n",temp));
 1250|       |    }
 1251|       |  }
 1252|       |
 1253|       |  /* Next try HKLM */
 1254|       |  if (temp == NULL)
 1255|       |  {
 1256|       |    if (RegOpenKeyExA(
 1257|       |          HKEY_LOCAL_MACHINE, 
 1258|       |          "SOFTWARE\\Net-SNMP", 
 1259|       |          0, 
 1260|       |          KEY_QUERY_VALUE, 
 1261|       |          &hKey) == ERROR_SUCCESS) {   
 1262|       |      
 1263|       |      if (RegQueryValueExA(
 1264|       |            hKey, 
 1265|       |            name, 
 1266|       |            NULL, 
 1267|       |            &key_value_type, 
 1268|       |            NULL,               /* Just get the size */
 1269|       |            &key_value_size) == ERROR_SUCCESS) {
 1270|       |
 1271|       |        SNMP_FREE(key_value);
 1272|       |
 1273|       |        /* Allocate memory needed +1 to allow RegQueryValueExA to NULL terminate the
 1274|       |         * string data in registry is missing one (which is unlikely).
 1275|       |         */
 1276|       |        key_value = malloc((sizeof(char) * key_value_size)+sizeof(char));
 1277|       |        
 1278|       |        if (RegQueryValueExA(
 1279|       |              hKey, 
 1280|       |              name, 
 1281|       |              NULL, 
 1282|       |              &key_value_type, 
 1283|       |              key_value, 
 1284|       |              &key_value_size) == ERROR_SUCCESS) {
 1285|       |        }
 1286|       |        temp = (char *) key_value;
 1287|       |
 1288|       |      }
 1289|       |      RegCloseKey(hKey);
 1290|       |      if (temp)
 1291|       |        DEBUGMSGTL(("read_config", "netsnmp_getenv will return from HKLM: %s\n",temp));
 1292|       |    }
 1293|       |  }
 1294|       |  
 1295|       |  if (temp && !getenv_worked) {
 1296|       |    setenv(name, temp, 1);
 1297|       |    SNMP_FREE(temp);
 1298|       |  }
 1299|       |
 1300|       |  DEBUGMSGTL(("read_config", "netsnmp_getenv returning: %s\n",getenv(name)));
 1301|       |
 1302|       |  return(getenv(name));
 1303|       |#endif
 1304|     14|}
netsnmp_gethomedir:
 1416|      4|const char *netsnmp_gethomedir(void) {
 1417|      4|    const char *homepath = netsnmp_getenv("HOME");
 1418|       |#ifdef _WIN32
 1419|       |    if (!homepath)
 1420|       |        homepath = netsnmp_getenv("USERPROFILE");
 1421|       |#endif
 1422|      4|    return homepath;
 1423|      4|}

netsnmp_aal5pvc_ctor:
  379|      2|{
  380|      2|    aal5pvcDomain.name = netsnmp_AAL5PVCDomain;
  381|      2|    aal5pvcDomain.name_length = OID_LENGTH(netsnmp_AAL5PVCDomain);
  ------------------
  |  |   64|      2|    (sizeof(x) / sizeof((x)[0]) +                                       \
  |  |   65|      2|     sizeof(int[-__builtin_types_compatible_p(typeof(x), typeof(&(x)[0]))]))
  ------------------
  382|      2|    aal5pvcDomain.prefix = calloc(3, sizeof(char *));
  383|      2|    if (!aal5pvcDomain.prefix) {
  ------------------
  |  Branch (383:9): [True: 0, False: 2]
  ------------------
  384|      0|        snmp_log(LOG_ERR, "calloc() failed - out of memory\n");
  385|      0|        return;
  386|      0|    }
  387|      2|    aal5pvcDomain.prefix[0] = "aal5pvc";
  388|      2|    aal5pvcDomain.prefix[1] = "pvc";
  389|       |
  390|      2|    aal5pvcDomain.f_create_from_tstring_new = netsnmp_aal5pvc_create_tstring;
  391|      2|    aal5pvcDomain.f_create_from_ostring     = netsnmp_aal5pvc_create_ostring;
  392|       |
  393|      2|    netsnmp_tdomain_register(&aal5pvcDomain);
  394|      2|}

free_alias_config:
   64|      2|free_alias_config(void) {
   65|      2|    netsnmp_free_all_list_data(alias_memory);
   66|       |    alias_memory = NULL;
   67|      2|}
netsnmp_alias_ctor:
  101|      2|{
  102|      2|    aliasDomain.name = netsnmp_snmpALIASDomain;
  103|      2|    aliasDomain.name_length = OID_LENGTH(netsnmp_snmpALIASDomain);
  ------------------
  |  |   64|      2|    (sizeof(x) / sizeof((x)[0]) +                                       \
  |  |   65|      2|     sizeof(int[-__builtin_types_compatible_p(typeof(x), typeof(&(x)[0]))]))
  ------------------
  104|      2|    aliasDomain.prefix = calloc(2, sizeof(char *));
  105|      2|    if (!aliasDomain.prefix) {
  ------------------
  |  Branch (105:9): [True: 0, False: 2]
  ------------------
  106|      0|        snmp_log(LOG_ERR, "calloc() failed - out of memory\n");
  107|      0|        return;
  108|      0|    }
  109|      2|    aliasDomain.prefix[0] = "alias";
  110|       |
  111|      2|    aliasDomain.f_create_from_tstring_new = netsnmp_alias_create_tstring;
  112|      2|    aliasDomain.f_create_from_ostring     = netsnmp_alias_create_ostring;
  113|       |
  114|      2|    netsnmp_tdomain_register(&aliasDomain);
  115|       |
  116|      2|    register_config_handler("snmp", "alias", parse_alias_config,
  117|      2|                            free_alias_config, "NAME TRANSPORT_DEFINITION");
  118|      2|}

netsnmp_dtlsudp_ctor:
 1733|      2|{
 1734|      2|    static const char indexname[] = "_netsnmp_addr_info";
 1735|      2|    static const char *prefixes[] = { "dtlsudp", "dtls"
 1736|      2|#ifdef NETSNMP_TRANSPORT_UDPIPV6_DOMAIN
 1737|      2|                                      , "dtlsudp6", "dtls6"
 1738|      2|#endif
 1739|      2|    };
 1740|      2|    int i, num_prefixes = sizeof(prefixes) / sizeof(char *);
 1741|      2|#ifdef NETSNMP_TRANSPORT_UDPIPV6_DOMAIN
 1742|      2|    static const char indexname6[] = "_netsnmp_addr_info6";
 1743|      2|#endif
 1744|       |
 1745|      2|    DEBUGMSGTL(("dtlsudp", "registering DTLS constructor\n"));
  ------------------
  |  |   66|      2|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      2|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 2]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 2]
  |  |  ------------------
  ------------------
 1746|       |
 1747|       |    /* config settings */
 1748|       |
 1749|      2|#ifdef NETSNMP_TRANSPORT_UDPIPV6_DOMAIN
 1750|      2|    if (!openssl_addr_index6)
  ------------------
  |  Branch (1750:9): [True: 2, False: 0]
  ------------------
 1751|      2|        openssl_addr_index6 =
 1752|      2|            SSL_get_ex_new_index(0, NETSNMP_REMOVE_CONST(void *, indexname6),
 1753|      2|                                 NULL, NULL, NULL);
 1754|      2|#endif
 1755|       |
 1756|      2|    dtlsudpDomain.name = netsnmpDTLSUDPDomain;
 1757|      2|    dtlsudpDomain.name_length = netsnmpDTLSUDPDomain_len;
 1758|      2|    dtlsudpDomain.prefix = calloc(num_prefixes + 1, sizeof(char *));
 1759|      2|    if (!dtlsudpDomain.prefix) {
  ------------------
  |  Branch (1759:9): [True: 0, False: 2]
  ------------------
 1760|      0|        snmp_log(LOG_ERR, "calloc() failed - out of memory\n");
 1761|      0|        return;
 1762|      0|    }
 1763|     10|    for (i = 0; i < num_prefixes; ++ i)
  ------------------
  |  Branch (1763:17): [True: 8, False: 2]
  ------------------
 1764|      8|        dtlsudpDomain.prefix[i] = prefixes[i];
 1765|       |
 1766|      2|    dtlsudpDomain.f_create_from_tstring_new = netsnmp_dtlsudp_create_tstring;
 1767|      2|    dtlsudpDomain.f_create_from_ostring     = netsnmp_dtlsudp_create_ostring;
 1768|       |
 1769|      2|    if (!openssl_addr_index)
  ------------------
  |  Branch (1769:9): [True: 2, False: 0]
  ------------------
 1770|      2|        openssl_addr_index =
 1771|      2|            SSL_get_ex_new_index(0, NETSNMP_REMOVE_CONST(void *, indexname),
 1772|      2|                                 NULL, NULL, NULL);
 1773|       |
 1774|      2|    netsnmp_tdomain_register(&dtlsudpDomain);
 1775|      2|}

netsnmp_ipx_ctor:
  486|      2|{
  487|      2|    ipxDomain.name = netsnmpIPXDomain;
  488|      2|    ipxDomain.name_length = netsnmpIPXDomain_len;
  489|      2|    ipxDomain.prefix = calloc(2, sizeof(char *));
  490|      2|    if (!ipxDomain.prefix) {
  ------------------
  |  Branch (490:9): [True: 0, False: 2]
  ------------------
  491|      0|        snmp_log(LOG_ERR, "calloc() failed - out of memory\n");
  492|      0|        return;
  493|      0|    }
  494|      2|    ipxDomain.prefix[0] = "ipx";
  495|       |
  496|      2|    ipxDomain.f_create_from_tstring_new = netsnmp_ipx_create_tstring;
  497|      2|    ipxDomain.f_create_from_ostring     = netsnmp_ipx_create_ostring;
  498|       |
  499|      2|    netsnmp_tdomain_register(&ipxDomain);
  500|      2|}

netsnmp_std_ctor:
  288|      2|{
  289|      2|    stdDomain.name = netsnmp_snmpSTDDomain;
  290|      2|    stdDomain.name_length = OID_LENGTH(netsnmp_snmpSTDDomain);
  ------------------
  |  |   64|      2|    (sizeof(x) / sizeof((x)[0]) +                                       \
  |  |   65|      2|     sizeof(int[-__builtin_types_compatible_p(typeof(x), typeof(&(x)[0]))]))
  ------------------
  291|      2|    stdDomain.prefix = calloc(2, sizeof(char *));
  292|      2|    if (!stdDomain.prefix) {
  ------------------
  |  Branch (292:9): [True: 0, False: 2]
  ------------------
  293|      0|        snmp_log(LOG_ERR, "calloc() failed - out of memory\n");
  294|      0|        return;
  295|      0|    }
  296|      2|    stdDomain.prefix[0] = "std";
  297|       |
  298|      2|    stdDomain.f_create_from_tstring_new = netsnmp_std_create_tstring;
  299|      2|    stdDomain.f_create_from_ostring     = netsnmp_std_create_ostring;
  300|       |
  301|      2|    netsnmp_tdomain_register(&stdDomain);
  302|      2|}

netsnmp_tcp_ctor:
  356|      2|{
  357|      2|    tcpDomain.name = netsnmp_snmpTCPDomain;
  358|      2|    tcpDomain.name_length = OID_LENGTH(netsnmp_snmpTCPDomain);
  ------------------
  |  |   64|      2|    (sizeof(x) / sizeof((x)[0]) +                                       \
  |  |   65|      2|     sizeof(int[-__builtin_types_compatible_p(typeof(x), typeof(&(x)[0]))]))
  ------------------
  359|      2|    tcpDomain.prefix = calloc(2, sizeof(char *));
  360|      2|    if (!tcpDomain.prefix) {
  ------------------
  |  Branch (360:9): [True: 0, False: 2]
  ------------------
  361|      0|        snmp_log(LOG_ERR, "calloc() failed - out of memory\n");
  362|      0|        return;
  363|      0|    }
  364|      2|    tcpDomain.prefix[0] = "tcp";
  365|       |
  366|      2|    tcpDomain.f_create_from_tstring_new = netsnmp_tcp_create_tstring;
  367|      2|    tcpDomain.f_create_from_ostring     = netsnmp_tcp_create_ostring;
  368|       |
  369|      2|    netsnmp_tdomain_register(&tcpDomain);
  370|      2|}

netsnmp_tcpipv6_ctor:
  387|      2|{
  388|      2|    tcp6Domain.name = netsnmp_TCPIPv6Domain;
  389|      2|    tcp6Domain.name_length = OID_LENGTH(netsnmp_TCPIPv6Domain);
  ------------------
  |  |   64|      2|    (sizeof(x) / sizeof((x)[0]) +                                       \
  |  |   65|      2|     sizeof(int[-__builtin_types_compatible_p(typeof(x), typeof(&(x)[0]))]))
  ------------------
  390|      2|    tcp6Domain.f_create_from_tstring_new = netsnmp_tcp6_create_tstring;
  391|      2|    tcp6Domain.f_create_from_ostring     = netsnmp_tcp6_create_ostring;
  392|      2|    tcp6Domain.prefix = calloc(4, sizeof(char *));
  393|      2|    if (!tcp6Domain.prefix) {
  ------------------
  |  Branch (393:9): [True: 0, False: 2]
  ------------------
  394|      0|        snmp_log(LOG_ERR, "calloc() failed - out of memory\n");
  395|      0|        return;
  396|      0|    }
  397|      2|    tcp6Domain.prefix[0] = "tcp6";
  398|      2|    tcp6Domain.prefix[1] = "tcpv6";
  399|      2|    tcp6Domain.prefix[2] = "tcpipv6";
  400|       |
  401|      2|    netsnmp_tdomain_register(&tcp6Domain);
  402|      2|}

netsnmp_tlsbase_ctor:
 1001|      2|netsnmp_tlsbase_ctor(void) {
 1002|       |
 1003|       |    /* bootstrap ssl since we'll need it */
 1004|      2|    netsnmp_init_openssl();
 1005|       |
 1006|       |    /* the private client cert to authenticate with */
 1007|      2|    netsnmp_ds_register_config(ASN_OCTET_STR, "snmp", "extraX509SubDir",
  ------------------
  |  |   78|      2|#define ASN_OCTET_STR	    0x04U
  ------------------
 1008|      2|                               NETSNMP_DS_LIBRARY_ID,
  ------------------
  |  |   48|      2|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
 1009|      2|                               NETSNMP_DS_LIB_CERT_EXTRA_SUBDIR);
  ------------------
  |  |  177|      2|#define NETSNMP_DS_LIB_CERT_EXTRA_SUBDIR 26
  ------------------
 1010|       |
 1011|       |    /* Do we have a CRL list? */
 1012|      2|    netsnmp_ds_register_config(ASN_OCTET_STR, "snmp", "x509CRLFile",
  ------------------
  |  |   78|      2|#define ASN_OCTET_STR	    0x04U
  ------------------
 1013|      2|                               NETSNMP_DS_LIBRARY_ID,
  ------------------
  |  |   48|      2|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
 1014|      2|                               NETSNMP_DS_LIB_X509_CRL_FILE);
  ------------------
  |  |  179|      2|#define NETSNMP_DS_LIB_X509_CRL_FILE     28
  ------------------
 1015|       |
 1016|       |    /* What TLS algorithms should be use */
 1017|      2|    netsnmp_ds_register_config(ASN_OCTET_STR, "snmp", "tlsAlgorithms",
  ------------------
  |  |   78|      2|#define ASN_OCTET_STR	    0x04U
  ------------------
 1018|      2|                               NETSNMP_DS_LIBRARY_ID,
  ------------------
  |  |   48|      2|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
 1019|      2|                               NETSNMP_DS_LIB_TLS_ALGORITMS);
  ------------------
  |  |  180|      2|#define NETSNMP_DS_LIB_TLS_ALGORITMS     29
  ------------------
 1020|       |
 1021|       |    /* What TLS version should be used at least */
 1022|      2|    netsnmp_ds_register_config(ASN_OCTET_STR, "snmp", "tlsMinVersion",
  ------------------
  |  |   78|      2|#define ASN_OCTET_STR	    0x04U
  ------------------
 1023|      2|                               NETSNMP_DS_LIBRARY_ID,
  ------------------
  |  |   48|      2|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
 1024|      2|                               NETSNMP_DS_LIB_TLS_MIN_VERSION);
  ------------------
  |  |  187|      2|#define NETSNMP_DS_LIB_TLS_MIN_VERSION   36
  ------------------
 1025|       |
 1026|       |    /* What TLS version should be used at max */
 1027|      2|    netsnmp_ds_register_config(ASN_OCTET_STR, "snmp", "tlsMaxVersion",
  ------------------
  |  |   78|      2|#define ASN_OCTET_STR	    0x04U
  ------------------
 1028|      2|                               NETSNMP_DS_LIBRARY_ID,
  ------------------
  |  |   48|      2|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
 1029|      2|                               NETSNMP_DS_LIB_TLS_MAX_VERSION);
  ------------------
  |  |  188|      2|#define NETSNMP_DS_LIB_TLS_MAX_VERSION   37
  ------------------
 1030|       |
 1031|       |    /*
 1032|       |     * for the client
 1033|       |     */
 1034|       |
 1035|       |    /* the public client cert to authenticate with */
 1036|      2|    register_config_handler("snmp", "clientCert", _parse_client_cert, NULL,
 1037|      2|                            NULL);
 1038|       |
 1039|       |    /*
 1040|       |     * for the server
 1041|       |     */
 1042|       |
 1043|       |    /* The X509 server key to use */
 1044|      2|    register_config_handler("snmp", "serverCert", _parse_server_cert, NULL,
 1045|      2|                            NULL);
 1046|       |    /*
 1047|       |     * remove cert config ambiguity: localCert, peerCert
 1048|       |     */
 1049|      2|    netsnmp_ds_register_config(ASN_OCTET_STR, "snmp", "localCert",
  ------------------
  |  |   78|      2|#define ASN_OCTET_STR	    0x04U
  ------------------
 1050|      2|                               NETSNMP_DS_LIBRARY_ID,
  ------------------
  |  |   48|      2|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
 1051|      2|                               NETSNMP_DS_LIB_TLS_LOCAL_CERT);
  ------------------
  |  |  181|      2|#define NETSNMP_DS_LIB_TLS_LOCAL_CERT    30
  ------------------
 1052|      2|    netsnmp_ds_register_config(ASN_OCTET_STR, "snmp", "peerCert",
  ------------------
  |  |   78|      2|#define ASN_OCTET_STR	    0x04U
  ------------------
 1053|      2|                               NETSNMP_DS_LIBRARY_ID,
  ------------------
  |  |   48|      2|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
 1054|      2|                               NETSNMP_DS_LIB_TLS_PEER_CERT);
  ------------------
  |  |  182|      2|#define NETSNMP_DS_LIB_TLS_PEER_CERT     31
  ------------------
 1055|       |
 1056|       |    /*
 1057|       |     * register our boot-strapping needs
 1058|       |     */
 1059|      2|    snmp_register_callback(SNMP_CALLBACK_LIBRARY,
  ------------------
  |  |   18|      2|#define SNMP_CALLBACK_LIBRARY     0
  ------------------
 1060|      2|			   SNMP_CALLBACK_POST_PREMIB_READ_CONFIG,
  ------------------
  |  |   27|      2|#define SNMP_CALLBACK_POST_PREMIB_READ_CONFIG	3
  ------------------
 1061|      2|			   tls_bootstrap, NULL);
 1062|       |
 1063|      2|}
snmpTLSBaseDomain.c:tls_bootstrap:
  953|      2|tls_bootstrap(int majorid, int minorid, void *serverarg, void *clientarg) {
  954|      2|    char indexname[] = "_netsnmp_verify_info";
  955|       |
  956|       |    /* don't do this more than once */
  957|      2|    if (have_done_bootstrap)
  ------------------
  |  Branch (957:9): [True: 0, False: 2]
  ------------------
  958|      0|        return 0;
  959|      2|    have_done_bootstrap = 1;
  960|       |
  961|      2|    netsnmp_certs_load();
  962|       |
  963|      2|    openssl_local_index =
  964|      2|        SSL_get_ex_new_index(0, indexname, NULL, NULL, verify_info_free);
  965|       |
  966|      2|    return 0;
  967|      2|}

netsnmp_tlstcp_ctor:
 1216|      2|{
 1217|      2|    DEBUGMSGTL(("tlstcp", "registering TLS constructor\n"));
  ------------------
  |  |   66|      2|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      2|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 2]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 2]
  |  |  ------------------
  ------------------
 1218|       |
 1219|       |    /* config settings */
 1220|       |
 1221|      2|    tlstcpDomain.name = netsnmpTLSTCPDomain;
 1222|      2|    tlstcpDomain.name_length = netsnmpTLSTCPDomain_len;
 1223|      2|    tlstcpDomain.prefix = calloc(3, sizeof(char *));
 1224|      2|    if (!tlstcpDomain.prefix) {
  ------------------
  |  Branch (1224:9): [True: 0, False: 2]
  ------------------
 1225|      0|        snmp_log(LOG_ERR, "calloc() failed - out of memory\n");
 1226|      0|        return;
 1227|      0|    }
 1228|      2|    tlstcpDomain.prefix[0] = "tlstcp";
 1229|      2|    tlstcpDomain.prefix[1] = "tls";
 1230|       |
 1231|      2|    tlstcpDomain.f_create_from_tstring_new = netsnmp_tlstcp_create_tstring;
 1232|      2|    tlstcpDomain.f_create_from_ostring     = netsnmp_tlstcp_create_ostring;
 1233|       |
 1234|      2|    netsnmp_tdomain_register(&tlstcpDomain);
 1235|      2|}

netsnmp_udp_ctor:
  724|      2|{
  725|      2|    udpDomain.name = netsnmpUDPDomain;
  726|      2|    udpDomain.name_length = netsnmpUDPDomain_len;
  727|      2|    udpDomain.prefix = calloc(2, sizeof(char *));
  728|      2|    if (!udpDomain.prefix) {
  ------------------
  |  Branch (728:9): [True: 0, False: 2]
  ------------------
  729|      0|        snmp_log(LOG_ERR, "calloc() failed - out of memory\n");
  730|      0|        return;
  731|      0|    }
  732|      2|    udpDomain.prefix[0] = "udp";
  733|       |
  734|      2|    udpDomain.f_create_from_tstring_new = netsnmp_udp_create_tstring;
  735|      2|    udpDomain.f_create_from_tspec       = netsnmp_udp_create_tspec;
  736|      2|    udpDomain.f_create_from_ostring     = netsnmp_udp_create_ostring;
  737|       |
  738|      2|    netsnmp_tdomain_register(&udpDomain);
  739|      2|}

netsnmp_udpipv6_ctor:
 1248|      2|{
 1249|      2|    udp6Domain.name = netsnmp_UDPIPv6Domain;
 1250|      2|    udp6Domain.name_length = OID_LENGTH(netsnmp_UDPIPv6Domain);
  ------------------
  |  |   64|      2|    (sizeof(x) / sizeof((x)[0]) +                                       \
  |  |   65|      2|     sizeof(int[-__builtin_types_compatible_p(typeof(x), typeof(&(x)[0]))]))
  ------------------
 1251|      2|    udp6Domain.f_create_from_tstring_new = netsnmp_udp6_create_tstring;
 1252|      2|    udp6Domain.f_create_from_tspec       = netsnmp_udp6_create_tspec;
 1253|      2|    udp6Domain.f_create_from_ostring     = netsnmp_udp6_create_ostring;
 1254|      2|    udp6Domain.prefix = calloc(5, sizeof(char *));
 1255|      2|    if (!udp6Domain.prefix) {
  ------------------
  |  Branch (1255:9): [True: 0, False: 2]
  ------------------
 1256|      0|        snmp_log(LOG_ERR, "calloc() failed - out of memory\n");
 1257|      0|        return;
 1258|      0|    }
 1259|      2|    udp6Domain.prefix[0] = "udp6";
 1260|      2|    udp6Domain.prefix[1] = "ipv6";
 1261|      2|    udp6Domain.prefix[2] = "udpv6";
 1262|      2|    udp6Domain.prefix[3] = "udpipv6";
 1263|       |
 1264|      2|    netsnmp_tdomain_register(&udp6Domain);
 1265|      2|}

netsnmp_udpshared_ctor:
  454|      2|{
  455|      2|    static netsnmp_tdomain domain;
  456|      2|    static int done = 0;
  457|       |
  458|      2|    if (done)
  ------------------
  |  Branch (458:9): [True: 0, False: 2]
  ------------------
  459|      0|        return;
  460|      2|    done = 1;
  461|       |
  462|      2|    domain.name = netsnmpUDPsharedDomain;
  463|      2|    domain.name_length = netsnmpUDPsharedDomain_len;
  464|       |
  465|      2|    domain.prefix = calloc(2, sizeof(char *));
  466|      2|    if (!domain.prefix) {
  ------------------
  |  Branch (466:9): [True: 0, False: 2]
  ------------------
  467|      0|        snmp_log(LOG_ERR, "calloc() failed - out of memory\n");
  468|      0|        return;
  469|      0|    }
  470|      2|    domain.prefix[0] = "udpshared";
  471|       |
  472|      2|    domain.f_create_from_tstring_new = netsnmp_udpshared_create_tstring;
  473|      2|    domain.f_create_from_tspec       = netsnmp_udpshared_create_tspec;
  474|      2|    domain.f_create_from_ostring     = netsnmp_udpshared_create_ostring;
  475|       |
  476|      2|    netsnmp_tdomain_register(&domain);
  477|      2|}

netsnmp_unix_ctor:
  536|      2|{
  537|      2|    unixDomain.name = netsnmp_UnixDomain;
  538|      2|    unixDomain.name_length = OID_LENGTH(netsnmp_UnixDomain);
  ------------------
  |  |   64|      2|    (sizeof(x) / sizeof((x)[0]) +                                       \
  |  |   65|      2|     sizeof(int[-__builtin_types_compatible_p(typeof(x), typeof(&(x)[0]))]))
  ------------------
  539|      2|    unixDomain.prefix = calloc(2, sizeof(char *));
  540|      2|    if (!unixDomain.prefix) {
  ------------------
  |  Branch (540:9): [True: 0, False: 2]
  ------------------
  541|      0|        snmp_log(LOG_ERR, "calloc() failed - out of memory\n");
  542|      0|        return;
  543|      0|    }
  544|      2|    unixDomain.prefix[0] = "unix";
  545|       |
  546|      2|    unixDomain.f_create_from_tstring_new = netsnmp_unix_create_tstring;
  547|      2|    unixDomain.f_create_from_ostring     = netsnmp_unix_create_ostring;
  548|       |
  549|      2|    netsnmp_tdomain_register(&unixDomain);
  550|      2|}

init_vacm:
   85|      2|{
   86|       |    /* views for access via get/set/send-notifications */
   87|      2|    se_add_pair_to_slist(VACM_VIEW_ENUM_NAME, strdup("read"),
  ------------------
  |  |  103|      2|#define VACM_VIEW_ENUM_NAME "vacmviews"
  ------------------
   88|      2|                         VACM_VIEW_READ);
  ------------------
  |  |   77|      2|#define VACM_VIEW_READ     0
  ------------------
   89|      2|    se_add_pair_to_slist(VACM_VIEW_ENUM_NAME, strdup("write"),
  ------------------
  |  |  103|      2|#define VACM_VIEW_ENUM_NAME "vacmviews"
  ------------------
   90|      2|                         VACM_VIEW_WRITE);
  ------------------
  |  |   78|      2|#define VACM_VIEW_WRITE    1
  ------------------
   91|      2|    se_add_pair_to_slist(VACM_VIEW_ENUM_NAME, strdup("notify"),
  ------------------
  |  |  103|      2|#define VACM_VIEW_ENUM_NAME "vacmviews"
  ------------------
   92|      2|                         VACM_VIEW_NOTIFY);
  ------------------
  |  |   79|      2|#define VACM_VIEW_NOTIFY   2
  ------------------
   93|       |
   94|       |    /* views for permissions when receiving notifications */
   95|      2|    se_add_pair_to_slist(VACM_VIEW_ENUM_NAME, strdup("log"),
  ------------------
  |  |  103|      2|#define VACM_VIEW_ENUM_NAME "vacmviews"
  ------------------
   96|      2|                         VACM_VIEW_LOG);
  ------------------
  |  |   82|      2|#define VACM_VIEW_LOG      3
  ------------------
   97|      2|    se_add_pair_to_slist(VACM_VIEW_ENUM_NAME, strdup("execute"),
  ------------------
  |  |  103|      2|#define VACM_VIEW_ENUM_NAME "vacmviews"
  ------------------
   98|      2|                         VACM_VIEW_EXECUTE);
  ------------------
  |  |   83|      2|#define VACM_VIEW_EXECUTE  4
  ------------------
   99|      2|    se_add_pair_to_slist(VACM_VIEW_ENUM_NAME, strdup("net"),
  ------------------
  |  |  103|      2|#define VACM_VIEW_ENUM_NAME "vacmviews"
  ------------------
  100|      2|                         VACM_VIEW_NET);
  ------------------
  |  |   84|      2|#define VACM_VIEW_NET      5
  ------------------
  101|      2|}
netsnmp_view_get:
  473|  1.53k|{
  474|  1.53k|    struct vacm_viewEntry *vp, *vpret = NULL;
  475|  1.53k|    char            view[VACMSTRINGLEN];
  476|  1.53k|    int             found, glen;
  477|  1.53k|    int count=0;
  478|       |
  479|  1.53k|    glen = (int) strlen(viewName);
  480|  1.53k|    if (glen < 0 || glen > VACM_MAX_STRING)
  ------------------
  |  |   56|  1.53k|#define VACM_MAX_STRING 32
  ------------------
  |  Branch (480:9): [True: 0, False: 1.53k]
  |  Branch (480:21): [True: 0, False: 1.53k]
  ------------------
  481|      0|        return NULL;
  482|  1.53k|    view[0] = glen;
  483|  1.53k|    strlcpy(view + 1, viewName, sizeof(view) - 1);
  484|  3.07k|    for (vp = head; vp; vp = vp->next) {
  ------------------
  |  Branch (484:21): [True: 1.53k, False: 1.53k]
  ------------------
  485|  1.53k|        if (vp->viewSubtreeLen > 0
  ------------------
  |  Branch (485:13): [True: 1.53k, False: 0]
  ------------------
  486|  1.53k|            && !memcmp(view, vp->viewName, glen + 1)
  ------------------
  |  Branch (486:16): [True: 1.53k, False: 0]
  ------------------
  487|  1.53k|            && viewSubtreeLen >= (vp->viewSubtreeLen - 1)) {
  ------------------
  |  Branch (487:16): [True: 528, False: 1.01k]
  ------------------
  488|    528|            int             mask = 0x80;
  489|    528|            unsigned int    oidpos, maskpos = 0;
  490|    528|            found = 1;
  491|       |
  492|    528|            for (oidpos = 0;
  493|  2.02k|                 found && oidpos < vp->viewSubtreeLen - 1;
  ------------------
  |  Branch (493:18): [True: 1.54k, False: 474]
  |  Branch (493:27): [True: 1.49k, False: 54]
  ------------------
  494|  1.49k|                 oidpos++) {
  495|  1.49k|                if (mode==VACM_MODE_IGNORE_MASK || (VIEW_MASK(vp, maskpos, mask) != 0)) {
  ------------------
  |  |  144|  2.98k|#define VACM_MODE_IGNORE_MASK         1
  ------------------
                              if (mode==VACM_MODE_IGNORE_MASK || (VIEW_MASK(vp, maskpos, mask) != 0)) {
  ------------------
  |  |   76|    996|    ((idx >= viewPtr->viewMaskLen) ? mask : (viewPtr->viewMask[idx] & mask))
  |  |  ------------------
  |  |  |  Branch (76:6): [True: 0, False: 996]
  |  |  ------------------
  ------------------
  |  Branch (495:21): [True: 498, False: 996]
  |  Branch (495:52): [True: 996, False: 0]
  ------------------
  496|  1.49k|                    if (viewSubtree[oidpos] !=
  ------------------
  |  Branch (496:25): [True: 474, False: 1.02k]
  ------------------
  497|  1.49k|                        vp->viewSubtree[oidpos + 1])
  498|    474|                        found = 0;
  499|  1.49k|                }
  500|  1.49k|                if (mask == 1) {
  ------------------
  |  Branch (500:21): [True: 0, False: 1.49k]
  ------------------
  501|      0|                    mask = 0x80;
  502|      0|                    maskpos++;
  503|      0|                } else
  504|  1.49k|                    mask >>= 1;
  505|  1.49k|            }
  506|       |
  507|    528|            if (found) {
  ------------------
  |  Branch (507:17): [True: 54, False: 474]
  ------------------
  508|       |                /*
  509|       |                 * match successful, keep this node if its longer than
  510|       |                 * the previous or (equal and lexicographically greater
  511|       |                 * than the previous). 
  512|       |                 */
  513|     54|                count++;
  514|     54|                if (mode == VACM_MODE_CHECK_SUBTREE) {
  ------------------
  |  |  145|     54|#define VACM_MODE_CHECK_SUBTREE       2
  ------------------
  |  Branch (514:21): [True: 18, False: 36]
  ------------------
  515|     18|                    vpret = vp;
  516|     36|                } else if (vpret == NULL
  ------------------
  |  Branch (516:28): [True: 36, False: 0]
  ------------------
  517|      0|                           || vp->viewSubtreeLen > vpret->viewSubtreeLen
  ------------------
  |  Branch (517:31): [True: 0, False: 0]
  ------------------
  518|      0|                           || (vp->viewSubtreeLen == vpret->viewSubtreeLen
  ------------------
  |  Branch (518:32): [True: 0, False: 0]
  ------------------
  519|      0|                               && snmp_oid_compare(vp->viewSubtree + 1,
  ------------------
  |  Branch (519:35): [True: 0, False: 0]
  ------------------
  520|      0|                                                   vp->viewSubtreeLen - 1,
  521|      0|                                                   vpret->viewSubtree + 1,
  522|      0|                                                   vpret->viewSubtreeLen - 1) >
  523|     36|                               0)) {
  524|     36|                    vpret = vp;
  525|     36|                }
  526|     54|            }
  527|    528|        }
  528|  1.53k|    }
  529|  1.53k|    DEBUGMSGTL(("vacm:getView", ", %s\n", (vpret) ? "found" : "none"));
  ------------------
  |  |   66|  1.53k|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|  1.53k|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 1.53k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (164:52): [True: 0, False: 0]
  |  |  |  |  |  Branch (164:64): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 1.53k]
  |  |  ------------------
  ------------------
  530|  1.53k|    if (mode == VACM_MODE_CHECK_SUBTREE && count > 1) {
  ------------------
  |  |  145|  3.07k|#define VACM_MODE_CHECK_SUBTREE       2
  ------------------
  |  Branch (530:9): [True: 513, False: 1.02k]
  |  Branch (530:44): [True: 0, False: 513]
  ------------------
  531|      0|        return NULL;
  532|      0|    }
  533|  1.53k|    return vpret;
  534|  1.53k|}
netsnmp_view_subtree_check:
  590|    513|{
  591|    513|    struct vacm_viewEntry *vp, *vpShorter = NULL, *vpLonger = NULL;
  592|    513|    char            view[VACMSTRINGLEN];
  593|    513|    int             found, glen;
  594|       |
  595|    513|    glen = (int) strlen(viewName);
  596|    513|    if (glen < 0 || glen > VACM_MAX_STRING)
  ------------------
  |  |   56|    513|#define VACM_MAX_STRING 32
  ------------------
  |  Branch (596:9): [True: 0, False: 513]
  |  Branch (596:21): [True: 0, False: 513]
  ------------------
  597|      0|        return VACM_NOTINVIEW;
  ------------------
  |  |   28|      0|#define VACM_NOTINVIEW     5
  ------------------
  598|    513|    view[0] = glen;
  599|    513|    strlcpy(view + 1, viewName, sizeof(view) - 1);
  600|    513|    DEBUGMSGTL(("9:vacm:checkSubtree", "view %s\n", viewName));
  ------------------
  |  |   66|    513|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|    513|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 513]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 513]
  |  |  ------------------
  ------------------
  601|  1.02k|    for (vp = head; vp; vp = vp->next) {
  ------------------
  |  Branch (601:21): [True: 513, False: 513]
  ------------------
  602|    513|        if (vp->viewSubtreeLen > 0 && !memcmp(view, vp->viewName, glen + 1)) {
  ------------------
  |  Branch (602:13): [True: 513, False: 0]
  |  Branch (602:39): [True: 513, False: 0]
  ------------------
  603|       |            /*
  604|       |             * If the subtree defined in the view is shorter than or equal
  605|       |             * to the subtree we are comparing, then it might envelop the
  606|       |             * subtree we are comparing against.
  607|       |             */
  608|    513|            if (viewSubtreeLen >= (vp->viewSubtreeLen - 1)) {
  ------------------
  |  Branch (608:17): [True: 176, False: 337]
  ------------------
  609|    176|                int             mask = 0x80;
  610|    176|                unsigned int    oidpos, maskpos = 0;
  611|    176|                found = 1;
  612|       |
  613|       |                /*
  614|       |                 * check the mask
  615|       |                 */
  616|    176|                for (oidpos = 0;
  617|    674|                     found && oidpos < vp->viewSubtreeLen - 1;
  ------------------
  |  Branch (617:22): [True: 516, False: 158]
  |  Branch (617:31): [True: 498, False: 18]
  ------------------
  618|    498|                     oidpos++) {
  619|    498|                    if (VIEW_MASK(vp, maskpos, mask) != 0) {
  ------------------
  |  |   76|    498|    ((idx >= viewPtr->viewMaskLen) ? mask : (viewPtr->viewMask[idx] & mask))
  |  |  ------------------
  |  |  |  Branch (76:6): [True: 0, False: 498]
  |  |  ------------------
  ------------------
  |  Branch (619:25): [True: 498, False: 0]
  ------------------
  620|    498|                        if (viewSubtree[oidpos] !=
  ------------------
  |  Branch (620:29): [True: 158, False: 340]
  ------------------
  621|    498|                            vp->viewSubtree[oidpos + 1])
  622|    158|                            found = 0;
  623|    498|                    }
  624|    498|                    if (mask == 1) {
  ------------------
  |  Branch (624:25): [True: 0, False: 498]
  ------------------
  625|      0|                        mask = 0x80;
  626|      0|                        maskpos++;
  627|      0|                    } else
  628|    498|                        mask >>= 1;
  629|    498|                }
  630|       |
  631|    176|                if (found) {
  ------------------
  |  Branch (631:21): [True: 18, False: 158]
  ------------------
  632|       |                    /*
  633|       |                     * match successful, keep this node if it's longer than
  634|       |                     * the previous or (equal and lexicographically greater
  635|       |                     * than the previous). 
  636|       |                     */
  637|     18|                    DEBUGMSGTL(("9:vacm:checkSubtree", " %s matched?\n", vp->viewName));
  ------------------
  |  |   66|     18|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     18|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 18]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 18]
  |  |  ------------------
  ------------------
  638|       |    
  639|     18|                    if (vpShorter == NULL
  ------------------
  |  Branch (639:25): [True: 18, False: 0]
  ------------------
  640|      0|                        || vp->viewSubtreeLen > vpShorter->viewSubtreeLen
  ------------------
  |  Branch (640:28): [True: 0, False: 0]
  ------------------
  641|      0|                        || (vp->viewSubtreeLen == vpShorter->viewSubtreeLen
  ------------------
  |  Branch (641:29): [True: 0, False: 0]
  ------------------
  642|      0|                           && snmp_oid_compare(vp->viewSubtree + 1,
  ------------------
  |  Branch (642:31): [True: 0, False: 0]
  ------------------
  643|      0|                                               vp->viewSubtreeLen - 1,
  644|      0|                                               vpShorter->viewSubtree + 1,
  645|      0|                                               vpShorter->viewSubtreeLen - 1) >
  646|     18|                                   0)) {
  647|     18|                        vpShorter = vp;
  648|     18|                    }
  649|     18|                }
  650|    176|            }
  651|       |            /*
  652|       |             * If the subtree defined in the view is longer than the
  653|       |             * subtree we are comparing, then it might ambiguate our
  654|       |             * response.
  655|       |             */
  656|    337|            else {
  657|    337|                int             mask = 0x80;
  658|    337|                unsigned int    oidpos, maskpos = 0;
  659|    337|                found = 1;
  660|       |
  661|       |                /*
  662|       |                 * check the mask up to the length of the provided subtree
  663|       |                 */
  664|    337|                for (oidpos = 0;
  665|    812|                     found && oidpos < viewSubtreeLen;
  ------------------
  |  Branch (665:22): [True: 489, False: 323]
  |  Branch (665:31): [True: 475, False: 14]
  ------------------
  666|    475|                     oidpos++) {
  667|    475|                    if (VIEW_MASK(vp, maskpos, mask) != 0) {
  ------------------
  |  |   76|    475|    ((idx >= viewPtr->viewMaskLen) ? mask : (viewPtr->viewMask[idx] & mask))
  |  |  ------------------
  |  |  |  Branch (76:6): [True: 0, False: 475]
  |  |  ------------------
  ------------------
  |  Branch (667:25): [True: 475, False: 0]
  ------------------
  668|    475|                        if (viewSubtree[oidpos] !=
  ------------------
  |  Branch (668:29): [True: 323, False: 152]
  ------------------
  669|    475|                            vp->viewSubtree[oidpos + 1])
  670|    323|                            found = 0;
  671|    475|                    }
  672|    475|                    if (mask == 1) {
  ------------------
  |  Branch (672:25): [True: 0, False: 475]
  ------------------
  673|      0|                        mask = 0x80;
  674|      0|                        maskpos++;
  675|      0|                    } else
  676|    475|                        mask >>= 1;
  677|    475|                }
  678|       |
  679|    337|                if (found) {
  ------------------
  |  Branch (679:21): [True: 14, False: 323]
  ------------------
  680|       |                    /*
  681|       |                     * match successful.  If we already found a match
  682|       |                     * with a different view type, then parts of the subtree 
  683|       |                     * are included and others are excluded, so return UNKNOWN.
  684|       |                     */
  685|     14|                    DEBUGMSGTL(("9:vacm:checkSubtree", " %s matched?\n", vp->viewName));
  ------------------
  |  |   66|     14|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     14|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 14]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 14]
  |  |  ------------------
  ------------------
  686|     14|                    if (vpLonger != NULL
  ------------------
  |  Branch (686:25): [True: 0, False: 14]
  ------------------
  687|      0|                        && (vpLonger->viewType != vp->viewType)) {
  ------------------
  |  Branch (687:28): [True: 0, False: 0]
  ------------------
  688|      0|                        DEBUGMSGTL(("vacm:checkSubtree", ", %s\n", "unknown"));
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
  689|      0|                        return VACM_SUBTREE_UNKNOWN;
  ------------------
  |  |   30|      0|#define VACM_SUBTREE_UNKNOWN 7
  ------------------
  690|      0|                    }
  691|     14|                    else if (vpLonger == NULL) {
  ------------------
  |  Branch (691:30): [True: 14, False: 0]
  ------------------
  692|     14|                        vpLonger = vp;
  693|     14|                    }
  694|     14|                }
  695|    337|            }
  696|    513|        }
  697|    513|    }
  698|    513|    DEBUGMSGTL(("9:vacm:checkSubtree", " %s matched\n", viewName));
  ------------------
  |  |   66|    513|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|    513|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 513]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 513]
  |  |  ------------------
  ------------------
  699|       |
  700|       |    /*
  701|       |     * If we found a matching view subtree with a longer OID than the provided
  702|       |     * OID, check to see if its type is consistent with any matching view
  703|       |     * subtree we may have found with a shorter OID than the provided OID.
  704|       |     *
  705|       |     * The view type of the longer OID is inconsistent with the shorter OID in
  706|       |     * either of these two cases:
  707|       |     *  1) No matching shorter OID was found and the view type of the longer
  708|       |     *     OID is INCLUDE.
  709|       |     *  2) A matching shorter ID was found and its view type doesn't match
  710|       |     *     the view type of the longer OID.
  711|       |     */
  712|    513|    if (vpLonger != NULL) {
  ------------------
  |  Branch (712:9): [True: 14, False: 499]
  ------------------
  713|     14|        if ((!vpShorter && vpLonger->viewType != SNMP_VIEW_EXCLUDED)
  ------------------
  |  |  327|     14|#define SNMP_VIEW_EXCLUDED		2
  ------------------
  |  Branch (713:14): [True: 14, False: 0]
  |  Branch (713:28): [True: 14, False: 0]
  ------------------
  714|     14|            || (vpShorter && vpLonger->viewType != vpShorter->viewType)) {
  ------------------
  |  Branch (714:17): [True: 0, False: 0]
  |  Branch (714:30): [True: 0, False: 0]
  ------------------
  715|     14|            DEBUGMSGTL(("vacm:checkSubtree", ", %s\n", "unknown"));
  ------------------
  |  |   66|     14|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     14|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 14]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 14]
  |  |  ------------------
  ------------------
  716|     14|            return VACM_SUBTREE_UNKNOWN;
  ------------------
  |  |   30|     14|#define VACM_SUBTREE_UNKNOWN 7
  ------------------
  717|     14|        }
  718|     14|    }
  719|       |
  720|    499|    if (vpShorter && vpShorter->viewType != SNMP_VIEW_EXCLUDED) {
  ------------------
  |  |  327|     18|#define SNMP_VIEW_EXCLUDED		2
  ------------------
  |  Branch (720:9): [True: 18, False: 481]
  |  Branch (720:22): [True: 18, False: 0]
  ------------------
  721|     18|        DEBUGMSGTL(("vacm:checkSubtree", ", %s\n", "included"));
  ------------------
  |  |   66|     18|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     18|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 18]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 18]
  |  |  ------------------
  ------------------
  722|     18|        return VACM_SUCCESS;
  ------------------
  |  |   23|     18|#define VACM_SUCCESS       0
  ------------------
  723|     18|    }
  724|       |
  725|    481|    DEBUGMSGTL(("vacm:checkSubtree", ", %s\n", "excluded"));
  ------------------
  |  |   66|    481|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|    481|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 481]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 481]
  |  |  ------------------
  ------------------
  726|    481|    return VACM_NOTINVIEW;
  ------------------
  |  |   28|    481|#define VACM_NOTINVIEW     5
  ------------------
  727|    499|}
netsnmp_view_create:
  747|      2|{
  748|      2|    struct vacm_viewEntry *vp, *lp, *op = NULL;
  749|      2|    int             cmp, cmp2, glen;
  750|       |
  751|      2|    glen = (int) strlen(viewName);
  752|      2|    if (glen < 0 || glen > VACM_MAX_STRING || viewSubtreeLen > MAX_OID_LEN)
  ------------------
  |  |   56|      4|#define VACM_MAX_STRING 32
  ------------------
                  if (glen < 0 || glen > VACM_MAX_STRING || viewSubtreeLen > MAX_OID_LEN)
  ------------------
  |  |  120|      2|#define MAX_OID_LEN	    128 /* max subid's in an oid */
  ------------------
  |  Branch (752:9): [True: 0, False: 2]
  |  Branch (752:21): [True: 0, False: 2]
  |  Branch (752:47): [True: 0, False: 2]
  ------------------
  753|      0|        return NULL;
  754|      2|    vp = calloc(1, sizeof(struct vacm_viewEntry));
  755|      2|    if (vp == NULL)
  ------------------
  |  Branch (755:9): [True: 0, False: 2]
  ------------------
  756|      0|        return NULL;
  757|      2|    vp->reserved = calloc(1, sizeof(struct vacm_viewEntry));
  758|      2|    if (vp->reserved == NULL) {
  ------------------
  |  Branch (758:9): [True: 0, False: 2]
  ------------------
  759|      0|        free(vp);
  760|      0|        return NULL;
  761|      0|    }
  762|       |
  763|      2|    vp->viewName[0] = glen;
  764|      2|    strlcpy(vp->viewName + 1, viewName, sizeof(vp->viewName) - 1);
  765|      2|    vp->viewSubtree[0] = viewSubtreeLen;
  766|      2|    memcpy(vp->viewSubtree + 1, viewSubtree, viewSubtreeLen * sizeof(oid));
  767|      2|    vp->viewSubtreeLen = viewSubtreeLen + 1;
  768|       |
  769|      2|    lp = *head;
  770|      2|    while (lp) {
  ------------------
  |  Branch (770:12): [True: 0, False: 2]
  ------------------
  771|      0|        cmp = memcmp(lp->viewName, vp->viewName, glen + 1);
  772|      0|        cmp2 = snmp_oid_compare(lp->viewSubtree, lp->viewSubtreeLen,
  773|      0|                                vp->viewSubtree, vp->viewSubtreeLen);
  774|      0|        if (cmp == 0 && cmp2 > 0)
  ------------------
  |  Branch (774:13): [True: 0, False: 0]
  |  Branch (774:25): [True: 0, False: 0]
  ------------------
  775|      0|            break;
  776|      0|        if (cmp > 0)
  ------------------
  |  Branch (776:13): [True: 0, False: 0]
  ------------------
  777|      0|            break;
  778|      0|        op = lp;
  779|      0|        lp = lp->next;
  780|      0|    }
  781|      2|    vp->next = lp;
  782|      2|    if (op)
  ------------------
  |  Branch (782:9): [True: 0, False: 2]
  ------------------
  783|      0|        op->next = vp;
  784|      2|    else
  785|      2|        *head = vp;
  786|      2|    return vp;
  787|      2|}
vacm_createGroupEntry:
  871|      6|{
  872|      6|    struct vacm_groupEntry *gp, *lg, *og;
  873|      6|    int             cmp, glen;
  874|       |
  875|      6|    glen = (int) strlen(securityName);
  876|      6|    if (glen < 0 || glen > VACM_MAX_STRING)
  ------------------
  |  |   56|      6|#define VACM_MAX_STRING 32
  ------------------
  |  Branch (876:9): [True: 0, False: 6]
  |  Branch (876:21): [True: 0, False: 6]
  ------------------
  877|      0|        return NULL;
  878|      6|    gp = calloc(1, sizeof(struct vacm_groupEntry));
  879|      6|    if (gp == NULL)
  ------------------
  |  Branch (879:9): [True: 0, False: 6]
  ------------------
  880|      0|        return NULL;
  881|      6|    gp->reserved = calloc(1, sizeof(struct vacm_groupEntry));
  882|      6|    if (gp->reserved == NULL) {
  ------------------
  |  Branch (882:9): [True: 0, False: 6]
  ------------------
  883|      0|        free(gp);
  884|      0|        return NULL;
  885|      0|    }
  886|       |
  887|      6|    gp->securityModel = securityModel;
  888|      6|    gp->securityName[0] = glen;
  889|      6|    strlcpy(gp->securityName + 1, securityName, sizeof(gp->securityName) - 1);
  890|       |
  891|      6|    lg = groupList;
  892|      6|    og = NULL;
  893|     12|    while (lg) {
  ------------------
  |  Branch (893:12): [True: 6, False: 6]
  ------------------
  894|      6|        if (lg->securityModel > securityModel)
  ------------------
  |  Branch (894:13): [True: 0, False: 6]
  ------------------
  895|      0|            break;
  896|      6|        if (lg->securityModel == securityModel &&
  ------------------
  |  Branch (896:13): [True: 6, False: 0]
  ------------------
  897|      6|            (cmp =
  ------------------
  |  Branch (897:13): [True: 0, False: 6]
  ------------------
  898|      6|             memcmp(lg->securityName, gp->securityName, glen + 1)) > 0)
  899|      0|            break;
  900|       |        /*
  901|       |         * if (lg->securityModel == securityModel && cmp == 0) abort(); 
  902|       |         */
  903|      6|        og = lg;
  904|      6|        lg = lg->next;
  905|      6|    }
  906|      6|    gp->next = lg;
  907|      6|    if (og == NULL)
  ------------------
  |  Branch (907:9): [True: 2, False: 4]
  ------------------
  908|      2|        groupList = gp;
  909|      4|    else
  910|      4|        og->next = gp;
  911|      6|    return gp;
  912|      6|}
_vacm_choose_best:
  956|    474|{
  957|       |    /*
  958|       |     * RFC 3415: vacmAccessTable:
  959|       |     *    2) if this set has [more than] one member, ...
  960|       |     *       it comes down to deciding how to weight the
  961|       |     *       preferences between ContextPrefixes,
  962|       |     *       SecurityModels, and SecurityLevels
  963|       |     */
  964|    474|    if (( !current ) ||
  ------------------
  |  Branch (964:9): [True: 474, False: 0]
  ------------------
  965|       |        /* a) if the subset of entries with securityModel
  966|       |         *    matching the securityModel in the message is
  967|       |         *    not empty, then discard the rest
  968|       |         */
  969|      0|        (  current->securityModel == SNMP_SEC_MODEL_ANY &&
  ------------------
  |  |  292|      0|#define SNMP_SEC_MODEL_ANY		0
  ------------------
  |  Branch (969:12): [True: 0, False: 0]
  ------------------
  970|      0|         candidate->securityModel != SNMP_SEC_MODEL_ANY ) ||
  ------------------
  |  |  292|      0|#define SNMP_SEC_MODEL_ANY		0
  ------------------
  |  Branch (970:10): [True: 0, False: 0]
  ------------------
  971|       |        /* b) if the subset of entries with vacmAccessContextPrefix
  972|       |         *    matching the contextName in the message is
  973|       |         *    not empty, then discard the rest
  974|       |         */
  975|      0|        (  current->contextMatch  == CONTEXT_MATCH_PREFIX &&
  ------------------
  |  |   72|      0|#define CONTEXT_MATCH_PREFIX 2
  ------------------
  |  Branch (975:12): [True: 0, False: 0]
  ------------------
  976|      0|         candidate->contextMatch  == CONTEXT_MATCH_EXACT ) ||
  ------------------
  |  |   71|      0|#define CONTEXT_MATCH_EXACT  1
  ------------------
  |  Branch (976:10): [True: 0, False: 0]
  ------------------
  977|       |        /* c) discard all entries with ContextPrefixes shorter
  978|       |         *    than the longest one remaining in the set
  979|       |         */
  980|      0|        (  current->contextMatch  == CONTEXT_MATCH_PREFIX &&
  ------------------
  |  |   72|      0|#define CONTEXT_MATCH_PREFIX 2
  ------------------
  |  Branch (980:12): [True: 0, False: 0]
  ------------------
  981|      0|           current->contextPrefix[0] < candidate->contextPrefix[0] ) ||
  ------------------
  |  Branch (981:12): [True: 0, False: 0]
  ------------------
  982|       |        /* d) select the entry with the highest securityLevel
  983|       |         */
  984|    474|        (  current->securityLevel < candidate->securityLevel )) {
  ------------------
  |  Branch (984:9): [True: 0, False: 0]
  ------------------
  985|       |
  986|    474|        return candidate;
  987|    474|    }
  988|       |
  989|      0|    return current;
  990|    474|}
vacm_getAccessEntry:
  996|    513|{
  997|    513|    struct vacm_accessEntry *vp, *best=NULL;
  998|    513|    char            group[VACMSTRINGLEN];
  999|    513|    char            context[VACMSTRINGLEN];
 1000|    513|    int             glen, clen;
 1001|       |
 1002|    513|    glen = (int) strlen(groupName);
 1003|    513|    if (glen < 0 || glen > VACM_MAX_STRING)
  ------------------
  |  |   56|    513|#define VACM_MAX_STRING 32
  ------------------
  |  Branch (1003:9): [True: 0, False: 513]
  |  Branch (1003:21): [True: 0, False: 513]
  ------------------
 1004|      0|        return NULL;
 1005|    513|    clen = (int) strlen(contextPrefix);
 1006|    513|    if (clen < 0 || clen > VACM_MAX_STRING)
  ------------------
  |  |   56|    513|#define VACM_MAX_STRING 32
  ------------------
  |  Branch (1006:9): [True: 0, False: 513]
  |  Branch (1006:21): [True: 4, False: 509]
  ------------------
 1007|      4|        return NULL;
 1008|       |
 1009|    509|    group[0] = glen;
 1010|    509|    strlcpy(group + 1, groupName, sizeof(group) - 1);
 1011|    509|    context[0] = clen;
 1012|    509|    strlcpy(context + 1, contextPrefix, sizeof(context) - 1);
 1013|  1.01k|    for (vp = accessList; vp; vp = vp->next) {
  ------------------
  |  Branch (1013:27): [True: 509, False: 509]
  ------------------
 1014|    509|        if ((securityModel == vp->securityModel
  ------------------
  |  Branch (1014:14): [True: 509, False: 0]
  ------------------
 1015|      0|             || vp->securityModel == SNMP_SEC_MODEL_ANY)
  ------------------
  |  |  292|      0|#define SNMP_SEC_MODEL_ANY		0
  ------------------
  |  Branch (1015:17): [True: 0, False: 0]
  ------------------
 1016|    509|            && securityLevel >= vp->securityLevel
  ------------------
  |  Branch (1016:16): [True: 509, False: 0]
  ------------------
 1017|    509|            && !memcmp(vp->groupName, group, glen + 1)
  ------------------
  |  Branch (1017:16): [True: 509, False: 0]
  ------------------
 1018|    509|            &&
 1019|    509|            ((vp->contextMatch == CONTEXT_MATCH_EXACT
  ------------------
  |  |   71|  1.01k|#define CONTEXT_MATCH_EXACT  1
  ------------------
  |  Branch (1019:15): [True: 509, False: 0]
  ------------------
 1020|    509|              && clen == vp->contextPrefix[0]
  ------------------
  |  Branch (1020:18): [True: 474, False: 35]
  ------------------
 1021|    474|              && (memcmp(vp->contextPrefix, context, clen + 1) == 0))
  ------------------
  |  Branch (1021:18): [True: 474, False: 0]
  ------------------
 1022|     35|             || (vp->contextMatch == CONTEXT_MATCH_PREFIX
  ------------------
  |  |   72|     70|#define CONTEXT_MATCH_PREFIX 2
  ------------------
  |  Branch (1022:18): [True: 0, False: 35]
  ------------------
 1023|      0|                 && clen >= vp->contextPrefix[0]
  ------------------
  |  Branch (1023:21): [True: 0, False: 0]
  ------------------
 1024|      0|                 && (memcmp(vp->contextPrefix + 1, context + 1,
  ------------------
  |  Branch (1024:21): [True: 0, False: 0]
  ------------------
 1025|      0|                            vp->contextPrefix[0]) == 0))))
 1026|    474|            best = _vacm_choose_best( best, vp );
 1027|    509|    }
 1028|    509|    return best;
 1029|    513|}
vacm_createAccessEntry:
 1050|      2|{
 1051|      2|    struct vacm_accessEntry *vp, *lp, *op = NULL;
 1052|      2|    int             cmp, glen, clen;
 1053|       |
 1054|      2|    glen = (int) strlen(groupName);
 1055|      2|    if (glen < 0 || glen > VACM_MAX_STRING)
  ------------------
  |  |   56|      2|#define VACM_MAX_STRING 32
  ------------------
  |  Branch (1055:9): [True: 0, False: 2]
  |  Branch (1055:21): [True: 0, False: 2]
  ------------------
 1056|      0|        return NULL;
 1057|      2|    clen = (int) strlen(contextPrefix);
 1058|      2|    if (clen < 0 || clen > VACM_MAX_STRING)
  ------------------
  |  |   56|      2|#define VACM_MAX_STRING 32
  ------------------
  |  Branch (1058:9): [True: 0, False: 2]
  |  Branch (1058:21): [True: 0, False: 2]
  ------------------
 1059|      0|        return NULL;
 1060|      2|    vp = calloc(1, sizeof(struct vacm_accessEntry));
 1061|      2|    if (vp == NULL)
  ------------------
  |  Branch (1061:9): [True: 0, False: 2]
  ------------------
 1062|      0|        return NULL;
 1063|      2|    vp->reserved = calloc(1, sizeof(struct vacm_accessEntry));
 1064|      2|    if (vp->reserved == NULL) {
  ------------------
  |  Branch (1064:9): [True: 0, False: 2]
  ------------------
 1065|      0|        free(vp);
 1066|      0|        return NULL;
 1067|      0|    }
 1068|       |
 1069|      2|    vp->securityModel = securityModel;
 1070|      2|    vp->securityLevel = securityLevel;
 1071|      2|    vp->groupName[0] = glen;
 1072|      2|    strlcpy(vp->groupName + 1, groupName, sizeof(vp->groupName) - 1);
 1073|      2|    vp->contextPrefix[0] = clen;
 1074|      2|    strlcpy(vp->contextPrefix + 1, contextPrefix,
 1075|      2|            sizeof(vp->contextPrefix) - 1);
 1076|       |
 1077|      2|    lp = accessList;
 1078|      2|    while (lp) {
  ------------------
  |  Branch (1078:12): [True: 0, False: 2]
  ------------------
 1079|      0|        cmp = memcmp(lp->groupName, vp->groupName, glen + 1);
 1080|      0|        if (cmp > 0)
  ------------------
  |  Branch (1080:13): [True: 0, False: 0]
  ------------------
 1081|      0|            break;
 1082|      0|        if (cmp < 0)
  ------------------
  |  Branch (1082:13): [True: 0, False: 0]
  ------------------
 1083|      0|            goto next;
 1084|      0|        cmp = memcmp(lp->contextPrefix, vp->contextPrefix, clen + 1);
 1085|      0|        if (cmp > 0)
  ------------------
  |  Branch (1085:13): [True: 0, False: 0]
  ------------------
 1086|      0|            break;
 1087|      0|        if (cmp < 0)
  ------------------
  |  Branch (1087:13): [True: 0, False: 0]
  ------------------
 1088|      0|            goto next;
 1089|      0|        if (lp->securityModel > securityModel)
  ------------------
  |  Branch (1089:13): [True: 0, False: 0]
  ------------------
 1090|      0|            break;
 1091|      0|        if (lp->securityModel < securityModel)
  ------------------
  |  Branch (1091:13): [True: 0, False: 0]
  ------------------
 1092|      0|            goto next;
 1093|      0|        if (lp->securityLevel > securityLevel)
  ------------------
  |  Branch (1093:13): [True: 0, False: 0]
  ------------------
 1094|      0|            break;
 1095|      0|      next:
 1096|      0|        op = lp;
 1097|      0|        lp = lp->next;
 1098|      0|    }
 1099|      2|    vp->next = lp;
 1100|      2|    if (op == NULL)
  ------------------
  |  Branch (1100:9): [True: 2, False: 0]
  ------------------
 1101|      2|        accessList = vp;
 1102|      0|    else
 1103|      0|        op->next = vp;
 1104|      2|    return vp;
 1105|      2|}
vacm_getViewEntry:
 1190|  1.53k|{
 1191|  1.53k|    return netsnmp_view_get( viewList, viewName, viewSubtree, viewSubtreeLen,
 1192|  1.53k|                             mode);
 1193|  1.53k|}
vacm_checkSubtree:
 1198|    513|{
 1199|    513|    return netsnmp_view_subtree_check( viewList, viewName, viewSubtree,
 1200|    513|                                       viewSubtreeLen);
 1201|    513|}
vacm_createViewEntry:
 1206|      2|{
 1207|      2|    return netsnmp_view_create( &viewList, viewName, viewSubtree,
 1208|      2|                                viewSubtreeLen);
 1209|      2|}

LLVMFuzzerInitialize:
   45|      2|{
   46|      2|    char path[PATH_MAX];
   47|      2|    char mibdirs[PATH_MAX];
   48|      2|    char *dir;
   49|       |
   50|      2|    if (getenv("NETSNMP_DEBUGGING") != NULL) {
  ------------------
  |  Branch (50:9): [True: 0, False: 2]
  ------------------
   51|      0|        snmp_enable_stderrlog();
   52|      0|        snmp_set_do_debugging(1);
   53|      0|        debug_register_tokens("");
   54|      0|    }
   55|       |
   56|      2|    strlcpy(path, (*argv)[0], sizeof(path));
   57|      2|    dir = dirname(path);
   58|      2|    snprintf(mibdirs, sizeof(mibdirs), "%s/../../mibs", dir);
   59|      2|    netsnmp_ds_set_string(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_MIBDIRS,
  ------------------
  |  |   48|      2|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
                  netsnmp_ds_set_string(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_MIBDIRS,
  ------------------
  |  |  162|      2|#define NETSNMP_DS_LIB_MIBDIRS           11
  ------------------
   60|      2|                          mibdirs);
   61|      2|    netsnmp_ds_set_boolean(NETSNMP_DS_LIBRARY_ID,
  ------------------
  |  |   48|      2|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
   62|      2|                           NETSNMP_DS_LIB_DONT_PERSIST_STATE, 1);
  ------------------
  |  |   92|      2|#define NETSNMP_DS_LIB_DONT_PERSIST_STATE  32	/* don't load config and don't load/save persistent file */
  ------------------
   63|      2|    netsnmp_ds_set_string(NETSNMP_DS_LIBRARY_ID,
  ------------------
  |  |   48|      2|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
   64|      2|                          NETSNMP_DS_LIB_PERSISTENT_DIR, "/tmp");
  ------------------
  |  |  159|      2|#define NETSNMP_DS_LIB_PERSISTENT_DIR    8
  ------------------
   65|       |
   66|      2|    init_snmp("snmp_sec_models_fuzzer");
   67|       |
   68|       |    /* 1. Configure USM users with different Auth/Priv protocol combinations */
   69|      2|    char user_md5_des[] = "fuzzMD5 MD5 authpassword1234 DES privpassword1234";
   70|      2|    char user_sha_aes[] = "fuzzSHA SHA authpassword1234 AES privpassword1234";
   71|      2|    char user_noauth[] = "fuzzNoAuth";
   72|       |
   73|      2|    usm_parse_create_usmUser("createUser", user_md5_des);
   74|      2|    usm_parse_create_usmUser("createUser", user_sha_aes);
   75|      2|    usm_parse_create_usmUser("createUser", user_noauth);
   76|       |
   77|       |    /* 3. Configure VACM groups, access rules, and views */
   78|      2|    struct vacm_groupEntry *ge;
   79|      2|    ge = vacm_createGroupEntry(SNMP_SEC_MODEL_USM, "fuzzMD5");
  ------------------
  |  |  295|      2|#define SNMP_SEC_MODEL_USM		3
  ------------------
   80|      2|    if (ge) {
  ------------------
  |  Branch (80:9): [True: 2, False: 0]
  ------------------
   81|      2|        ge->status = RS_ACTIVE;
  ------------------
  |  |   35|      2|#define RS_ACTIVE	        1
  ------------------
   82|      2|        ge->storageType = ST_NONVOLATILE;
  ------------------
  |  |   52|      2|#define ST_NONVOLATILE	3
  ------------------
   83|      2|        strlcpy(ge->groupName, "fuzzGroup", sizeof(ge->groupName));
   84|      2|    }
   85|      2|    ge = vacm_createGroupEntry(SNMP_SEC_MODEL_USM, "fuzzSHA");
  ------------------
  |  |  295|      2|#define SNMP_SEC_MODEL_USM		3
  ------------------
   86|      2|    if (ge) {
  ------------------
  |  Branch (86:9): [True: 2, False: 0]
  ------------------
   87|      2|        ge->status = RS_ACTIVE;
  ------------------
  |  |   35|      2|#define RS_ACTIVE	        1
  ------------------
   88|      2|        ge->storageType = ST_NONVOLATILE;
  ------------------
  |  |   52|      2|#define ST_NONVOLATILE	3
  ------------------
   89|      2|        strlcpy(ge->groupName, "fuzzGroup", sizeof(ge->groupName));
   90|      2|    }
   91|      2|    ge = vacm_createGroupEntry(SNMP_SEC_MODEL_USM, "fuzzNoAuth");
  ------------------
  |  |  295|      2|#define SNMP_SEC_MODEL_USM		3
  ------------------
   92|      2|    if (ge) {
  ------------------
  |  Branch (92:9): [True: 2, False: 0]
  ------------------
   93|      2|        ge->status = RS_ACTIVE;
  ------------------
  |  |   35|      2|#define RS_ACTIVE	        1
  ------------------
   94|      2|        ge->storageType = ST_NONVOLATILE;
  ------------------
  |  |   52|      2|#define ST_NONVOLATILE	3
  ------------------
   95|      2|        strlcpy(ge->groupName, "fuzzGroup", sizeof(ge->groupName));
   96|      2|    }
   97|       |
   98|      2|    struct vacm_accessEntry *ae;
   99|      2|    ae = vacm_createAccessEntry("fuzzGroup", "", SNMP_SEC_MODEL_USM,
  ------------------
  |  |  295|      2|#define SNMP_SEC_MODEL_USM		3
  ------------------
  100|      2|                                SNMP_SEC_LEVEL_NOAUTH);
  ------------------
  |  |  299|      2|#define SNMP_SEC_LEVEL_NOAUTH		1
  ------------------
  101|      2|    if (ae) {
  ------------------
  |  Branch (101:9): [True: 2, False: 0]
  ------------------
  102|      2|        ae->status = RS_ACTIVE;
  ------------------
  |  |   35|      2|#define RS_ACTIVE	        1
  ------------------
  103|      2|        ae->storageType = ST_NONVOLATILE;
  ------------------
  |  |   52|      2|#define ST_NONVOLATILE	3
  ------------------
  104|      2|        ae->contextMatch = CONTEXT_MATCH_EXACT;
  ------------------
  |  |   71|      2|#define CONTEXT_MATCH_EXACT  1
  ------------------
  105|      2|        strlcpy((char *)ae->views[VACM_VIEW_READ], "fullView",
  ------------------
  |  |   77|      2|#define VACM_VIEW_READ     0
  ------------------
  106|      2|                sizeof(ae->views[VACM_VIEW_READ]));
  ------------------
  |  |   77|      2|#define VACM_VIEW_READ     0
  ------------------
  107|      2|        strlcpy((char *)ae->views[VACM_VIEW_WRITE], "fullView",
  ------------------
  |  |   78|      2|#define VACM_VIEW_WRITE    1
  ------------------
  108|      2|                sizeof(ae->views[VACM_VIEW_WRITE]));
  ------------------
  |  |   78|      2|#define VACM_VIEW_WRITE    1
  ------------------
  109|      2|        strlcpy((char *)ae->views[VACM_VIEW_NOTIFY], "fullView",
  ------------------
  |  |   79|      2|#define VACM_VIEW_NOTIFY   2
  ------------------
  110|      2|                sizeof(ae->views[VACM_VIEW_NOTIFY]));
  ------------------
  |  |   79|      2|#define VACM_VIEW_NOTIFY   2
  ------------------
  111|      2|    }
  112|       |
  113|      2|    oid fullViewOid[] = { 1, 3, 6, 1 };
  114|      2|    struct vacm_viewEntry *ve;
  115|      2|    ve = vacm_createViewEntry("fullView", fullViewOid, OID_LENGTH(fullViewOid));
  ------------------
  |  |   64|      2|    (sizeof(x) / sizeof((x)[0]) +                                       \
  |  |   65|      2|     sizeof(int[-__builtin_types_compatible_p(typeof(x), typeof(&(x)[0]))]))
  ------------------
  116|      2|    if (ve) {
  ------------------
  |  Branch (116:9): [True: 2, False: 0]
  ------------------
  117|      2|        ve->viewStatus = RS_ACTIVE;
  ------------------
  |  |   35|      2|#define RS_ACTIVE	        1
  ------------------
  118|      2|        ve->viewStorageType = ST_NONVOLATILE;
  ------------------
  |  |   52|      2|#define ST_NONVOLATILE	3
  ------------------
  119|      2|        ve->viewType = SNMP_VIEW_INCLUDED;
  ------------------
  |  |  326|      2|#define SNMP_VIEW_INCLUDED		1
  ------------------
  120|      2|        ve->viewMask[0] = 0xff;
  121|      2|        ve->viewMaskLen = 1;
  122|      2|    }
  123|       |
  124|      2|    return 0;
  125|      2|}
LLVMFuzzerTestOneInput:
  128|  3.01k|{
  129|  3.01k|    netsnmp_session session;
  130|  3.01k|    netsnmp_pdu *pdu;
  131|  3.01k|    u_char *pkt;
  132|       |
  133|  3.01k|    if (size == 0)
  ------------------
  |  Branch (133:9): [True: 0, False: 3.01k]
  ------------------
  134|      0|        return 0;
  135|       |
  136|  3.01k|    memset(&session, 0, sizeof(session));
  137|  3.01k|    session.version = SNMP_VERSION_3;
  ------------------
  |  |  113|  3.01k|#define SNMP_VERSION_3     3
  ------------------
  138|       |
  139|  3.01k|    pdu = SNMP_MALLOC_TYPEDEF(netsnmp_pdu);
  ------------------
  |  |   73|  3.01k|#define SNMP_MALLOC_TYPEDEF(td)  (td *) calloc(1, sizeof(td))
  ------------------
  140|  3.01k|    if (!pdu)
  ------------------
  |  Branch (140:9): [True: 0, False: 3.01k]
  ------------------
  141|      0|        return 0;
  142|       |
  143|  3.01k|    pkt = netsnmp_memdup(data, size);
  144|  3.01k|    if (!pkt) {
  ------------------
  |  Branch (144:9): [True: 0, False: 3.01k]
  ------------------
  145|      0|        snmp_free_pdu(pdu);
  146|      0|        return 0;
  147|      0|    }
  148|       |
  149|       |    /* 1. Test full SNMP message parsing with active security models */
  150|  3.01k|    snmp_parse(NULL, &session, pdu, pkt, size);
  151|       |
  152|       |    /* 2. Test scoped PDU parsing directly */
  153|  3.01k|    size_t scoped_bytes = size;
  154|  3.01k|    netsnmp_pdu *scoped_pdu = SNMP_MALLOC_TYPEDEF(netsnmp_pdu);
  ------------------
  |  |   73|  3.01k|#define SNMP_MALLOC_TYPEDEF(td)  (td *) calloc(1, sizeof(td))
  ------------------
  155|  3.01k|    if (scoped_pdu) {
  ------------------
  |  Branch (155:9): [True: 3.01k, False: 0]
  ------------------
  156|  3.01k|        snmpv3_scopedPDU_parse(scoped_pdu, pkt, &scoped_bytes);
  157|  3.01k|        snmp_free_pdu(scoped_pdu);
  158|  3.01k|    }
  159|       |
  160|       |    /* 3. Test VACM view lookups and subtree verification */
  161|  3.01k|    if (pdu->variables && pdu->variables->name && pdu->variables->name_length > 0) {
  ------------------
  |  Branch (161:9): [True: 513, False: 2.50k]
  |  Branch (161:27): [True: 513, False: 0]
  |  Branch (161:51): [True: 513, False: 0]
  ------------------
  162|    513|        vacm_checkSubtree("fullView", pdu->variables->name,
  163|    513|                          pdu->variables->name_length);
  164|    513|        vacm_getViewEntry("fullView", pdu->variables->name,
  165|    513|                          pdu->variables->name_length, VACM_MODE_FIND);
  ------------------
  |  |  143|    513|#define VACM_MODE_FIND                0
  ------------------
  166|    513|        vacm_getViewEntry("fullView", pdu->variables->name,
  167|    513|                          pdu->variables->name_length, VACM_MODE_IGNORE_MASK);
  ------------------
  |  |  144|    513|#define VACM_MODE_IGNORE_MASK         1
  ------------------
  168|    513|        vacm_getViewEntry("fullView", pdu->variables->name,
  169|    513|                          pdu->variables->name_length, VACM_MODE_CHECK_SUBTREE);
  ------------------
  |  |  145|    513|#define VACM_MODE_CHECK_SUBTREE       2
  ------------------
  170|    513|        vacm_getAccessEntry("fuzzGroup",
  171|    513|                            pdu->contextName ? pdu->contextName : "",
  ------------------
  |  Branch (171:29): [True: 513, False: 0]
  ------------------
  172|    513|                            pdu->securityModel, pdu->securityLevel);
  173|    513|    }
  174|       |
  175|  3.01k|    free(pkt);
  176|  3.01k|    snmp_free_pdu(pdu);
  177|  3.01k|    netsnmp_cleanup_session(&session);
  178|       |
  179|  3.01k|    return 0;
  180|  3.01k|}

