pac.c:k5_input_init: 53| 1.01k|{ 54| 1.01k| in->ptr = ptr; 55| 1.01k| in->len = len; 56| 1.01k| in->status = 0; 57| 1.01k|} pac.c:k5_input_get_uint32_le: 117| 5.47k|{ 118| 5.47k| const unsigned char *ptr = k5_input_get_bytes(in, 4); 119| 5.47k| return (ptr == NULL) ? 0 : load_32_le(ptr); ------------------ | Branch (119:12): [True: 9, False: 5.46k] ------------------ 120| 5.47k|} pac.c:k5_input_get_bytes: 70| 7.20k|{ 71| 7.20k| if (in->len < len) ------------------ | Branch (71:9): [True: 9, False: 7.19k] ------------------ 72| 9| k5_input_set_status(in, EINVAL); 73| 7.20k| if (in->status) ------------------ | Branch (73:9): [True: 9, False: 7.19k] ------------------ 74| 9| return NULL; 75| 7.19k| in->len -= len; 76| 7.19k| in->ptr += len; 77| 7.19k| return in->ptr - len; 78| 7.20k|} pac.c:k5_input_set_status: 63| 9|{ 64| 9| if (!in->status) ------------------ | Branch (64:9): [True: 6, False: 3] ------------------ 65| 6| in->status = status; 66| 9|} pac.c:k5_input_get_uint64_le: 138| 1.72k|{ 139| 1.72k| const unsigned char *ptr = k5_input_get_bytes(in, 8); 140| 1.72k| return (ptr == NULL) ? 0 : load_64_le(ptr); ------------------ | Branch (140:12): [True: 0, False: 1.72k] ------------------ 141| 1.72k|} utf8_conv.c:k5_input_init: 53| 1.73k|{ 54| 1.73k| in->ptr = ptr; 55| 1.73k| in->len = len; 56| 1.73k| in->status = 0; 57| 1.73k|} utf8_conv.c:k5_input_get_uint16_le: 96| 25.9k|{ 97| 25.9k| const unsigned char *ptr = k5_input_get_bytes(in, 2); 98| 25.9k| return (ptr == NULL) ? 0 : load_16_le(ptr); ------------------ | Branch (98:12): [True: 39, False: 25.8k] ------------------ 99| 25.9k|} utf8_conv.c:k5_input_get_bytes: 70| 25.9k|{ 71| 25.9k| if (in->len < len) ------------------ | Branch (71:9): [True: 39, False: 25.8k] ------------------ 72| 39| k5_input_set_status(in, EINVAL); 73| 25.9k| if (in->status) ------------------ | Branch (73:9): [True: 39, False: 25.8k] ------------------ 74| 39| return NULL; 75| 25.8k| in->len -= len; 76| 25.8k| in->ptr += len; 77| 25.8k| return in->ptr - len; 78| 25.9k|} utf8_conv.c:k5_input_set_status: 63| 39|{ 64| 39| if (!in->status) ------------------ | Branch (64:9): [True: 39, False: 0] ------------------ 65| 39| in->status = status; 66| 39|} pac.c:make_data: 2237| 2.23k|{ 2238| 2.23k| krb5_data d; 2239| | 2240| 2.23k| d.magic = KV5M_DATA; ------------------ | | 9038| 2.23k|#define KV5M_DATA (-1760647422L) ------------------ 2241| 2.23k| d.data = (char *) data; 2242| 2.23k| d.length = len; 2243| 2.23k| return d; 2244| 2.23k|} pac.c:zapfree: 665| 1.78k|{ 666| 1.78k| if (ptr != NULL) { ------------------ | Branch (666:9): [True: 1.78k, False: 0] ------------------ 667| 1.78k| zap(ptr, len); ------------------ | | 1009| 1.78k|# define zap(ptr, len) explicit_bzero(ptr, len) ------------------ 668| 1.78k| free(ptr); 669| 1.78k| } 670| 1.78k|} pac.c:k5alloc: 2294| 890|{ 2295| 890| return k5calloc(1, size, code); 2296| 890|} pac.c:k5calloc: 2282| 1.78k|{ 2283| 1.78k| void *ptr; 2284| | 2285| | /* Allocate at least one byte since zero-byte allocs may return NULL. */ 2286| 1.78k| ptr = calloc(nmemb ? nmemb : 1, size ? size : 1); ------------------ | Branch (2286:18): [True: 1.78k, False: 0] | Branch (2286:37): [True: 1.78k, False: 0] ------------------ 2287| 1.78k| *code = (ptr == NULL) ? ENOMEM : 0; ------------------ | Branch (2287:13): [True: 0, False: 1.78k] ------------------ 2288| 1.78k| return ptr; 2289| 1.78k|} parse.c:k5alloc: 2294| 4.05k|{ 2295| 4.05k| return k5calloc(1, size, code); 2296| 4.05k|} parse.c:k5calloc: 2282| 4.05k|{ 2283| 4.05k| void *ptr; 2284| | 2285| | /* Allocate at least one byte since zero-byte allocs may return NULL. */ 2286| 4.05k| ptr = calloc(nmemb ? nmemb : 1, size ? size : 1); ------------------ | Branch (2286:18): [True: 4.05k, False: 0] | Branch (2286:37): [True: 4.05k, False: 0] ------------------ 2287| 4.05k| *code = (ptr == NULL) ? ENOMEM : 0; ------------------ | Branch (2287:13): [True: 0, False: 4.05k] ------------------ 2288| 4.05k| return ptr; 2289| 4.05k|} parse.c:make_data: 2237| 2.02k|{ 2238| 2.02k| krb5_data d; 2239| | 2240| 2.02k| d.magic = KV5M_DATA; ------------------ | | 9038| 2.02k|#define KV5M_DATA (-1760647422L) ------------------ 2241| 2.02k| d.data = (char *) data; 2242| 2.02k| d.length = len; 2243| 2.02k| return d; 2244| 2.02k|} parse.c:empty_data: 2248| 2.02k|{ 2249| | return make_data(NULL, 0); 2250| 2.02k|} keyblocks.c:zapfree: 665| 84|{ 666| 84| if (ptr != NULL) { ------------------ | Branch (666:9): [True: 84, False: 0] ------------------ 667| 84| zap(ptr, len); ------------------ | | 1009| 84|# define zap(ptr, len) explicit_bzero(ptr, len) ------------------ 668| 84| free(ptr); 669| 84| } 670| 84|} make_checksum.c:alloc_data: 2260| 79|{ 2261| | /* Allocate at least one byte since zero-byte allocs may return NULL. */ 2262| 79| char *ptr = (char *) calloc((len > 0) ? len : 1, 1); ------------------ | Branch (2262:33): [True: 79, False: 0] ------------------ 2263| | 2264| 79| if (ptr == NULL) ------------------ | Branch (2264:9): [True: 0, False: 79] ------------------ 2265| 0| return ENOMEM; 2266| 79| data->magic = KV5M_DATA; ------------------ | | 9038| 79|#define KV5M_DATA (-1760647422L) ------------------ 2267| 79| data->data = ptr; 2268| 79| data->length = len; 2269| 79| return 0; 2270| 79|} make_checksum.c:zapfree: 665| 79|{ 666| 79| if (ptr != NULL) { ------------------ | Branch (666:9): [True: 0, False: 79] ------------------ 667| 0| zap(ptr, len); ------------------ | | 1009| 0|# define zap(ptr, len) explicit_bzero(ptr, len) ------------------ 668| 0| free(ptr); 669| 0| } 670| 79|} verify_checksum.c:make_data: 2237| 79|{ 2238| 79| krb5_data d; 2239| | 2240| 79| d.magic = KV5M_DATA; ------------------ | | 9038| 79|#define KV5M_DATA (-1760647422L) ------------------ 2241| 79| d.data = (char *) data; 2242| 79| d.length = len; 2243| 79| return d; 2244| 79|} hmac.c:k5alloc: 2294| 238|{ 2295| 238| return k5calloc(1, size, code); 2296| 238|} hmac.c:k5calloc: 2282| 357|{ 2283| 357| void *ptr; 2284| | 2285| | /* Allocate at least one byte since zero-byte allocs may return NULL. */ 2286| 357| ptr = calloc(nmemb ? nmemb : 1, size ? size : 1); ------------------ | Branch (2286:18): [True: 357, False: 0] | Branch (2286:37): [True: 357, False: 0] ------------------ 2287| 357| *code = (ptr == NULL) ? ENOMEM : 0; ------------------ | Branch (2287:13): [True: 0, False: 357] ------------------ 2288| 357| return ptr; 2289| 357|} hmac.c:make_data: 2237| 476|{ 2238| 476| krb5_data d; 2239| | 2240| 476| d.magic = KV5M_DATA; ------------------ | | 9038| 476|#define KV5M_DATA (-1760647422L) ------------------ 2241| 476| d.data = (char *) data; 2242| 476| d.length = len; 2243| 476| return d; 2244| 476|} hmac.c:zapfree: 665| 238|{ 666| 238| if (ptr != NULL) { ------------------ | Branch (666:9): [True: 238, False: 0] ------------------ 667| 238| zap(ptr, len); ------------------ | | 1009| 238|# define zap(ptr, len) explicit_bzero(ptr, len) ------------------ 668| 238| free(ptr); 669| 238| } 670| 238|} checksum_hmac_md5.c:empty_data: 2248| 158|{ 2249| | return make_data(NULL, 0); 2250| 158|} checksum_hmac_md5.c:alloc_data: 2260| 119|{ 2261| | /* Allocate at least one byte since zero-byte allocs may return NULL. */ 2262| 119| char *ptr = (char *) calloc((len > 0) ? len : 1, 1); ------------------ | Branch (2262:33): [True: 119, False: 0] ------------------ 2263| | 2264| 119| if (ptr == NULL) ------------------ | Branch (2264:9): [True: 0, False: 119] ------------------ 2265| 0| return ENOMEM; 2266| 119| data->magic = KV5M_DATA; ------------------ | | 9038| 119|#define KV5M_DATA (-1760647422L) ------------------ 2267| 119| data->data = ptr; 2268| 119| data->length = len; 2269| 119| return 0; 2270| 119|} checksum_hmac_md5.c:make_data: 2237| 277|{ 2238| 277| krb5_data d; 2239| | 2240| 277| d.magic = KV5M_DATA; ------------------ | | 9038| 277|#define KV5M_DATA (-1760647422L) ------------------ 2241| 277| d.data = (char *) data; 2242| 277| d.length = len; 2243| 277| return d; 2244| 277|} checksum_hmac_md5.c:k5calloc: 2282| 79|{ 2283| 79| void *ptr; 2284| | 2285| | /* Allocate at least one byte since zero-byte allocs may return NULL. */ 2286| 79| ptr = calloc(nmemb ? nmemb : 1, size ? size : 1); ------------------ | Branch (2286:18): [True: 79, False: 0] | Branch (2286:37): [True: 79, False: 0] ------------------ 2287| 79| *code = (ptr == NULL) ? ENOMEM : 0; ------------------ | Branch (2287:13): [True: 0, False: 79] ------------------ 2288| 79| return ptr; 2289| 79|} checksum_hmac_md5.c:zapfree: 665| 158|{ 666| 158| if (ptr != NULL) { ------------------ | Branch (666:9): [True: 119, False: 39] ------------------ 667| 119| zap(ptr, len); ------------------ | | 1009| 119|# define zap(ptr, len) explicit_bzero(ptr, len) ------------------ 668| 119| free(ptr); 669| 119| } 670| 158|} pac.c:load_32_le: 681| 5.65k|{ 682| 5.65k| const unsigned char *p = (const unsigned char *) cvp; 683| 5.65k|#if defined(__GNUC__) && defined(K5_LE) && !defined(__cplusplus) 684| 5.65k| return GET(32,p); ------------------ | | 490| 5.65k|# define GET(SIZE,PTR) (((const struct { uint##SIZE##_t i; } __attribute__((packed)) *)(PTR))->i) ------------------ 685| |#elif defined(__GNUC__) && defined(K5_BE) && defined(SWAP32) && !defined(__cplusplus) 686| | return GETSWAPPED(32,p); 687| |#else 688| | return (p[0] | (p[1] << 8) | (p[2] << 16) | (p[3] << 24)); 689| |#endif 690| 5.65k|} pac.c:load_64_le: 693| 3.71k|{ 694| 3.71k| const unsigned char *p = (const unsigned char *) cvp; 695| 3.71k|#if defined(__GNUC__) && defined(K5_LE) && !defined(__cplusplus) 696| 3.71k| return GET(64,p); ------------------ | | 490| 3.71k|# define GET(SIZE,PTR) (((const struct { uint##SIZE##_t i; } __attribute__((packed)) *)(PTR))->i) ------------------ 697| |#elif defined(__GNUC__) && defined(K5_BE) && defined(SWAP64) && !defined(__cplusplus) 698| | return GETSWAPPED(64,p); 699| |#else 700| | return ((uint64_t)load_32_le(p+4) << 32) | load_32_le(p); 701| |#endif 702| 3.71k|} pac.c:load_16_le: 669| 1.98k|{ 670| 1.98k| const unsigned char *p = (const unsigned char *) cvp; 671| 1.98k|#if defined(__GNUC__) && defined(K5_LE) && !defined(__cplusplus) 672| 1.98k| return GET(16,p); ------------------ | | 490| 1.98k|# define GET(SIZE,PTR) (((const struct { uint##SIZE##_t i; } __attribute__((packed)) *)(PTR))->i) ------------------ 673| |#elif defined(__GNUC__) && defined(K5_BE) && defined(SWAP16) && !defined(__cplusplus) 674| | return GETSWAPPED(16,p); 675| |#else 676| | return (p[0] | (p[1] << 8)); 677| |#endif 678| 1.98k|} krb5_libinit.c:krb5int_lib_init__aux: 284| 1| { \ 285| 1| JOIN__2(NAME, once).did_run = 1; \ ------------------ | | 233| 1|# define JOIN__2(A,B) JOIN__2_2(A,B) | | ------------------ | | | | 232| 1|# define JOIN__2_2(A,B) A ## _ ## _ ## B | | ------------------ ------------------ 286| 1| JOIN__2(NAME, once).error = NAME(); \ ------------------ | | 233| 1|# define JOIN__2(A,B) JOIN__2_2(A,B) | | ------------------ | | | | 232| 1|# define JOIN__2_2(A,B) A ## _ ## _ ## B | | ------------------ ------------------ 287| 1| } \ prof_file.c:profile_library_initializer__aux: 284| 1| { \ 285| 1| JOIN__2(NAME, once).did_run = 1; \ ------------------ | | 233| 1|# define JOIN__2(A,B) JOIN__2_2(A,B) | | ------------------ | | | | 232| 1|# define JOIN__2_2(A,B) A ## _ ## _ ## B | | ------------------ ------------------ 286| 1| JOIN__2(NAME, once).error = NAME(); \ ------------------ | | 233| 1|# define JOIN__2(A,B) JOIN__2_2(A,B) | | ------------------ | | | | 232| 1|# define JOIN__2_2(A,B) A ## _ ## _ ## B | | ------------------ ------------------ 287| 1| } \ checksum_hmac_md5.c:store_32_le: 635| 79|{ 636| 79| unsigned char *p = (unsigned char *) vp; 637| 79|#if defined(__GNUC__) && defined(K5_LE) && !defined(__cplusplus) 638| 79| PUT(32,p,val); ------------------ | | 489| 79|# define PUT(SIZE,PTR,VAL) (((struct { uint##SIZE##_t i; } __attribute__((packed)) *)(PTR))->i = (VAL)) ------------------ 639| |#elif defined(__GNUC__) && defined(K5_BE) && defined(SWAP32) && !defined(__cplusplus) 640| | PUTSWAPPED(32,p,val); 641| |#else 642| | p[3] = (val >> 24) & 0xff; 643| | p[2] = (val >> 16) & 0xff; 644| | p[1] = (val >> 8) & 0xff; 645| | p[0] = (val ) & 0xff; 646| |#endif 647| 79|} md5.c:load_32_le: 681| 15.3k|{ 682| 15.3k| const unsigned char *p = (const unsigned char *) cvp; 683| 15.3k|#if defined(__GNUC__) && defined(K5_LE) && !defined(__cplusplus) 684| 15.3k| return GET(32,p); ------------------ | | 490| 15.3k|# define GET(SIZE,PTR) (((const struct { uint##SIZE##_t i; } __attribute__((packed)) *)(PTR))->i) ------------------ 685| |#elif defined(__GNUC__) && defined(K5_BE) && defined(SWAP32) && !defined(__cplusplus) 686| | return GETSWAPPED(32,p); 687| |#else 688| | return (p[0] | (p[1] << 8) | (p[2] << 16) | (p[3] << 24)); 689| |#endif 690| 15.3k|} md5.c:store_32_le: 635| 1.26k|{ 636| 1.26k| unsigned char *p = (unsigned char *) vp; 637| 1.26k|#if defined(__GNUC__) && defined(K5_LE) && !defined(__cplusplus) 638| 1.26k| PUT(32,p,val); ------------------ | | 489| 1.26k|# define PUT(SIZE,PTR,VAL) (((struct { uint##SIZE##_t i; } __attribute__((packed)) *)(PTR))->i = (VAL)) ------------------ 639| |#elif defined(__GNUC__) && defined(K5_BE) && defined(SWAP32) && !defined(__cplusplus) 640| | PUTSWAPPED(32,p,val); 641| |#else 642| | p[3] = (val >> 24) & 0xff; 643| | p[2] = (val >> 16) & 0xff; 644| | p[1] = (val >> 8) & 0xff; 645| | p[0] = (val ) & 0xff; 646| |#endif 647| 1.26k|} error_message.c:com_err_initialize__aux: 284| 1| { \ 285| 1| JOIN__2(NAME, once).did_run = 1; \ ------------------ | | 233| 1|# define JOIN__2(A,B) JOIN__2_2(A,B) | | ------------------ | | | | 232| 1|# define JOIN__2_2(A,B) A ## _ ## _ ## B | | ------------------ ------------------ 286| 1| JOIN__2(NAME, once).error = NAME(); \ ------------------ | | 233| 1|# define JOIN__2(A,B) JOIN__2_2(A,B) | | ------------------ | | | | 232| 1|# define JOIN__2_2(A,B) A ## _ ## _ ## B | | ------------------ ------------------ 287| 1| } \ threads.c:krb5int_thread_support_init__aux: 284| 1| { \ 285| 1| JOIN__2(NAME, once).did_run = 1; \ ------------------ | | 233| 1|# define JOIN__2(A,B) JOIN__2_2(A,B) | | ------------------ | | | | 232| 1|# define JOIN__2_2(A,B) A ## _ ## _ ## B | | ------------------ ------------------ 286| 1| JOIN__2(NAME, once).error = NAME(); \ ------------------ | | 233| 1|# define JOIN__2(A,B) JOIN__2_2(A,B) | | ------------------ | | | | 232| 1|# define JOIN__2_2(A,B) A ## _ ## _ ## B | | ------------------ ------------------ 287| 1| } \ utf8_conv.c:load_16_le: 669| 25.8k|{ 670| 25.8k| const unsigned char *p = (const unsigned char *) cvp; 671| 25.8k|#if defined(__GNUC__) && defined(K5_LE) && !defined(__cplusplus) 672| 25.8k| return GET(16,p); ------------------ | | 490| 25.8k|# define GET(SIZE,PTR) (((const struct { uint##SIZE##_t i; } __attribute__((packed)) *)(PTR))->i) ------------------ 673| |#elif defined(__GNUC__) && defined(K5_BE) && defined(SWAP16) && !defined(__cplusplus) 674| | return GETSWAPPED(16,p); 675| |#else 676| | return (p[0] | (p[1] << 8)); 677| |#endif 678| 25.8k|} krb5_libinit.c:k5_mutex_finish_init: 361| 1|{ 362| 1| return k5_os_mutex_finish_init(m); ------------------ | | 289| 1|# define k5_os_mutex_finish_init(M) (0) ------------------ 363| 1|} ccbase.c:k5_mutex_finish_init: 361| 4|{ 362| 4| return k5_os_mutex_finish_init(m); ------------------ | | 289| 4|# define k5_os_mutex_finish_init(M) (0) ------------------ 363| 4|} ktbase.c:k5_mutex_finish_init: 361| 1|{ 362| 1| return k5_os_mutex_finish_init(m); ------------------ | | 289| 1|# define k5_os_mutex_finish_init(M) (0) ------------------ 363| 1|} kt_memory.c:k5_mutex_finish_init: 361| 1|{ 362| 1| return k5_os_mutex_finish_init(m); ------------------ | | 289| 1|# define k5_os_mutex_finish_init(M) (0) ------------------ 363| 1|} prof_file.c:k5_mutex_init: 357| 2.02k|{ 358| 2.02k| return k5_os_mutex_init(m); 359| 2.02k|} prof_file.c:k5_mutex_finish_init: 361| 1|{ 362| 1| return k5_os_mutex_finish_init(m); ------------------ | | 289| 1|# define k5_os_mutex_finish_init(M) (0) ------------------ 363| 1|} prof_file.c:k5_mutex_lock: 368| 8.11k|{ 369| 8.11k| int r = k5_os_mutex_lock(m); 370| 8.11k|#ifndef NDEBUG 371| 8.11k| if (r != 0) { ------------------ | Branch (371:9): [True: 0, False: 8.11k] ------------------ 372| 0| fprintf(stderr, "k5_mutex_lock: Received error %d (%s)\n", 373| 0| r, strerror(r)); 374| 0| } 375| 8.11k|#endif 376| | assert(r == 0); ------------------ | Branch (376:5): [True: 0, False: 8.11k] | Branch (376:5): [True: 8.11k, False: 0] ------------------ 377| 8.11k|} prof_file.c:k5_mutex_unlock: 380| 8.11k|{ 381| 8.11k| int r = k5_os_mutex_unlock(m); 382| 8.11k|#ifndef NDEBUG 383| 8.11k| if (r != 0) { ------------------ | Branch (383:9): [True: 0, False: 8.11k] ------------------ 384| 0| fprintf(stderr, "k5_mutex_unlock: Received error %d (%s)\n", 385| 0| r, strerror(r)); 386| 0| } 387| 8.11k|#endif 388| | assert(r == 0); ------------------ | Branch (388:5): [True: 0, False: 8.11k] | Branch (388:5): [True: 8.11k, False: 0] ------------------ 389| 8.11k|} error_message.c:k5_mutex_finish_init: 361| 2|{ 362| 2| return k5_os_mutex_finish_init(m); ------------------ | | 289| 2|# define k5_os_mutex_finish_init(M) (0) ------------------ 363| 2|} error_message.c:k5_mutex_lock: 368| 7|{ 369| 7| int r = k5_os_mutex_lock(m); 370| 7|#ifndef NDEBUG 371| 7| if (r != 0) { ------------------ | Branch (371:9): [True: 0, False: 7] ------------------ 372| 0| fprintf(stderr, "k5_mutex_lock: Received error %d (%s)\n", 373| 0| r, strerror(r)); 374| 0| } 375| 7|#endif 376| | assert(r == 0); ------------------ | Branch (376:5): [True: 0, False: 7] | Branch (376:5): [True: 7, False: 0] ------------------ 377| 7|} error_message.c:k5_mutex_unlock: 380| 7|{ 381| 7| int r = k5_os_mutex_unlock(m); 382| 7|#ifndef NDEBUG 383| 7| if (r != 0) { ------------------ | Branch (383:9): [True: 0, False: 7] ------------------ 384| 0| fprintf(stderr, "k5_mutex_unlock: Received error %d (%s)\n", 385| 0| r, strerror(r)); 386| 0| } 387| 7|#endif 388| | assert(r == 0); ------------------ | Branch (388:5): [True: 0, False: 7] | Branch (388:5): [True: 7, False: 0] ------------------ 389| 7|} threads.c:k5_mutex_finish_init: 361| 1|{ 362| 1| return k5_os_mutex_finish_init(m); ------------------ | | 289| 1|# define k5_os_mutex_finish_init(M) (0) ------------------ 363| 1|} threads.c:k5_mutex_lock: 368| 1|{ 369| 1| int r = k5_os_mutex_lock(m); 370| 1|#ifndef NDEBUG 371| 1| if (r != 0) { ------------------ | Branch (371:9): [True: 0, False: 1] ------------------ 372| 0| fprintf(stderr, "k5_mutex_lock: Received error %d (%s)\n", 373| 0| r, strerror(r)); 374| 0| } 375| 1|#endif 376| | assert(r == 0); ------------------ | Branch (376:5): [True: 0, False: 1] | Branch (376:5): [True: 1, False: 0] ------------------ 377| 1|} threads.c:k5_mutex_unlock: 380| 1|{ 381| 1| int r = k5_os_mutex_unlock(m); 382| 1|#ifndef NDEBUG 383| 1| if (r != 0) { ------------------ | Branch (383:9): [True: 0, False: 1] ------------------ 384| 0| fprintf(stderr, "k5_mutex_unlock: Received error %d (%s)\n", 385| 0| r, strerror(r)); 386| 0| } 387| 1|#endif 388| | assert(r == 0); ------------------ | Branch (388:5): [True: 0, False: 1] | Branch (388:5): [True: 1, False: 0] ------------------ 389| 1|} init-addrinfo.c:k5_mutex_finish_init: 361| 1|{ 362| 1| return k5_os_mutex_finish_init(m); ------------------ | | 289| 1|# define k5_os_mutex_finish_init(M) (0) ------------------ 363| 1|} errors.c:k5_mutex_finish_init: 361| 1|{ 362| 1| return k5_os_mutex_finish_init(m); ------------------ | | 289| 1|# define k5_os_mutex_finish_init(M) (0) ------------------ 363| 1|} errors.c:k5_mutex_lock: 368| 1|{ 369| 1| int r = k5_os_mutex_lock(m); 370| 1|#ifndef NDEBUG 371| 1| if (r != 0) { ------------------ | Branch (371:9): [True: 0, False: 1] ------------------ 372| 0| fprintf(stderr, "k5_mutex_lock: Received error %d (%s)\n", 373| 0| r, strerror(r)); 374| 0| } 375| 1|#endif 376| | assert(r == 0); ------------------ | Branch (376:5): [True: 0, False: 1] | Branch (376:5): [True: 1, False: 0] ------------------ 377| 1|} errors.c:k5_mutex_unlock: 380| 1|{ 381| 1| int r = k5_os_mutex_unlock(m); 382| 1|#ifndef NDEBUG 383| 1| if (r != 0) { ------------------ | Branch (383:9): [True: 0, False: 1] ------------------ 384| 0| fprintf(stderr, "k5_mutex_unlock: Received error %d (%s)\n", 385| 0| r, strerror(r)); 386| 0| } 387| 1|#endif 388| | assert(r == 0); ------------------ | Branch (388:5): [True: 0, False: 1] | Branch (388:5): [True: 1, False: 0] ------------------ 389| 1|} hash_md5.c:k5_md5_hash: 35| 317|{ 36| 317| krb5_MD5_CTX ctx; 37| 317| unsigned int i; 38| | 39| 317| if (output->length != RSA_MD5_CKSUM_LENGTH) ------------------ | | 54| 317|#define RSA_MD5_CKSUM_LENGTH 16 ------------------ | Branch (39:9): [True: 0, False: 317] ------------------ 40| 0| return KRB5_CRYPTO_INTERNAL; ------------------ | | 8831| 0|#define KRB5_CRYPTO_INTERNAL (-1765328206L) ------------------ 41| | 42| 317| krb5int_MD5Init(&ctx); 43| 951| for (i = 0; i < num_data; i++) { ------------------ | Branch (43:17): [True: 634, False: 317] ------------------ 44| 634| const krb5_crypto_iov *iov = &data[i]; 45| | 46| 634| if (SIGN_IOV(iov)) { ------------------ | | 431| 634|#define SIGN_IOV(_iov) (ENCRYPT_IOV(_iov) || \ | | ------------------ | | | | 429| 1.26k|#define ENCRYPT_IOV(_iov) (ENCRYPT_CONF_IOV(_iov) || ENCRYPT_DATA_IOV(_iov)) | | | | ------------------ | | | | | | 424| 1.26k|#define ENCRYPT_CONF_IOV(_iov) ((_iov)->flags == KRB5_CRYPTO_TYPE_HEADER) | | | | | | ------------------ | | | | | | | | 1055| 634|#define KRB5_CRYPTO_TYPE_HEADER 1 /**< [out] header */ | | | | | | ------------------ | | | | | | | Branch (424:33): [True: 0, False: 634] | | | | | | ------------------ | | | | ------------------ | | | | #define ENCRYPT_IOV(_iov) (ENCRYPT_CONF_IOV(_iov) || ENCRYPT_DATA_IOV(_iov)) | | | | ------------------ | | | | | | 426| 634|#define ENCRYPT_DATA_IOV(_iov) ((_iov)->flags == KRB5_CRYPTO_TYPE_DATA || \ | | | | | | ------------------ | | | | | | | | 1056| 1.26k|#define KRB5_CRYPTO_TYPE_DATA 2 /**< [in, out] plaintext */ | | | | | | ------------------ | | | | | | | Branch (426:34): [True: 634, False: 0] | | | | | | ------------------ | | | | | | 427| 634| (_iov)->flags == KRB5_CRYPTO_TYPE_PADDING) | | | | | | ------------------ | | | | | | | | 1058| 0|#define KRB5_CRYPTO_TYPE_PADDING 4 /**< [out] padding */ | | | | | | ------------------ | | | | | | | Branch (427:34): [True: 0, False: 0] | | | | | | ------------------ | | | | ------------------ | | ------------------ | | 432| 634| (_iov)->flags == KRB5_CRYPTO_TYPE_SIGN_ONLY ) | | ------------------ | | | | 1057| 0|#define KRB5_CRYPTO_TYPE_SIGN_ONLY 3 /**< [in] associated data */ | | ------------------ | | | Branch (432:34): [True: 0, False: 0] | | ------------------ ------------------ 47| 634| krb5int_MD5Update(&ctx, (unsigned char *) iov->data.data, 48| 634| iov->data.length); 49| 634| } 50| 634| } 51| 317| krb5int_MD5Final(&ctx); 52| | 53| 317| memcpy(output->data, ctx.digest, RSA_MD5_CKSUM_LENGTH); ------------------ | | 54| 317|#define RSA_MD5_CKSUM_LENGTH 16 ------------------ 54| | 55| 317| return 0; 56| 317|} krb5int_hmac_keyblock: 57| 119|{ 58| 119| unsigned char *xorkey = NULL, *ihash = NULL; 59| 119| unsigned int i; 60| 119| krb5_crypto_iov *ihash_iov = NULL, ohash_iov[2]; 61| 119| krb5_data hashout; 62| 119| krb5_error_code ret; 63| | 64| 119| if (keyblock->length > hash->blocksize) ------------------ | Branch (64:9): [True: 0, False: 119] ------------------ 65| 0| return KRB5_CRYPTO_INTERNAL; ------------------ | | 8831| 0|#define KRB5_CRYPTO_INTERNAL (-1765328206L) ------------------ 66| 119| if (output->length < hash->hashsize) ------------------ | Branch (66:9): [True: 0, False: 119] ------------------ 67| 0| return KRB5_BAD_MSIZE; ------------------ | | 8843| 0|#define KRB5_BAD_MSIZE (-1765328194L) ------------------ 68| | 69| | /* Allocate space for the xor key, hash input vector, and inner hash */ 70| 119| xorkey = k5alloc(hash->blocksize, &ret); 71| 119| if (xorkey == NULL) ------------------ | Branch (71:9): [True: 0, False: 119] ------------------ 72| 0| goto cleanup; 73| 119| ihash = k5alloc(hash->hashsize, &ret); 74| 119| if (ihash == NULL) ------------------ | Branch (74:9): [True: 0, False: 119] ------------------ 75| 0| goto cleanup; 76| 119| ihash_iov = k5calloc(num_data + 1, sizeof(krb5_crypto_iov), &ret); 77| 119| if (ihash_iov == NULL) ------------------ | Branch (77:9): [True: 0, False: 119] ------------------ 78| 0| goto cleanup; 79| | 80| | /* Create the inner padded key. */ 81| 119| memset(xorkey, 0x36, hash->blocksize); 82| 2.02k| for (i = 0; i < keyblock->length; i++) ------------------ | Branch (82:17): [True: 1.90k, False: 119] ------------------ 83| 1.90k| xorkey[i] ^= keyblock->contents[i]; 84| | 85| | /* Compute the inner hash over the inner key and input data. */ 86| 119| ihash_iov[0].flags = KRB5_CRYPTO_TYPE_DATA; ------------------ | | 1056| 119|#define KRB5_CRYPTO_TYPE_DATA 2 /**< [in, out] plaintext */ ------------------ 87| 119| ihash_iov[0].data = make_data(xorkey, hash->blocksize); 88| 119| memcpy(ihash_iov + 1, data, num_data * sizeof(krb5_crypto_iov)); 89| 119| hashout = make_data(ihash, hash->hashsize); 90| 119| ret = hash->hash(ihash_iov, num_data + 1, &hashout); 91| 119| if (ret != 0) ------------------ | Branch (91:9): [True: 0, False: 119] ------------------ 92| 0| goto cleanup; 93| | 94| | /* Create the outer padded key. */ 95| 119| memset(xorkey, 0x5c, hash->blocksize); 96| 2.02k| for (i = 0; i < keyblock->length; i++) ------------------ | Branch (96:17): [True: 1.90k, False: 119] ------------------ 97| 1.90k| xorkey[i] ^= keyblock->contents[i]; 98| | 99| | /* Compute the outer hash over the outer key and inner hash value. */ 100| 119| ohash_iov[0].flags = KRB5_CRYPTO_TYPE_DATA; ------------------ | | 1056| 119|#define KRB5_CRYPTO_TYPE_DATA 2 /**< [in, out] plaintext */ ------------------ 101| 119| ohash_iov[0].data = make_data(xorkey, hash->blocksize); 102| 119| ohash_iov[1].flags = KRB5_CRYPTO_TYPE_DATA; ------------------ | | 1056| 119|#define KRB5_CRYPTO_TYPE_DATA 2 /**< [in, out] plaintext */ ------------------ 103| 119| ohash_iov[1].data = make_data(ihash, hash->hashsize); 104| 119| output->length = hash->hashsize; 105| 119| ret = hash->hash(ohash_iov, 2, output); 106| 119| if (ret != 0) ------------------ | Branch (106:9): [True: 0, False: 119] ------------------ 107| 0| memset(output->data, 0, output->length); 108| | 109| 119|cleanup: 110| 119| zapfree(xorkey, hash->blocksize); 111| 119| zapfree(ihash, hash->hashsize); 112| 119| free(ihash_iov); 113| 119| return ret; 114| 119|} krb5int_hmac: 120| 40|{ 121| 40| return krb5int_hmac_keyblock(hash, &key->keyblock, data, num_data, output); 122| 40|} krb5int_MD5Init: 112| 317|{ 113| 317| mdContext->i[0] = mdContext->i[1] = (krb5_ui_4)0; 114| | 115| | /* Load magic initialization constants. 116| | */ 117| 317| mdContext->buf[0] = 0x67452301UL; 118| 317| mdContext->buf[1] = 0xefcdab89UL; 119| 317| mdContext->buf[2] = 0x98badcfeUL; 120| 317| mdContext->buf[3] = 0x10325476UL; 121| 317|} krb5int_MD5Update: 129| 951|{ 130| 951| krb5_ui_4 in[16]; 131| 951| int mdi; 132| 951| unsigned int i, ii; 133| | 134| | /* compute number of bytes mod 64 */ 135| 951| mdi = (int)((mdContext->i[0] >> 3) & 0x3F); 136| | 137| | /* update number of bits */ 138| 951| if ((mdContext->i[0] + ((krb5_ui_4)inLen << 3)) < mdContext->i[0]) ------------------ | Branch (138:9): [True: 0, False: 951] ------------------ 139| 0| mdContext->i[1]++; 140| 951| mdContext->i[0] += ((krb5_ui_4)inLen << 3); 141| 951| mdContext->i[1] += ((krb5_ui_4)inLen >> 29); 142| | 143| 62.2k| while (inLen--) { ------------------ | Branch (143:12): [True: 61.2k, False: 951] ------------------ 144| | /* add new character to buffer, increment mdi */ 145| 61.2k| mdContext->in[mdi++] = *inBuf++; 146| | 147| | /* transform if necessary */ 148| 61.2k| if (mdi == 0x40) { ------------------ | Branch (148:13): [True: 680, False: 60.5k] ------------------ 149| 11.5k| for (i = 0, ii = 0; i < 16; i++, ii += 4) ------------------ | Branch (149:33): [True: 10.8k, False: 680] ------------------ 150| 10.8k| in[i] = load_32_le(mdContext->in+ii); 151| 680| Transform (mdContext->buf, in); 152| 680| mdi = 0; 153| 680| } 154| 61.2k| } 155| 951|} krb5int_MD5Final: 162| 317|{ 163| 317| krb5_ui_4 in[16]; 164| 317| int mdi; 165| 317| unsigned int i, ii; 166| 317| unsigned int padLen; 167| | 168| | /* save number of bits */ 169| 317| in[14] = mdContext->i[0]; 170| 317| in[15] = mdContext->i[1]; 171| | 172| | /* compute number of bytes mod 64 */ 173| 317| mdi = (int)((mdContext->i[0] >> 3) & 0x3F); 174| | 175| | /* pad out to 56 mod 64 */ 176| 317| padLen = (mdi < 56) ? (56 - mdi) : (120 - mdi); ------------------ | Branch (176:14): [True: 301, False: 16] ------------------ 177| 317| krb5int_MD5Update (mdContext, PADDING, padLen); 178| | 179| | /* append length in bits and transform */ 180| 4.75k| for (i = 0, ii = 0; i < 14; i++, ii += 4) ------------------ | Branch (180:25): [True: 4.43k, False: 317] ------------------ 181| 4.43k| in[i] = load_32_le(mdContext->in+ii); 182| 317| Transform (mdContext->buf, in); 183| | 184| | /* store buffer in digest */ 185| 1.58k| for (i = 0, ii = 0; i < 4; i++, ii += 4) { ------------------ | Branch (185:25): [True: 1.26k, False: 317] ------------------ 186| 1.26k| store_32_le(mdContext->buf[i], mdContext->digest+ii); 187| 1.26k| } 188| 317|} md5.c:Transform: 193| 997|{ 194| 997| krb5_ui_4 a = buf[0], b = buf[1], c = buf[2], d = buf[3]; 195| | 196| |#if defined(CONFIG_SMALL) && !defined(CONFIG_SMALL_NO_CRYPTO) 197| | 198| | int i; 199| |#define ROTATE { krb5_ui_4 temp; temp = d, d = c, c = b, b = a, a = temp; } 200| | for (i = 0; i < 16; i++) { 201| | const unsigned char round1s[] = { 7, 12, 17, 22 }; 202| | const krb5_ui_4 round1consts[] = { 203| | 3614090360UL, 3905402710UL, 606105819UL, 3250441966UL, 204| | 4118548399UL, 1200080426UL, 2821735955UL, 4249261313UL, 205| | 1770035416UL, 2336552879UL, 4294925233UL, 2304563134UL, 206| | 1804603682UL, 4254626195UL, 2792965006UL, 1236535329UL, 207| | }; 208| | FF (a, b, c, d, in[i], round1s[i%4], round1consts[i]); 209| | ROTATE; 210| | } 211| | for (i = 0; i < 16; i++) { 212| | const unsigned char round2s[] = { 5, 9, 14, 20 }; 213| | const krb5_ui_4 round2consts[] = { 214| | 4129170786UL, 3225465664UL, 643717713UL, 3921069994UL, 215| | 3593408605UL, 38016083UL, 3634488961UL, 3889429448UL, 216| | 568446438UL, 3275163606UL, 4107603335UL, 1163531501UL, 217| | 2850285829UL, 4243563512UL, 1735328473UL, 2368359562UL, 218| | }; 219| | int r2index = (1 + i * 5) % 16; 220| | GG (a, b, c, d, in[r2index], round2s[i%4], round2consts[i]); 221| | ROTATE; 222| | } 223| | for (i = 0; i < 16; i++) { 224| | static const unsigned char round3s[] = { 4, 11, 16, 23 }; 225| | static const krb5_ui_4 round3consts[] = { 226| | 4294588738UL, 2272392833UL, 1839030562UL, 4259657740UL, 227| | 2763975236UL, 1272893353UL, 4139469664UL, 3200236656UL, 228| | 681279174UL, 3936430074UL, 3572445317UL, 76029189UL, 229| | 3654602809UL, 3873151461UL, 530742520UL, 3299628645UL, 230| | }; 231| | int r3index = (5 + i * 3) % 16; 232| | HH (a, b, c, d, in[r3index], round3s[i%4], round3consts[i]); 233| | ROTATE; 234| | } 235| | for (i = 0; i < 16; i++) { 236| | static const unsigned char round4s[] = { 6, 10, 15, 21 }; 237| | static const krb5_ui_4 round4consts[] = { 238| | 4096336452UL, 1126891415UL, 2878612391UL, 4237533241UL, 239| | 1700485571UL, 2399980690UL, 4293915773UL, 2240044497UL, 240| | 1873313359UL, 4264355552UL, 2734768916UL, 1309151649UL, 241| | 4149444226UL, 3174756917UL, 718787259UL, 3951481745UL, 242| | }; 243| | int r4index = (7 * i) % 16; 244| | II (a, b, c, d, in[r4index], round4s[i%4], round4consts[i]); 245| | ROTATE; 246| | } 247| | 248| |#else 249| | 250| | /* Round 1 */ 251| 997|#define S11 7 252| 997|#define S12 12 253| 997|#define S13 17 254| 997|#define S14 22 255| 997| FF ( a, b, c, d, in[ 0], S11, 3614090360UL); /* 1 */ ------------------ | | 79| 997| {(a) += F ((b), (c), (d)) + (x) + (krb5_ui_4)(ac); \ | | ------------------ | | | | 68| 997|#define F(x, y, z) (((x) & (y)) | ((~x) & (z))) | | ------------------ | | 80| 997| (a) &= 0xffffffff; \ | | 81| 997| (a) = ROTATE_LEFT ((a), (s)); \ | | ------------------ | | | | 74| 997|#define ROTATE_LEFT(x, n) ((((x) << (n)) & 0xffffffff) | ((x) >> (32-(n)))) | | ------------------ | | 82| 997| (a) += (b); \ | | 83| 997| (a) &= 0xffffffff; \ | | 84| 997| } ------------------ 256| 997| FF ( d, a, b, c, in[ 1], S12, 3905402710UL); /* 2 */ ------------------ | | 79| 997| {(a) += F ((b), (c), (d)) + (x) + (krb5_ui_4)(ac); \ | | ------------------ | | | | 68| 997|#define F(x, y, z) (((x) & (y)) | ((~x) & (z))) | | ------------------ | | 80| 997| (a) &= 0xffffffff; \ | | 81| 997| (a) = ROTATE_LEFT ((a), (s)); \ | | ------------------ | | | | 74| 997|#define ROTATE_LEFT(x, n) ((((x) << (n)) & 0xffffffff) | ((x) >> (32-(n)))) | | ------------------ | | 82| 997| (a) += (b); \ | | 83| 997| (a) &= 0xffffffff; \ | | 84| 997| } ------------------ 257| 997| FF ( c, d, a, b, in[ 2], S13, 606105819UL); /* 3 */ ------------------ | | 79| 997| {(a) += F ((b), (c), (d)) + (x) + (krb5_ui_4)(ac); \ | | ------------------ | | | | 68| 997|#define F(x, y, z) (((x) & (y)) | ((~x) & (z))) | | ------------------ | | 80| 997| (a) &= 0xffffffff; \ | | 81| 997| (a) = ROTATE_LEFT ((a), (s)); \ | | ------------------ | | | | 74| 997|#define ROTATE_LEFT(x, n) ((((x) << (n)) & 0xffffffff) | ((x) >> (32-(n)))) | | ------------------ | | 82| 997| (a) += (b); \ | | 83| 997| (a) &= 0xffffffff; \ | | 84| 997| } ------------------ 258| 997| FF ( b, c, d, a, in[ 3], S14, 3250441966UL); /* 4 */ ------------------ | | 79| 997| {(a) += F ((b), (c), (d)) + (x) + (krb5_ui_4)(ac); \ | | ------------------ | | | | 68| 997|#define F(x, y, z) (((x) & (y)) | ((~x) & (z))) | | ------------------ | | 80| 997| (a) &= 0xffffffff; \ | | 81| 997| (a) = ROTATE_LEFT ((a), (s)); \ | | ------------------ | | | | 74| 997|#define ROTATE_LEFT(x, n) ((((x) << (n)) & 0xffffffff) | ((x) >> (32-(n)))) | | ------------------ | | 82| 997| (a) += (b); \ | | 83| 997| (a) &= 0xffffffff; \ | | 84| 997| } ------------------ 259| 997| FF ( a, b, c, d, in[ 4], S11, 4118548399UL); /* 5 */ ------------------ | | 79| 997| {(a) += F ((b), (c), (d)) + (x) + (krb5_ui_4)(ac); \ | | ------------------ | | | | 68| 997|#define F(x, y, z) (((x) & (y)) | ((~x) & (z))) | | ------------------ | | 80| 997| (a) &= 0xffffffff; \ | | 81| 997| (a) = ROTATE_LEFT ((a), (s)); \ | | ------------------ | | | | 74| 997|#define ROTATE_LEFT(x, n) ((((x) << (n)) & 0xffffffff) | ((x) >> (32-(n)))) | | ------------------ | | 82| 997| (a) += (b); \ | | 83| 997| (a) &= 0xffffffff; \ | | 84| 997| } ------------------ 260| 997| FF ( d, a, b, c, in[ 5], S12, 1200080426UL); /* 6 */ ------------------ | | 79| 997| {(a) += F ((b), (c), (d)) + (x) + (krb5_ui_4)(ac); \ | | ------------------ | | | | 68| 997|#define F(x, y, z) (((x) & (y)) | ((~x) & (z))) | | ------------------ | | 80| 997| (a) &= 0xffffffff; \ | | 81| 997| (a) = ROTATE_LEFT ((a), (s)); \ | | ------------------ | | | | 74| 997|#define ROTATE_LEFT(x, n) ((((x) << (n)) & 0xffffffff) | ((x) >> (32-(n)))) | | ------------------ | | 82| 997| (a) += (b); \ | | 83| 997| (a) &= 0xffffffff; \ | | 84| 997| } ------------------ 261| 997| FF ( c, d, a, b, in[ 6], S13, 2821735955UL); /* 7 */ ------------------ | | 79| 997| {(a) += F ((b), (c), (d)) + (x) + (krb5_ui_4)(ac); \ | | ------------------ | | | | 68| 997|#define F(x, y, z) (((x) & (y)) | ((~x) & (z))) | | ------------------ | | 80| 997| (a) &= 0xffffffff; \ | | 81| 997| (a) = ROTATE_LEFT ((a), (s)); \ | | ------------------ | | | | 74| 997|#define ROTATE_LEFT(x, n) ((((x) << (n)) & 0xffffffff) | ((x) >> (32-(n)))) | | ------------------ | | 82| 997| (a) += (b); \ | | 83| 997| (a) &= 0xffffffff; \ | | 84| 997| } ------------------ 262| 997| FF ( b, c, d, a, in[ 7], S14, 4249261313UL); /* 8 */ ------------------ | | 79| 997| {(a) += F ((b), (c), (d)) + (x) + (krb5_ui_4)(ac); \ | | ------------------ | | | | 68| 997|#define F(x, y, z) (((x) & (y)) | ((~x) & (z))) | | ------------------ | | 80| 997| (a) &= 0xffffffff; \ | | 81| 997| (a) = ROTATE_LEFT ((a), (s)); \ | | ------------------ | | | | 74| 997|#define ROTATE_LEFT(x, n) ((((x) << (n)) & 0xffffffff) | ((x) >> (32-(n)))) | | ------------------ | | 82| 997| (a) += (b); \ | | 83| 997| (a) &= 0xffffffff; \ | | 84| 997| } ------------------ 263| 997| FF ( a, b, c, d, in[ 8], S11, 1770035416UL); /* 9 */ ------------------ | | 79| 997| {(a) += F ((b), (c), (d)) + (x) + (krb5_ui_4)(ac); \ | | ------------------ | | | | 68| 997|#define F(x, y, z) (((x) & (y)) | ((~x) & (z))) | | ------------------ | | 80| 997| (a) &= 0xffffffff; \ | | 81| 997| (a) = ROTATE_LEFT ((a), (s)); \ | | ------------------ | | | | 74| 997|#define ROTATE_LEFT(x, n) ((((x) << (n)) & 0xffffffff) | ((x) >> (32-(n)))) | | ------------------ | | 82| 997| (a) += (b); \ | | 83| 997| (a) &= 0xffffffff; \ | | 84| 997| } ------------------ 264| 997| FF ( d, a, b, c, in[ 9], S12, 2336552879UL); /* 10 */ ------------------ | | 79| 997| {(a) += F ((b), (c), (d)) + (x) + (krb5_ui_4)(ac); \ | | ------------------ | | | | 68| 997|#define F(x, y, z) (((x) & (y)) | ((~x) & (z))) | | ------------------ | | 80| 997| (a) &= 0xffffffff; \ | | 81| 997| (a) = ROTATE_LEFT ((a), (s)); \ | | ------------------ | | | | 74| 997|#define ROTATE_LEFT(x, n) ((((x) << (n)) & 0xffffffff) | ((x) >> (32-(n)))) | | ------------------ | | 82| 997| (a) += (b); \ | | 83| 997| (a) &= 0xffffffff; \ | | 84| 997| } ------------------ 265| 997| FF ( c, d, a, b, in[10], S13, 4294925233UL); /* 11 */ ------------------ | | 79| 997| {(a) += F ((b), (c), (d)) + (x) + (krb5_ui_4)(ac); \ | | ------------------ | | | | 68| 997|#define F(x, y, z) (((x) & (y)) | ((~x) & (z))) | | ------------------ | | 80| 997| (a) &= 0xffffffff; \ | | 81| 997| (a) = ROTATE_LEFT ((a), (s)); \ | | ------------------ | | | | 74| 997|#define ROTATE_LEFT(x, n) ((((x) << (n)) & 0xffffffff) | ((x) >> (32-(n)))) | | ------------------ | | 82| 997| (a) += (b); \ | | 83| 997| (a) &= 0xffffffff; \ | | 84| 997| } ------------------ 266| 997| FF ( b, c, d, a, in[11], S14, 2304563134UL); /* 12 */ ------------------ | | 79| 997| {(a) += F ((b), (c), (d)) + (x) + (krb5_ui_4)(ac); \ | | ------------------ | | | | 68| 997|#define F(x, y, z) (((x) & (y)) | ((~x) & (z))) | | ------------------ | | 80| 997| (a) &= 0xffffffff; \ | | 81| 997| (a) = ROTATE_LEFT ((a), (s)); \ | | ------------------ | | | | 74| 997|#define ROTATE_LEFT(x, n) ((((x) << (n)) & 0xffffffff) | ((x) >> (32-(n)))) | | ------------------ | | 82| 997| (a) += (b); \ | | 83| 997| (a) &= 0xffffffff; \ | | 84| 997| } ------------------ 267| 997| FF ( a, b, c, d, in[12], S11, 1804603682UL); /* 13 */ ------------------ | | 79| 997| {(a) += F ((b), (c), (d)) + (x) + (krb5_ui_4)(ac); \ | | ------------------ | | | | 68| 997|#define F(x, y, z) (((x) & (y)) | ((~x) & (z))) | | ------------------ | | 80| 997| (a) &= 0xffffffff; \ | | 81| 997| (a) = ROTATE_LEFT ((a), (s)); \ | | ------------------ | | | | 74| 997|#define ROTATE_LEFT(x, n) ((((x) << (n)) & 0xffffffff) | ((x) >> (32-(n)))) | | ------------------ | | 82| 997| (a) += (b); \ | | 83| 997| (a) &= 0xffffffff; \ | | 84| 997| } ------------------ 268| 997| FF ( d, a, b, c, in[13], S12, 4254626195UL); /* 14 */ ------------------ | | 79| 997| {(a) += F ((b), (c), (d)) + (x) + (krb5_ui_4)(ac); \ | | ------------------ | | | | 68| 997|#define F(x, y, z) (((x) & (y)) | ((~x) & (z))) | | ------------------ | | 80| 997| (a) &= 0xffffffff; \ | | 81| 997| (a) = ROTATE_LEFT ((a), (s)); \ | | ------------------ | | | | 74| 997|#define ROTATE_LEFT(x, n) ((((x) << (n)) & 0xffffffff) | ((x) >> (32-(n)))) | | ------------------ | | 82| 997| (a) += (b); \ | | 83| 997| (a) &= 0xffffffff; \ | | 84| 997| } ------------------ 269| 997| FF ( c, d, a, b, in[14], S13, 2792965006UL); /* 15 */ ------------------ | | 79| 997| {(a) += F ((b), (c), (d)) + (x) + (krb5_ui_4)(ac); \ | | ------------------ | | | | 68| 997|#define F(x, y, z) (((x) & (y)) | ((~x) & (z))) | | ------------------ | | 80| 997| (a) &= 0xffffffff; \ | | 81| 997| (a) = ROTATE_LEFT ((a), (s)); \ | | ------------------ | | | | 74| 997|#define ROTATE_LEFT(x, n) ((((x) << (n)) & 0xffffffff) | ((x) >> (32-(n)))) | | ------------------ | | 82| 997| (a) += (b); \ | | 83| 997| (a) &= 0xffffffff; \ | | 84| 997| } ------------------ 270| 997| FF ( b, c, d, a, in[15], S14, 1236535329UL); /* 16 */ ------------------ | | 79| 997| {(a) += F ((b), (c), (d)) + (x) + (krb5_ui_4)(ac); \ | | ------------------ | | | | 68| 997|#define F(x, y, z) (((x) & (y)) | ((~x) & (z))) | | ------------------ | | 80| 997| (a) &= 0xffffffff; \ | | 81| 997| (a) = ROTATE_LEFT ((a), (s)); \ | | ------------------ | | | | 74| 997|#define ROTATE_LEFT(x, n) ((((x) << (n)) & 0xffffffff) | ((x) >> (32-(n)))) | | ------------------ | | 82| 997| (a) += (b); \ | | 83| 997| (a) &= 0xffffffff; \ | | 84| 997| } ------------------ 271| | 272| | /* Round 2 */ 273| 997|#define S21 5 274| 997|#define S22 9 275| 997|#define S23 14 276| 997|#define S24 20 277| 997| GG ( a, b, c, d, in[ 1], S21, 4129170786UL); /* 17 */ ------------------ | | 86| 997| {(a) += G ((b), (c), (d)) + (x) + (krb5_ui_4)(ac); \ | | ------------------ | | | | 69| 997|#define G(x, y, z) (((x) & (z)) | ((y) & (~z))) | | ------------------ | | 87| 997| (a) &= 0xffffffff; \ | | 88| 997| (a) = ROTATE_LEFT ((a), (s)); \ | | ------------------ | | | | 74| 997|#define ROTATE_LEFT(x, n) ((((x) << (n)) & 0xffffffff) | ((x) >> (32-(n)))) | | ------------------ | | 89| 997| (a) += (b); \ | | 90| 997| (a) &= 0xffffffff; \ | | 91| 997| } ------------------ 278| 997| GG ( d, a, b, c, in[ 6], S22, 3225465664UL); /* 18 */ ------------------ | | 86| 997| {(a) += G ((b), (c), (d)) + (x) + (krb5_ui_4)(ac); \ | | ------------------ | | | | 69| 997|#define G(x, y, z) (((x) & (z)) | ((y) & (~z))) | | ------------------ | | 87| 997| (a) &= 0xffffffff; \ | | 88| 997| (a) = ROTATE_LEFT ((a), (s)); \ | | ------------------ | | | | 74| 997|#define ROTATE_LEFT(x, n) ((((x) << (n)) & 0xffffffff) | ((x) >> (32-(n)))) | | ------------------ | | 89| 997| (a) += (b); \ | | 90| 997| (a) &= 0xffffffff; \ | | 91| 997| } ------------------ 279| 997| GG ( c, d, a, b, in[11], S23, 643717713UL); /* 19 */ ------------------ | | 86| 997| {(a) += G ((b), (c), (d)) + (x) + (krb5_ui_4)(ac); \ | | ------------------ | | | | 69| 997|#define G(x, y, z) (((x) & (z)) | ((y) & (~z))) | | ------------------ | | 87| 997| (a) &= 0xffffffff; \ | | 88| 997| (a) = ROTATE_LEFT ((a), (s)); \ | | ------------------ | | | | 74| 997|#define ROTATE_LEFT(x, n) ((((x) << (n)) & 0xffffffff) | ((x) >> (32-(n)))) | | ------------------ | | 89| 997| (a) += (b); \ | | 90| 997| (a) &= 0xffffffff; \ | | 91| 997| } ------------------ 280| 997| GG ( b, c, d, a, in[ 0], S24, 3921069994UL); /* 20 */ ------------------ | | 86| 997| {(a) += G ((b), (c), (d)) + (x) + (krb5_ui_4)(ac); \ | | ------------------ | | | | 69| 997|#define G(x, y, z) (((x) & (z)) | ((y) & (~z))) | | ------------------ | | 87| 997| (a) &= 0xffffffff; \ | | 88| 997| (a) = ROTATE_LEFT ((a), (s)); \ | | ------------------ | | | | 74| 997|#define ROTATE_LEFT(x, n) ((((x) << (n)) & 0xffffffff) | ((x) >> (32-(n)))) | | ------------------ | | 89| 997| (a) += (b); \ | | 90| 997| (a) &= 0xffffffff; \ | | 91| 997| } ------------------ 281| 997| GG ( a, b, c, d, in[ 5], S21, 3593408605UL); /* 21 */ ------------------ | | 86| 997| {(a) += G ((b), (c), (d)) + (x) + (krb5_ui_4)(ac); \ | | ------------------ | | | | 69| 997|#define G(x, y, z) (((x) & (z)) | ((y) & (~z))) | | ------------------ | | 87| 997| (a) &= 0xffffffff; \ | | 88| 997| (a) = ROTATE_LEFT ((a), (s)); \ | | ------------------ | | | | 74| 997|#define ROTATE_LEFT(x, n) ((((x) << (n)) & 0xffffffff) | ((x) >> (32-(n)))) | | ------------------ | | 89| 997| (a) += (b); \ | | 90| 997| (a) &= 0xffffffff; \ | | 91| 997| } ------------------ 282| 997| GG ( d, a, b, c, in[10], S22, 38016083UL); /* 22 */ ------------------ | | 86| 997| {(a) += G ((b), (c), (d)) + (x) + (krb5_ui_4)(ac); \ | | ------------------ | | | | 69| 997|#define G(x, y, z) (((x) & (z)) | ((y) & (~z))) | | ------------------ | | 87| 997| (a) &= 0xffffffff; \ | | 88| 997| (a) = ROTATE_LEFT ((a), (s)); \ | | ------------------ | | | | 74| 997|#define ROTATE_LEFT(x, n) ((((x) << (n)) & 0xffffffff) | ((x) >> (32-(n)))) | | ------------------ | | 89| 997| (a) += (b); \ | | 90| 997| (a) &= 0xffffffff; \ | | 91| 997| } ------------------ 283| 997| GG ( c, d, a, b, in[15], S23, 3634488961UL); /* 23 */ ------------------ | | 86| 997| {(a) += G ((b), (c), (d)) + (x) + (krb5_ui_4)(ac); \ | | ------------------ | | | | 69| 997|#define G(x, y, z) (((x) & (z)) | ((y) & (~z))) | | ------------------ | | 87| 997| (a) &= 0xffffffff; \ | | 88| 997| (a) = ROTATE_LEFT ((a), (s)); \ | | ------------------ | | | | 74| 997|#define ROTATE_LEFT(x, n) ((((x) << (n)) & 0xffffffff) | ((x) >> (32-(n)))) | | ------------------ | | 89| 997| (a) += (b); \ | | 90| 997| (a) &= 0xffffffff; \ | | 91| 997| } ------------------ 284| 997| GG ( b, c, d, a, in[ 4], S24, 3889429448UL); /* 24 */ ------------------ | | 86| 997| {(a) += G ((b), (c), (d)) + (x) + (krb5_ui_4)(ac); \ | | ------------------ | | | | 69| 997|#define G(x, y, z) (((x) & (z)) | ((y) & (~z))) | | ------------------ | | 87| 997| (a) &= 0xffffffff; \ | | 88| 997| (a) = ROTATE_LEFT ((a), (s)); \ | | ------------------ | | | | 74| 997|#define ROTATE_LEFT(x, n) ((((x) << (n)) & 0xffffffff) | ((x) >> (32-(n)))) | | ------------------ | | 89| 997| (a) += (b); \ | | 90| 997| (a) &= 0xffffffff; \ | | 91| 997| } ------------------ 285| 997| GG ( a, b, c, d, in[ 9], S21, 568446438UL); /* 25 */ ------------------ | | 86| 997| {(a) += G ((b), (c), (d)) + (x) + (krb5_ui_4)(ac); \ | | ------------------ | | | | 69| 997|#define G(x, y, z) (((x) & (z)) | ((y) & (~z))) | | ------------------ | | 87| 997| (a) &= 0xffffffff; \ | | 88| 997| (a) = ROTATE_LEFT ((a), (s)); \ | | ------------------ | | | | 74| 997|#define ROTATE_LEFT(x, n) ((((x) << (n)) & 0xffffffff) | ((x) >> (32-(n)))) | | ------------------ | | 89| 997| (a) += (b); \ | | 90| 997| (a) &= 0xffffffff; \ | | 91| 997| } ------------------ 286| 997| GG ( d, a, b, c, in[14], S22, 3275163606UL); /* 26 */ ------------------ | | 86| 997| {(a) += G ((b), (c), (d)) + (x) + (krb5_ui_4)(ac); \ | | ------------------ | | | | 69| 997|#define G(x, y, z) (((x) & (z)) | ((y) & (~z))) | | ------------------ | | 87| 997| (a) &= 0xffffffff; \ | | 88| 997| (a) = ROTATE_LEFT ((a), (s)); \ | | ------------------ | | | | 74| 997|#define ROTATE_LEFT(x, n) ((((x) << (n)) & 0xffffffff) | ((x) >> (32-(n)))) | | ------------------ | | 89| 997| (a) += (b); \ | | 90| 997| (a) &= 0xffffffff; \ | | 91| 997| } ------------------ 287| 997| GG ( c, d, a, b, in[ 3], S23, 4107603335UL); /* 27 */ ------------------ | | 86| 997| {(a) += G ((b), (c), (d)) + (x) + (krb5_ui_4)(ac); \ | | ------------------ | | | | 69| 997|#define G(x, y, z) (((x) & (z)) | ((y) & (~z))) | | ------------------ | | 87| 997| (a) &= 0xffffffff; \ | | 88| 997| (a) = ROTATE_LEFT ((a), (s)); \ | | ------------------ | | | | 74| 997|#define ROTATE_LEFT(x, n) ((((x) << (n)) & 0xffffffff) | ((x) >> (32-(n)))) | | ------------------ | | 89| 997| (a) += (b); \ | | 90| 997| (a) &= 0xffffffff; \ | | 91| 997| } ------------------ 288| 997| GG ( b, c, d, a, in[ 8], S24, 1163531501UL); /* 28 */ ------------------ | | 86| 997| {(a) += G ((b), (c), (d)) + (x) + (krb5_ui_4)(ac); \ | | ------------------ | | | | 69| 997|#define G(x, y, z) (((x) & (z)) | ((y) & (~z))) | | ------------------ | | 87| 997| (a) &= 0xffffffff; \ | | 88| 997| (a) = ROTATE_LEFT ((a), (s)); \ | | ------------------ | | | | 74| 997|#define ROTATE_LEFT(x, n) ((((x) << (n)) & 0xffffffff) | ((x) >> (32-(n)))) | | ------------------ | | 89| 997| (a) += (b); \ | | 90| 997| (a) &= 0xffffffff; \ | | 91| 997| } ------------------ 289| 997| GG ( a, b, c, d, in[13], S21, 2850285829UL); /* 29 */ ------------------ | | 86| 997| {(a) += G ((b), (c), (d)) + (x) + (krb5_ui_4)(ac); \ | | ------------------ | | | | 69| 997|#define G(x, y, z) (((x) & (z)) | ((y) & (~z))) | | ------------------ | | 87| 997| (a) &= 0xffffffff; \ | | 88| 997| (a) = ROTATE_LEFT ((a), (s)); \ | | ------------------ | | | | 74| 997|#define ROTATE_LEFT(x, n) ((((x) << (n)) & 0xffffffff) | ((x) >> (32-(n)))) | | ------------------ | | 89| 997| (a) += (b); \ | | 90| 997| (a) &= 0xffffffff; \ | | 91| 997| } ------------------ 290| 997| GG ( d, a, b, c, in[ 2], S22, 4243563512UL); /* 30 */ ------------------ | | 86| 997| {(a) += G ((b), (c), (d)) + (x) + (krb5_ui_4)(ac); \ | | ------------------ | | | | 69| 997|#define G(x, y, z) (((x) & (z)) | ((y) & (~z))) | | ------------------ | | 87| 997| (a) &= 0xffffffff; \ | | 88| 997| (a) = ROTATE_LEFT ((a), (s)); \ | | ------------------ | | | | 74| 997|#define ROTATE_LEFT(x, n) ((((x) << (n)) & 0xffffffff) | ((x) >> (32-(n)))) | | ------------------ | | 89| 997| (a) += (b); \ | | 90| 997| (a) &= 0xffffffff; \ | | 91| 997| } ------------------ 291| 997| GG ( c, d, a, b, in[ 7], S23, 1735328473UL); /* 31 */ ------------------ | | 86| 997| {(a) += G ((b), (c), (d)) + (x) + (krb5_ui_4)(ac); \ | | ------------------ | | | | 69| 997|#define G(x, y, z) (((x) & (z)) | ((y) & (~z))) | | ------------------ | | 87| 997| (a) &= 0xffffffff; \ | | 88| 997| (a) = ROTATE_LEFT ((a), (s)); \ | | ------------------ | | | | 74| 997|#define ROTATE_LEFT(x, n) ((((x) << (n)) & 0xffffffff) | ((x) >> (32-(n)))) | | ------------------ | | 89| 997| (a) += (b); \ | | 90| 997| (a) &= 0xffffffff; \ | | 91| 997| } ------------------ 292| 997| GG ( b, c, d, a, in[12], S24, 2368359562UL); /* 32 */ ------------------ | | 86| 997| {(a) += G ((b), (c), (d)) + (x) + (krb5_ui_4)(ac); \ | | ------------------ | | | | 69| 997|#define G(x, y, z) (((x) & (z)) | ((y) & (~z))) | | ------------------ | | 87| 997| (a) &= 0xffffffff; \ | | 88| 997| (a) = ROTATE_LEFT ((a), (s)); \ | | ------------------ | | | | 74| 997|#define ROTATE_LEFT(x, n) ((((x) << (n)) & 0xffffffff) | ((x) >> (32-(n)))) | | ------------------ | | 89| 997| (a) += (b); \ | | 90| 997| (a) &= 0xffffffff; \ | | 91| 997| } ------------------ 293| | 294| | /* Round 3 */ 295| 997|#define S31 4 296| 997|#define S32 11 297| 997|#define S33 16 298| 997|#define S34 23 299| 997| HH ( a, b, c, d, in[ 5], S31, 4294588738UL); /* 33 */ ------------------ | | 93| 997| {(a) += H ((b), (c), (d)) + (x) + (krb5_ui_4)(ac); \ | | ------------------ | | | | 70| 997|#define H(x, y, z) ((x) ^ (y) ^ (z)) | | ------------------ | | 94| 997| (a) &= 0xffffffff; \ | | 95| 997| (a) = ROTATE_LEFT ((a), (s)); \ | | ------------------ | | | | 74| 997|#define ROTATE_LEFT(x, n) ((((x) << (n)) & 0xffffffff) | ((x) >> (32-(n)))) | | ------------------ | | 96| 997| (a) += (b); \ | | 97| 997| (a) &= 0xffffffff; \ | | 98| 997| } ------------------ 300| 997| HH ( d, a, b, c, in[ 8], S32, 2272392833UL); /* 34 */ ------------------ | | 93| 997| {(a) += H ((b), (c), (d)) + (x) + (krb5_ui_4)(ac); \ | | ------------------ | | | | 70| 997|#define H(x, y, z) ((x) ^ (y) ^ (z)) | | ------------------ | | 94| 997| (a) &= 0xffffffff; \ | | 95| 997| (a) = ROTATE_LEFT ((a), (s)); \ | | ------------------ | | | | 74| 997|#define ROTATE_LEFT(x, n) ((((x) << (n)) & 0xffffffff) | ((x) >> (32-(n)))) | | ------------------ | | 96| 997| (a) += (b); \ | | 97| 997| (a) &= 0xffffffff; \ | | 98| 997| } ------------------ 301| 997| HH ( c, d, a, b, in[11], S33, 1839030562UL); /* 35 */ ------------------ | | 93| 997| {(a) += H ((b), (c), (d)) + (x) + (krb5_ui_4)(ac); \ | | ------------------ | | | | 70| 997|#define H(x, y, z) ((x) ^ (y) ^ (z)) | | ------------------ | | 94| 997| (a) &= 0xffffffff; \ | | 95| 997| (a) = ROTATE_LEFT ((a), (s)); \ | | ------------------ | | | | 74| 997|#define ROTATE_LEFT(x, n) ((((x) << (n)) & 0xffffffff) | ((x) >> (32-(n)))) | | ------------------ | | 96| 997| (a) += (b); \ | | 97| 997| (a) &= 0xffffffff; \ | | 98| 997| } ------------------ 302| 997| HH ( b, c, d, a, in[14], S34, 4259657740UL); /* 36 */ ------------------ | | 93| 997| {(a) += H ((b), (c), (d)) + (x) + (krb5_ui_4)(ac); \ | | ------------------ | | | | 70| 997|#define H(x, y, z) ((x) ^ (y) ^ (z)) | | ------------------ | | 94| 997| (a) &= 0xffffffff; \ | | 95| 997| (a) = ROTATE_LEFT ((a), (s)); \ | | ------------------ | | | | 74| 997|#define ROTATE_LEFT(x, n) ((((x) << (n)) & 0xffffffff) | ((x) >> (32-(n)))) | | ------------------ | | 96| 997| (a) += (b); \ | | 97| 997| (a) &= 0xffffffff; \ | | 98| 997| } ------------------ 303| 997| HH ( a, b, c, d, in[ 1], S31, 2763975236UL); /* 37 */ ------------------ | | 93| 997| {(a) += H ((b), (c), (d)) + (x) + (krb5_ui_4)(ac); \ | | ------------------ | | | | 70| 997|#define H(x, y, z) ((x) ^ (y) ^ (z)) | | ------------------ | | 94| 997| (a) &= 0xffffffff; \ | | 95| 997| (a) = ROTATE_LEFT ((a), (s)); \ | | ------------------ | | | | 74| 997|#define ROTATE_LEFT(x, n) ((((x) << (n)) & 0xffffffff) | ((x) >> (32-(n)))) | | ------------------ | | 96| 997| (a) += (b); \ | | 97| 997| (a) &= 0xffffffff; \ | | 98| 997| } ------------------ 304| 997| HH ( d, a, b, c, in[ 4], S32, 1272893353UL); /* 38 */ ------------------ | | 93| 997| {(a) += H ((b), (c), (d)) + (x) + (krb5_ui_4)(ac); \ | | ------------------ | | | | 70| 997|#define H(x, y, z) ((x) ^ (y) ^ (z)) | | ------------------ | | 94| 997| (a) &= 0xffffffff; \ | | 95| 997| (a) = ROTATE_LEFT ((a), (s)); \ | | ------------------ | | | | 74| 997|#define ROTATE_LEFT(x, n) ((((x) << (n)) & 0xffffffff) | ((x) >> (32-(n)))) | | ------------------ | | 96| 997| (a) += (b); \ | | 97| 997| (a) &= 0xffffffff; \ | | 98| 997| } ------------------ 305| 997| HH ( c, d, a, b, in[ 7], S33, 4139469664UL); /* 39 */ ------------------ | | 93| 997| {(a) += H ((b), (c), (d)) + (x) + (krb5_ui_4)(ac); \ | | ------------------ | | | | 70| 997|#define H(x, y, z) ((x) ^ (y) ^ (z)) | | ------------------ | | 94| 997| (a) &= 0xffffffff; \ | | 95| 997| (a) = ROTATE_LEFT ((a), (s)); \ | | ------------------ | | | | 74| 997|#define ROTATE_LEFT(x, n) ((((x) << (n)) & 0xffffffff) | ((x) >> (32-(n)))) | | ------------------ | | 96| 997| (a) += (b); \ | | 97| 997| (a) &= 0xffffffff; \ | | 98| 997| } ------------------ 306| 997| HH ( b, c, d, a, in[10], S34, 3200236656UL); /* 40 */ ------------------ | | 93| 997| {(a) += H ((b), (c), (d)) + (x) + (krb5_ui_4)(ac); \ | | ------------------ | | | | 70| 997|#define H(x, y, z) ((x) ^ (y) ^ (z)) | | ------------------ | | 94| 997| (a) &= 0xffffffff; \ | | 95| 997| (a) = ROTATE_LEFT ((a), (s)); \ | | ------------------ | | | | 74| 997|#define ROTATE_LEFT(x, n) ((((x) << (n)) & 0xffffffff) | ((x) >> (32-(n)))) | | ------------------ | | 96| 997| (a) += (b); \ | | 97| 997| (a) &= 0xffffffff; \ | | 98| 997| } ------------------ 307| 997| HH ( a, b, c, d, in[13], S31, 681279174UL); /* 41 */ ------------------ | | 93| 997| {(a) += H ((b), (c), (d)) + (x) + (krb5_ui_4)(ac); \ | | ------------------ | | | | 70| 997|#define H(x, y, z) ((x) ^ (y) ^ (z)) | | ------------------ | | 94| 997| (a) &= 0xffffffff; \ | | 95| 997| (a) = ROTATE_LEFT ((a), (s)); \ | | ------------------ | | | | 74| 997|#define ROTATE_LEFT(x, n) ((((x) << (n)) & 0xffffffff) | ((x) >> (32-(n)))) | | ------------------ | | 96| 997| (a) += (b); \ | | 97| 997| (a) &= 0xffffffff; \ | | 98| 997| } ------------------ 308| 997| HH ( d, a, b, c, in[ 0], S32, 3936430074UL); /* 42 */ ------------------ | | 93| 997| {(a) += H ((b), (c), (d)) + (x) + (krb5_ui_4)(ac); \ | | ------------------ | | | | 70| 997|#define H(x, y, z) ((x) ^ (y) ^ (z)) | | ------------------ | | 94| 997| (a) &= 0xffffffff; \ | | 95| 997| (a) = ROTATE_LEFT ((a), (s)); \ | | ------------------ | | | | 74| 997|#define ROTATE_LEFT(x, n) ((((x) << (n)) & 0xffffffff) | ((x) >> (32-(n)))) | | ------------------ | | 96| 997| (a) += (b); \ | | 97| 997| (a) &= 0xffffffff; \ | | 98| 997| } ------------------ 309| 997| HH ( c, d, a, b, in[ 3], S33, 3572445317UL); /* 43 */ ------------------ | | 93| 997| {(a) += H ((b), (c), (d)) + (x) + (krb5_ui_4)(ac); \ | | ------------------ | | | | 70| 997|#define H(x, y, z) ((x) ^ (y) ^ (z)) | | ------------------ | | 94| 997| (a) &= 0xffffffff; \ | | 95| 997| (a) = ROTATE_LEFT ((a), (s)); \ | | ------------------ | | | | 74| 997|#define ROTATE_LEFT(x, n) ((((x) << (n)) & 0xffffffff) | ((x) >> (32-(n)))) | | ------------------ | | 96| 997| (a) += (b); \ | | 97| 997| (a) &= 0xffffffff; \ | | 98| 997| } ------------------ 310| 997| HH ( b, c, d, a, in[ 6], S34, 76029189UL); /* 44 */ ------------------ | | 93| 997| {(a) += H ((b), (c), (d)) + (x) + (krb5_ui_4)(ac); \ | | ------------------ | | | | 70| 997|#define H(x, y, z) ((x) ^ (y) ^ (z)) | | ------------------ | | 94| 997| (a) &= 0xffffffff; \ | | 95| 997| (a) = ROTATE_LEFT ((a), (s)); \ | | ------------------ | | | | 74| 997|#define ROTATE_LEFT(x, n) ((((x) << (n)) & 0xffffffff) | ((x) >> (32-(n)))) | | ------------------ | | 96| 997| (a) += (b); \ | | 97| 997| (a) &= 0xffffffff; \ | | 98| 997| } ------------------ 311| 997| HH ( a, b, c, d, in[ 9], S31, 3654602809UL); /* 45 */ ------------------ | | 93| 997| {(a) += H ((b), (c), (d)) + (x) + (krb5_ui_4)(ac); \ | | ------------------ | | | | 70| 997|#define H(x, y, z) ((x) ^ (y) ^ (z)) | | ------------------ | | 94| 997| (a) &= 0xffffffff; \ | | 95| 997| (a) = ROTATE_LEFT ((a), (s)); \ | | ------------------ | | | | 74| 997|#define ROTATE_LEFT(x, n) ((((x) << (n)) & 0xffffffff) | ((x) >> (32-(n)))) | | ------------------ | | 96| 997| (a) += (b); \ | | 97| 997| (a) &= 0xffffffff; \ | | 98| 997| } ------------------ 312| 997| HH ( d, a, b, c, in[12], S32, 3873151461UL); /* 46 */ ------------------ | | 93| 997| {(a) += H ((b), (c), (d)) + (x) + (krb5_ui_4)(ac); \ | | ------------------ | | | | 70| 997|#define H(x, y, z) ((x) ^ (y) ^ (z)) | | ------------------ | | 94| 997| (a) &= 0xffffffff; \ | | 95| 997| (a) = ROTATE_LEFT ((a), (s)); \ | | ------------------ | | | | 74| 997|#define ROTATE_LEFT(x, n) ((((x) << (n)) & 0xffffffff) | ((x) >> (32-(n)))) | | ------------------ | | 96| 997| (a) += (b); \ | | 97| 997| (a) &= 0xffffffff; \ | | 98| 997| } ------------------ 313| 997| HH ( c, d, a, b, in[15], S33, 530742520UL); /* 47 */ ------------------ | | 93| 997| {(a) += H ((b), (c), (d)) + (x) + (krb5_ui_4)(ac); \ | | ------------------ | | | | 70| 997|#define H(x, y, z) ((x) ^ (y) ^ (z)) | | ------------------ | | 94| 997| (a) &= 0xffffffff; \ | | 95| 997| (a) = ROTATE_LEFT ((a), (s)); \ | | ------------------ | | | | 74| 997|#define ROTATE_LEFT(x, n) ((((x) << (n)) & 0xffffffff) | ((x) >> (32-(n)))) | | ------------------ | | 96| 997| (a) += (b); \ | | 97| 997| (a) &= 0xffffffff; \ | | 98| 997| } ------------------ 314| 997| HH ( b, c, d, a, in[ 2], S34, 3299628645UL); /* 48 */ ------------------ | | 93| 997| {(a) += H ((b), (c), (d)) + (x) + (krb5_ui_4)(ac); \ | | ------------------ | | | | 70| 997|#define H(x, y, z) ((x) ^ (y) ^ (z)) | | ------------------ | | 94| 997| (a) &= 0xffffffff; \ | | 95| 997| (a) = ROTATE_LEFT ((a), (s)); \ | | ------------------ | | | | 74| 997|#define ROTATE_LEFT(x, n) ((((x) << (n)) & 0xffffffff) | ((x) >> (32-(n)))) | | ------------------ | | 96| 997| (a) += (b); \ | | 97| 997| (a) &= 0xffffffff; \ | | 98| 997| } ------------------ 315| | 316| | /* Round 4 */ 317| 997|#define S41 6 318| 997|#define S42 10 319| 997|#define S43 15 320| 997|#define S44 21 321| 997| II ( a, b, c, d, in[ 0], S41, 4096336452UL); /* 49 */ ------------------ | | 100| 997| {(a) += I ((b), (c), (d)) + (x) + (krb5_ui_4)(ac); \ | | ------------------ | | | | 71| 997|#define I(x, y, z) ((y) ^ ((x) | (~z))) | | ------------------ | | 101| 997| (a) &= 0xffffffff; \ | | 102| 997| (a) = ROTATE_LEFT ((a), (s)); \ | | ------------------ | | | | 74| 997|#define ROTATE_LEFT(x, n) ((((x) << (n)) & 0xffffffff) | ((x) >> (32-(n)))) | | ------------------ | | 103| 997| (a) += (b); \ | | 104| 997| (a) &= 0xffffffff; \ | | 105| 997| } ------------------ 322| 997| II ( d, a, b, c, in[ 7], S42, 1126891415UL); /* 50 */ ------------------ | | 100| 997| {(a) += I ((b), (c), (d)) + (x) + (krb5_ui_4)(ac); \ | | ------------------ | | | | 71| 997|#define I(x, y, z) ((y) ^ ((x) | (~z))) | | ------------------ | | 101| 997| (a) &= 0xffffffff; \ | | 102| 997| (a) = ROTATE_LEFT ((a), (s)); \ | | ------------------ | | | | 74| 997|#define ROTATE_LEFT(x, n) ((((x) << (n)) & 0xffffffff) | ((x) >> (32-(n)))) | | ------------------ | | 103| 997| (a) += (b); \ | | 104| 997| (a) &= 0xffffffff; \ | | 105| 997| } ------------------ 323| 997| II ( c, d, a, b, in[14], S43, 2878612391UL); /* 51 */ ------------------ | | 100| 997| {(a) += I ((b), (c), (d)) + (x) + (krb5_ui_4)(ac); \ | | ------------------ | | | | 71| 997|#define I(x, y, z) ((y) ^ ((x) | (~z))) | | ------------------ | | 101| 997| (a) &= 0xffffffff; \ | | 102| 997| (a) = ROTATE_LEFT ((a), (s)); \ | | ------------------ | | | | 74| 997|#define ROTATE_LEFT(x, n) ((((x) << (n)) & 0xffffffff) | ((x) >> (32-(n)))) | | ------------------ | | 103| 997| (a) += (b); \ | | 104| 997| (a) &= 0xffffffff; \ | | 105| 997| } ------------------ 324| 997| II ( b, c, d, a, in[ 5], S44, 4237533241UL); /* 52 */ ------------------ | | 100| 997| {(a) += I ((b), (c), (d)) + (x) + (krb5_ui_4)(ac); \ | | ------------------ | | | | 71| 997|#define I(x, y, z) ((y) ^ ((x) | (~z))) | | ------------------ | | 101| 997| (a) &= 0xffffffff; \ | | 102| 997| (a) = ROTATE_LEFT ((a), (s)); \ | | ------------------ | | | | 74| 997|#define ROTATE_LEFT(x, n) ((((x) << (n)) & 0xffffffff) | ((x) >> (32-(n)))) | | ------------------ | | 103| 997| (a) += (b); \ | | 104| 997| (a) &= 0xffffffff; \ | | 105| 997| } ------------------ 325| 997| II ( a, b, c, d, in[12], S41, 1700485571UL); /* 53 */ ------------------ | | 100| 997| {(a) += I ((b), (c), (d)) + (x) + (krb5_ui_4)(ac); \ | | ------------------ | | | | 71| 997|#define I(x, y, z) ((y) ^ ((x) | (~z))) | | ------------------ | | 101| 997| (a) &= 0xffffffff; \ | | 102| 997| (a) = ROTATE_LEFT ((a), (s)); \ | | ------------------ | | | | 74| 997|#define ROTATE_LEFT(x, n) ((((x) << (n)) & 0xffffffff) | ((x) >> (32-(n)))) | | ------------------ | | 103| 997| (a) += (b); \ | | 104| 997| (a) &= 0xffffffff; \ | | 105| 997| } ------------------ 326| 997| II ( d, a, b, c, in[ 3], S42, 2399980690UL); /* 54 */ ------------------ | | 100| 997| {(a) += I ((b), (c), (d)) + (x) + (krb5_ui_4)(ac); \ | | ------------------ | | | | 71| 997|#define I(x, y, z) ((y) ^ ((x) | (~z))) | | ------------------ | | 101| 997| (a) &= 0xffffffff; \ | | 102| 997| (a) = ROTATE_LEFT ((a), (s)); \ | | ------------------ | | | | 74| 997|#define ROTATE_LEFT(x, n) ((((x) << (n)) & 0xffffffff) | ((x) >> (32-(n)))) | | ------------------ | | 103| 997| (a) += (b); \ | | 104| 997| (a) &= 0xffffffff; \ | | 105| 997| } ------------------ 327| 997| II ( c, d, a, b, in[10], S43, 4293915773UL); /* 55 */ ------------------ | | 100| 997| {(a) += I ((b), (c), (d)) + (x) + (krb5_ui_4)(ac); \ | | ------------------ | | | | 71| 997|#define I(x, y, z) ((y) ^ ((x) | (~z))) | | ------------------ | | 101| 997| (a) &= 0xffffffff; \ | | 102| 997| (a) = ROTATE_LEFT ((a), (s)); \ | | ------------------ | | | | 74| 997|#define ROTATE_LEFT(x, n) ((((x) << (n)) & 0xffffffff) | ((x) >> (32-(n)))) | | ------------------ | | 103| 997| (a) += (b); \ | | 104| 997| (a) &= 0xffffffff; \ | | 105| 997| } ------------------ 328| 997| II ( b, c, d, a, in[ 1], S44, 2240044497UL); /* 56 */ ------------------ | | 100| 997| {(a) += I ((b), (c), (d)) + (x) + (krb5_ui_4)(ac); \ | | ------------------ | | | | 71| 997|#define I(x, y, z) ((y) ^ ((x) | (~z))) | | ------------------ | | 101| 997| (a) &= 0xffffffff; \ | | 102| 997| (a) = ROTATE_LEFT ((a), (s)); \ | | ------------------ | | | | 74| 997|#define ROTATE_LEFT(x, n) ((((x) << (n)) & 0xffffffff) | ((x) >> (32-(n)))) | | ------------------ | | 103| 997| (a) += (b); \ | | 104| 997| (a) &= 0xffffffff; \ | | 105| 997| } ------------------ 329| 997| II ( a, b, c, d, in[ 8], S41, 1873313359UL); /* 57 */ ------------------ | | 100| 997| {(a) += I ((b), (c), (d)) + (x) + (krb5_ui_4)(ac); \ | | ------------------ | | | | 71| 997|#define I(x, y, z) ((y) ^ ((x) | (~z))) | | ------------------ | | 101| 997| (a) &= 0xffffffff; \ | | 102| 997| (a) = ROTATE_LEFT ((a), (s)); \ | | ------------------ | | | | 74| 997|#define ROTATE_LEFT(x, n) ((((x) << (n)) & 0xffffffff) | ((x) >> (32-(n)))) | | ------------------ | | 103| 997| (a) += (b); \ | | 104| 997| (a) &= 0xffffffff; \ | | 105| 997| } ------------------ 330| 997| II ( d, a, b, c, in[15], S42, 4264355552UL); /* 58 */ ------------------ | | 100| 997| {(a) += I ((b), (c), (d)) + (x) + (krb5_ui_4)(ac); \ | | ------------------ | | | | 71| 997|#define I(x, y, z) ((y) ^ ((x) | (~z))) | | ------------------ | | 101| 997| (a) &= 0xffffffff; \ | | 102| 997| (a) = ROTATE_LEFT ((a), (s)); \ | | ------------------ | | | | 74| 997|#define ROTATE_LEFT(x, n) ((((x) << (n)) & 0xffffffff) | ((x) >> (32-(n)))) | | ------------------ | | 103| 997| (a) += (b); \ | | 104| 997| (a) &= 0xffffffff; \ | | 105| 997| } ------------------ 331| 997| II ( c, d, a, b, in[ 6], S43, 2734768916UL); /* 59 */ ------------------ | | 100| 997| {(a) += I ((b), (c), (d)) + (x) + (krb5_ui_4)(ac); \ | | ------------------ | | | | 71| 997|#define I(x, y, z) ((y) ^ ((x) | (~z))) | | ------------------ | | 101| 997| (a) &= 0xffffffff; \ | | 102| 997| (a) = ROTATE_LEFT ((a), (s)); \ | | ------------------ | | | | 74| 997|#define ROTATE_LEFT(x, n) ((((x) << (n)) & 0xffffffff) | ((x) >> (32-(n)))) | | ------------------ | | 103| 997| (a) += (b); \ | | 104| 997| (a) &= 0xffffffff; \ | | 105| 997| } ------------------ 332| 997| II ( b, c, d, a, in[13], S44, 1309151649UL); /* 60 */ ------------------ | | 100| 997| {(a) += I ((b), (c), (d)) + (x) + (krb5_ui_4)(ac); \ | | ------------------ | | | | 71| 997|#define I(x, y, z) ((y) ^ ((x) | (~z))) | | ------------------ | | 101| 997| (a) &= 0xffffffff; \ | | 102| 997| (a) = ROTATE_LEFT ((a), (s)); \ | | ------------------ | | | | 74| 997|#define ROTATE_LEFT(x, n) ((((x) << (n)) & 0xffffffff) | ((x) >> (32-(n)))) | | ------------------ | | 103| 997| (a) += (b); \ | | 104| 997| (a) &= 0xffffffff; \ | | 105| 997| } ------------------ 333| 997| II ( a, b, c, d, in[ 4], S41, 4149444226UL); /* 61 */ ------------------ | | 100| 997| {(a) += I ((b), (c), (d)) + (x) + (krb5_ui_4)(ac); \ | | ------------------ | | | | 71| 997|#define I(x, y, z) ((y) ^ ((x) | (~z))) | | ------------------ | | 101| 997| (a) &= 0xffffffff; \ | | 102| 997| (a) = ROTATE_LEFT ((a), (s)); \ | | ------------------ | | | | 74| 997|#define ROTATE_LEFT(x, n) ((((x) << (n)) & 0xffffffff) | ((x) >> (32-(n)))) | | ------------------ | | 103| 997| (a) += (b); \ | | 104| 997| (a) &= 0xffffffff; \ | | 105| 997| } ------------------ 334| 997| II ( d, a, b, c, in[11], S42, 3174756917UL); /* 62 */ ------------------ | | 100| 997| {(a) += I ((b), (c), (d)) + (x) + (krb5_ui_4)(ac); \ | | ------------------ | | | | 71| 997|#define I(x, y, z) ((y) ^ ((x) | (~z))) | | ------------------ | | 101| 997| (a) &= 0xffffffff; \ | | 102| 997| (a) = ROTATE_LEFT ((a), (s)); \ | | ------------------ | | | | 74| 997|#define ROTATE_LEFT(x, n) ((((x) << (n)) & 0xffffffff) | ((x) >> (32-(n)))) | | ------------------ | | 103| 997| (a) += (b); \ | | 104| 997| (a) &= 0xffffffff; \ | | 105| 997| } ------------------ 335| 997| II ( c, d, a, b, in[ 2], S43, 718787259UL); /* 63 */ ------------------ | | 100| 997| {(a) += I ((b), (c), (d)) + (x) + (krb5_ui_4)(ac); \ | | ------------------ | | | | 71| 997|#define I(x, y, z) ((y) ^ ((x) | (~z))) | | ------------------ | | 101| 997| (a) &= 0xffffffff; \ | | 102| 997| (a) = ROTATE_LEFT ((a), (s)); \ | | ------------------ | | | | 74| 997|#define ROTATE_LEFT(x, n) ((((x) << (n)) & 0xffffffff) | ((x) >> (32-(n)))) | | ------------------ | | 103| 997| (a) += (b); \ | | 104| 997| (a) &= 0xffffffff; \ | | 105| 997| } ------------------ 336| 997| II ( b, c, d, a, in[ 9], S44, 3951481745UL); /* 64 */ ------------------ | | 100| 997| {(a) += I ((b), (c), (d)) + (x) + (krb5_ui_4)(ac); \ | | ------------------ | | | | 71| 997|#define I(x, y, z) ((y) ^ ((x) | (~z))) | | ------------------ | | 101| 997| (a) &= 0xffffffff; \ | | 102| 997| (a) = ROTATE_LEFT ((a), (s)); \ | | ------------------ | | | | 74| 997|#define ROTATE_LEFT(x, n) ((((x) << (n)) & 0xffffffff) | ((x) >> (32-(n)))) | | ------------------ | | 103| 997| (a) += (b); \ | | 104| 997| (a) &= 0xffffffff; \ | | 105| 997| } ------------------ 337| | 338| 997|#endif /* small? */ 339| | 340| 997| buf[0] += a; 341| 997| buf[1] += b; 342| 997| buf[2] += c; 343| 997| buf[3] += d; 344| 997|} krb5int_hmacmd5_checksum: 41| 79|{ 42| 79| krb5_keyusage ms_usage; 43| 79| krb5_error_code ret; 44| 79| krb5_keyblock ks, *keyblock; 45| 79| krb5_crypto_iov *hash_iov = NULL, iov; 46| 79| krb5_data ds = empty_data(), hashval = empty_data(); 47| 79| char t[4]; 48| | 49| 79| if (key == NULL || key->keyblock.length > ctp->hash->blocksize) ------------------ | Branch (49:9): [True: 0, False: 79] | Branch (49:24): [True: 0, False: 79] ------------------ 50| 0| return KRB5_BAD_ENCTYPE; ------------------ | | 8841| 0|#define KRB5_BAD_ENCTYPE (-1765328196L) ------------------ 51| 79| if (ctp->ctype == CKSUMTYPE_HMAC_MD5_ARCFOUR) { ------------------ | | 479| 79|#define CKSUMTYPE_HMAC_MD5_ARCFOUR -138 /**< RFC 4757 */ ------------------ | Branch (51:9): [True: 40, False: 39] ------------------ 52| | /* Compute HMAC(key, "signaturekey\0") to get the signing key ks. */ 53| 40| ret = alloc_data(&ds, ctp->hash->hashsize); 54| 40| if (ret != 0) ------------------ | Branch (54:13): [True: 0, False: 40] ------------------ 55| 0| goto cleanup; 56| | 57| 40| iov.flags = KRB5_CRYPTO_TYPE_DATA; ------------------ | | 1056| 40|#define KRB5_CRYPTO_TYPE_DATA 2 /**< [in, out] plaintext */ ------------------ 58| 40| iov.data = make_data("signaturekey", 13); 59| 40| ret = krb5int_hmac(ctp->hash, key, &iov, 1, &ds); 60| 40| if (ret) ------------------ | Branch (60:13): [True: 0, False: 40] ------------------ 61| 0| goto cleanup; 62| 40| ks.length = ds.length; 63| 40| ks.contents = (krb5_octet *) ds.data; 64| 40| keyblock = &ks; 65| 40| } else /* For md5-hmac, just use the key. */ 66| 39| keyblock = &key->keyblock; 67| | 68| | /* Compute the MD5 value of the input. */ 69| 79| ms_usage = krb5int_arcfour_translate_usage(usage); 70| 79| store_32_le(ms_usage, t); 71| 79| hash_iov = k5calloc(num_data + 1, sizeof(krb5_crypto_iov), &ret); 72| 79| if (hash_iov == NULL) ------------------ | Branch (72:9): [True: 0, False: 79] ------------------ 73| 0| goto cleanup; 74| 79| hash_iov[0].flags = KRB5_CRYPTO_TYPE_DATA; ------------------ | | 1056| 79|#define KRB5_CRYPTO_TYPE_DATA 2 /**< [in, out] plaintext */ ------------------ 75| 79| hash_iov[0].data = make_data(t, 4); 76| 79| memcpy(hash_iov + 1, data, num_data * sizeof(krb5_crypto_iov)); 77| 79| ret = alloc_data(&hashval, ctp->hash->hashsize); 78| 79| if (ret != 0) ------------------ | Branch (78:9): [True: 0, False: 79] ------------------ 79| 0| goto cleanup; 80| 79| ret = ctp->hash->hash(hash_iov, num_data + 1, &hashval); 81| 79| if (ret != 0) ------------------ | Branch (81:9): [True: 0, False: 79] ------------------ 82| 0| goto cleanup; 83| | 84| | /* Compute HMAC(ks, md5value). */ 85| 79| iov.flags = KRB5_CRYPTO_TYPE_DATA; ------------------ | | 1056| 79|#define KRB5_CRYPTO_TYPE_DATA 2 /**< [in, out] plaintext */ ------------------ 86| 79| iov.data = hashval; 87| 79| ret = krb5int_hmac_keyblock(ctp->hash, keyblock, &iov, 1, output); 88| | 89| 79|cleanup: 90| 79| zapfree(ds.data, ds.length); 91| 79| zapfree(hashval.data, hashval.length); 92| 79| free(hash_iov); 93| 79| return ret; 94| 79|} krb5_c_checksum_length: 33| 93|{ 34| 93| const struct krb5_cksumtypes *ctp; 35| | 36| 93| ctp = find_cksumtype(cksumtype); 37| 93| if (ctp == NULL) ------------------ | Branch (37:9): [True: 0, False: 93] ------------------ 38| 0| return KRB5_BAD_ENCTYPE; ------------------ | | 8841| 0|#define KRB5_BAD_ENCTYPE (-1765328196L) ------------------ 39| | 40| 93| *length = ctp->output_size; 41| 93| return 0; 42| 93|} checksum_length.c:find_cksumtype: 583| 93|{ 584| 93| size_t i; 585| | 586| 715| for (i = 0; i < krb5int_cksumtypes_length; i++) { ------------------ | Branch (586:17): [True: 715, False: 0] ------------------ 587| 715| if (krb5int_cksumtypes_list[i].ctype == ctype) ------------------ | Branch (587:13): [True: 93, False: 622] ------------------ 588| 93| break; 589| 715| } 590| | 591| 93| if (i == krb5int_cksumtypes_length) ------------------ | Branch (591:9): [True: 0, False: 93] ------------------ 592| 0| return NULL; 593| 93| return &krb5int_cksumtypes_list[i]; 594| 93|} keyed_cksum.c:find_cksumtype: 583| 184|{ 584| 184| size_t i; 585| | 586| 1.94k| for (i = 0; i < krb5int_cksumtypes_length; i++) { ------------------ | Branch (586:17): [True: 1.85k, False: 87] ------------------ 587| 1.85k| if (krb5int_cksumtypes_list[i].ctype == ctype) ------------------ | Branch (587:13): [True: 97, False: 1.75k] ------------------ 588| 97| break; 589| 1.85k| } 590| | 591| 184| if (i == krb5int_cksumtypes_length) ------------------ | Branch (591:9): [True: 87, False: 97] ------------------ 592| 87| return NULL; 593| 97| return &krb5int_cksumtypes_list[i]; 594| 184|} make_checksum.c:find_cksumtype: 583| 79|{ 584| 79| size_t i; 585| | 586| 591| for (i = 0; i < krb5int_cksumtypes_length; i++) { ------------------ | Branch (586:17): [True: 591, False: 0] ------------------ 587| 591| if (krb5int_cksumtypes_list[i].ctype == ctype) ------------------ | Branch (587:13): [True: 79, False: 512] ------------------ 588| 79| break; 589| 591| } 590| | 591| 79| if (i == krb5int_cksumtypes_length) ------------------ | Branch (591:9): [True: 0, False: 79] ------------------ 592| 0| return NULL; 593| 79| return &krb5int_cksumtypes_list[i]; 594| 79|} make_checksum.c:verify_key: 599| 79|{ 600| 79| const struct krb5_keytypes *ktp; 601| | 602| 79| ktp = key ? find_enctype(key->keyblock.enctype) : NULL; ------------------ | Branch (602:11): [True: 79, False: 0] ------------------ 603| 79| if (ctp->enc != NULL && (!ktp || ktp->enc != ctp->enc)) ------------------ | Branch (603:9): [True: 39, False: 40] | Branch (603:30): [True: 0, False: 39] | Branch (603:38): [True: 0, False: 39] ------------------ 604| 0| return KRB5_BAD_ENCTYPE; ------------------ | | 8841| 0|#define KRB5_BAD_ENCTYPE (-1765328196L) ------------------ 605| 79| if (key && (!ktp || key->keyblock.length != ktp->enc->keylength)) ------------------ | Branch (605:9): [True: 79, False: 0] | Branch (605:17): [True: 0, False: 79] | Branch (605:25): [True: 0, False: 79] ------------------ 606| 0| return KRB5_BAD_KEYSIZE; ------------------ | | 8842| 0|#define KRB5_BAD_KEYSIZE (-1765328195L) ------------------ 607| 79| return 0; 608| 79|} make_checksum.c:find_enctype: 567| 79|{ 568| 79| int i; 569| | 570| 237| for (i = 0; i < krb5int_enctypes_length; i++) { ------------------ | Branch (570:17): [True: 237, False: 0] ------------------ 571| 237| if (krb5int_enctypes_list[i].etype == enctype) ------------------ | Branch (571:13): [True: 79, False: 158] ------------------ 572| 79| break; 573| 237| } 574| | 575| 79| if (i == krb5int_enctypes_length) ------------------ | Branch (575:9): [True: 0, False: 79] ------------------ 576| 0| return NULL; 577| 79| return &krb5int_enctypes_list[i]; 578| 79|} verify_checksum.c:find_cksumtype: 583| 84|{ 584| 84| size_t i; 585| | 586| 634| for (i = 0; i < krb5int_cksumtypes_length; i++) { ------------------ | Branch (586:17): [True: 634, False: 0] ------------------ 587| 634| if (krb5int_cksumtypes_list[i].ctype == ctype) ------------------ | Branch (587:13): [True: 84, False: 550] ------------------ 588| 84| break; 589| 634| } 590| | 591| 84| if (i == krb5int_cksumtypes_length) ------------------ | Branch (591:9): [True: 0, False: 84] ------------------ 592| 0| return NULL; 593| 84| return &krb5int_cksumtypes_list[i]; 594| 84|} verify_checksum.c:verify_key: 599| 84|{ 600| 84| const struct krb5_keytypes *ktp; 601| | 602| 84| ktp = key ? find_enctype(key->keyblock.enctype) : NULL; ------------------ | Branch (602:11): [True: 84, False: 0] ------------------ 603| 84| if (ctp->enc != NULL && (!ktp || ktp->enc != ctp->enc)) ------------------ | Branch (603:9): [True: 44, False: 40] | Branch (603:30): [True: 0, False: 44] | Branch (603:38): [True: 5, False: 39] ------------------ 604| 5| return KRB5_BAD_ENCTYPE; ------------------ | | 8841| 5|#define KRB5_BAD_ENCTYPE (-1765328196L) ------------------ 605| 79| if (key && (!ktp || key->keyblock.length != ktp->enc->keylength)) ------------------ | Branch (605:9): [True: 79, False: 0] | Branch (605:17): [True: 0, False: 79] | Branch (605:25): [True: 0, False: 79] ------------------ 606| 0| return KRB5_BAD_KEYSIZE; ------------------ | | 8842| 0|#define KRB5_BAD_KEYSIZE (-1765328195L) ------------------ 607| 79| return 0; 608| 79|} verify_checksum.c:find_enctype: 567| 84|{ 568| 84| int i; 569| | 570| 252| for (i = 0; i < krb5int_enctypes_length; i++) { ------------------ | Branch (570:17): [True: 252, False: 0] ------------------ 571| 252| if (krb5int_enctypes_list[i].etype == enctype) ------------------ | Branch (571:13): [True: 84, False: 168] ------------------ 572| 84| break; 573| 252| } 574| | 575| 84| if (i == krb5int_enctypes_length) ------------------ | Branch (575:9): [True: 0, False: 84] ------------------ 576| 0| return NULL; 577| 84| return &krb5int_enctypes_list[i]; 578| 84|} krb5int_arcfour_translate_usage: 18| 79|{ 19| 79| switch (usage) { 20| 0| case 1: return 1; /* AS-REQ PA-ENC-TIMESTAMP padata timestamp, */ ------------------ | Branch (20:5): [True: 0, False: 79] ------------------ 21| 0| case 2: return 2; /* ticket from kdc */ ------------------ | Branch (21:5): [True: 0, False: 79] ------------------ 22| 0| case 3: return 8; /* as-rep encrypted part */ ------------------ | Branch (22:5): [True: 0, False: 79] ------------------ 23| 0| case 4: return 4; /* tgs-req authz data */ ------------------ | Branch (23:5): [True: 0, False: 79] ------------------ 24| 0| case 5: return 5; /* tgs-req authz data in subkey */ ------------------ | Branch (24:5): [True: 0, False: 79] ------------------ 25| 0| case 6: return 6; /* tgs-req authenticator cksum */ ------------------ | Branch (25:5): [True: 0, False: 79] ------------------ 26| 0| case 7: return 7; /* tgs-req authenticator */ ------------------ | Branch (26:5): [True: 0, False: 79] ------------------ 27| 0| case 8: return 8; ------------------ | Branch (27:5): [True: 0, False: 79] ------------------ 28| 0| case 9: return 9; /* tgs-rep encrypted with subkey */ ------------------ | Branch (28:5): [True: 0, False: 79] ------------------ 29| 0| case 10: return 10; /* ap-rep authentication cksum (never used by MS) */ ------------------ | Branch (29:5): [True: 0, False: 79] ------------------ 30| 0| case 11: return 11; /* app-req authenticator */ ------------------ | Branch (30:5): [True: 0, False: 79] ------------------ 31| 0| case 12: return 12; /* app-rep encrypted part */ ------------------ | Branch (31:5): [True: 0, False: 79] ------------------ 32| 0| case 23: return 13; /* sign wrap token*/ ------------------ | Branch (32:5): [True: 0, False: 79] ------------------ 33| 79| default: return usage; ------------------ | Branch (33:5): [True: 79, False: 0] ------------------ 34| 79| } 35| 79|} krb5_k_create_key: 40| 84|{ 41| 84| krb5_key key = NULL; 42| 84| krb5_error_code code; 43| | 44| 84| *out = NULL; 45| | 46| 84| key = malloc(sizeof(*key)); 47| 84| if (key == NULL) ------------------ | Branch (47:9): [True: 0, False: 84] ------------------ 48| 0| return ENOMEM; 49| 84| code = krb5int_c_copy_keyblock_contents(context, key_data, &key->keyblock); 50| 84| if (code) ------------------ | Branch (50:9): [True: 0, False: 84] ------------------ 51| 0| goto cleanup; 52| | 53| 84| key->refcount = 1; 54| 84| key->derived = NULL; 55| 84| key->cache = NULL; 56| 84| *out = key; 57| 84| return 0; 58| | 59| 0|cleanup: 60| 0| free(key); 61| 0| return code; 62| 84|} krb5_k_free_key: 74| 84|{ 75| 84| struct derived_key *dk; 76| 84| const struct krb5_keytypes *ktp; 77| | 78| 84| if (key == NULL || --key->refcount > 0) ------------------ | Branch (78:9): [True: 0, False: 84] | Branch (78:24): [True: 0, False: 84] ------------------ 79| 0| return; 80| | 81| | /* Free the derived key cache. */ 82| 84| while ((dk = key->derived) != NULL) { ------------------ | Branch (82:12): [True: 0, False: 84] ------------------ 83| 0| key->derived = dk->next; 84| 0| free(dk->constant.data); 85| 0| krb5_k_free_key(context, dk->dkey); 86| 0| free(dk); 87| 0| } 88| 84| krb5int_c_free_keyblock_contents(context, &key->keyblock); 89| 84| if (key->cache) { ------------------ | Branch (89:9): [True: 0, False: 84] ------------------ 90| 0| ktp = find_enctype(key->keyblock.enctype); 91| 0| if (ktp && ktp->enc->key_cleanup) ------------------ | Branch (91:13): [True: 0, False: 0] | Branch (91:20): [True: 0, False: 0] ------------------ 92| 0| ktp->enc->key_cleanup(key); 93| 0| } 94| 84| free(key); 95| 84|} krb5int_c_free_keyblock_contents: 67| 84|{ 68| 84| if (key && key->contents) { ------------------ | Branch (68:9): [True: 84, False: 0] | Branch (68:16): [True: 84, False: 0] ------------------ 69| 84| zapfree(key->contents, key->length); 70| | key->contents = NULL; 71| 84| key->length = 0; 72| 84| } 73| 84|} krb5int_c_copy_keyblock_contents: 98| 84|{ 99| 84| *to = *from; 100| 84| if (to->length) { ------------------ | Branch (100:9): [True: 84, False: 0] ------------------ 101| 84| to->contents = malloc(to->length); 102| 84| if (!to->contents) ------------------ | Branch (102:13): [True: 0, False: 84] ------------------ 103| 0| return ENOMEM; 104| 84| memcpy(to->contents, from->contents, to->length); 105| 84| } else 106| 0| to->contents = 0; 107| 84| return 0; 108| 84|} krb5_c_is_keyed_cksum: 32| 184|{ 33| 184| const struct krb5_cksumtypes *ctp; 34| | 35| 184| ctp = find_cksumtype(ctype); 36| 184| if (ctp == NULL) ------------------ | Branch (36:9): [True: 87, False: 97] ------------------ 37| 87| return FALSE; ------------------ | | 164| 87|#define FALSE 0 ------------------ 38| 97| return !(ctp->flags & CKSUM_UNKEYED); ------------------ | | 230| 97|#define CKSUM_UNKEYED 0x0001 ------------------ 39| 184|} krb5_k_make_checksum: 36| 79|{ 37| 79| const struct krb5_cksumtypes *ctp; 38| 79| krb5_crypto_iov iov; 39| 79| krb5_data cksum_data; 40| 79| krb5_octet *trunc; 41| 79| krb5_error_code ret; 42| | 43| 79| if (cksumtype == 0 && key != NULL) { ------------------ | Branch (43:9): [True: 0, False: 79] | Branch (43:27): [True: 0, False: 0] ------------------ 44| 0| ret = krb5int_c_mandatory_cksumtype(context, key->keyblock.enctype, 45| 0| &cksumtype); 46| 0| if (ret != 0) ------------------ | Branch (46:13): [True: 0, False: 0] ------------------ 47| 0| return ret; 48| 0| } 49| 79| ctp = find_cksumtype(cksumtype); 50| 79| if (ctp == NULL) ------------------ | Branch (50:9): [True: 0, False: 79] ------------------ 51| 0| return KRB5_BAD_ENCTYPE; ------------------ | | 8841| 0|#define KRB5_BAD_ENCTYPE (-1765328196L) ------------------ 52| | 53| 79| ret = verify_key(ctp, key); 54| 79| if (ret != 0) ------------------ | Branch (54:9): [True: 0, False: 79] ------------------ 55| 0| return ret; 56| | 57| 79| ret = alloc_data(&cksum_data, ctp->compute_size); 58| 79| if (ret != 0) ------------------ | Branch (58:9): [True: 0, False: 79] ------------------ 59| 0| return ret; 60| | 61| 79| iov.flags = KRB5_CRYPTO_TYPE_DATA; ------------------ | | 1056| 79|#define KRB5_CRYPTO_TYPE_DATA 2 /**< [in, out] plaintext */ ------------------ 62| 79| iov.data = *input; 63| 79| ret = ctp->checksum(ctp, key, usage, &iov, 1, &cksum_data); 64| 79| if (ret != 0) ------------------ | Branch (64:9): [True: 0, False: 79] ------------------ 65| 0| goto cleanup; 66| | 67| 79| cksum->magic = KV5M_CHECKSUM; ------------------ | | 9040| 79|#define KV5M_CHECKSUM (-1760647420L) ------------------ 68| 79| cksum->checksum_type = cksumtype; 69| 79| cksum->length = ctp->output_size; 70| 79| cksum->contents = (krb5_octet *) cksum_data.data; 71| 79| cksum_data.data = NULL; 72| 79| if (ctp->output_size < ctp->compute_size) { ------------------ | Branch (72:9): [True: 0, False: 79] ------------------ 73| 0| trunc = realloc(cksum->contents, ctp->output_size); 74| 0| if (trunc != NULL) ------------------ | Branch (74:13): [True: 0, False: 0] ------------------ 75| 0| cksum->contents = trunc; 76| 0| } 77| | 78| 79|cleanup: 79| 79| zapfree(cksum_data.data, ctp->compute_size); 80| 79| return ret; 81| 79|} krb5_k_verify_checksum: 34| 84|{ 35| 84| const struct krb5_cksumtypes *ctp; 36| 84| krb5_cksumtype cksumtype; 37| 84| krb5_crypto_iov iov; 38| 84| krb5_error_code ret; 39| 84| krb5_data cksum_data; 40| 84| krb5_checksum computed; 41| | 42| 84| iov.flags = KRB5_CRYPTO_TYPE_DATA; ------------------ | | 1056| 84|#define KRB5_CRYPTO_TYPE_DATA 2 /**< [in, out] plaintext */ ------------------ 43| 84| iov.data = *data; 44| | 45| | /* A 0 checksum type means use the mandatory checksum. */ 46| 84| cksumtype = cksum->checksum_type; 47| 84| if (cksumtype == 0 && key != NULL) { ------------------ | Branch (47:9): [True: 0, False: 84] | Branch (47:27): [True: 0, False: 0] ------------------ 48| 0| ret = krb5int_c_mandatory_cksumtype(context, key->keyblock.enctype, 49| 0| &cksumtype); 50| 0| if (ret) ------------------ | Branch (50:13): [True: 0, False: 0] ------------------ 51| 0| return ret; 52| 0| } 53| 84| ctp = find_cksumtype(cksumtype); 54| 84| if (ctp == NULL) ------------------ | Branch (54:9): [True: 0, False: 84] ------------------ 55| 0| return KRB5_BAD_ENCTYPE; ------------------ | | 8841| 0|#define KRB5_BAD_ENCTYPE (-1765328196L) ------------------ 56| | 57| 84| ret = verify_key(ctp, key); 58| 84| if (ret != 0) ------------------ | Branch (58:9): [True: 5, False: 79] ------------------ 59| 5| return ret; 60| | 61| | /* If there's actually a verify function, call it. */ 62| 79| cksum_data = make_data(cksum->contents, cksum->length); 63| 79| if (ctp->verify != NULL) ------------------ | Branch (63:9): [True: 0, False: 79] ------------------ 64| 0| return ctp->verify(ctp, key, usage, &iov, 1, &cksum_data, valid); 65| | 66| | /* Otherwise, make the checksum again, and compare. */ 67| 79| if (cksum->length != ctp->output_size) ------------------ | Branch (67:9): [True: 0, False: 79] ------------------ 68| 0| return KRB5_BAD_MSIZE; ------------------ | | 8843| 0|#define KRB5_BAD_MSIZE (-1765328194L) ------------------ 69| | 70| 79| ret = krb5_k_make_checksum(context, cksum->checksum_type, key, usage, 71| 79| data, &computed); 72| 79| if (ret) ------------------ | Branch (72:9): [True: 0, False: 79] ------------------ 73| 0| return ret; 74| | 75| 79| *valid = (k5_bcmp(computed.contents, cksum->contents, 76| 79| ctp->output_size) == 0); 77| | 78| 79| free(computed.contents); 79| 79| return 0; 80| 79|} krb5_c_verify_checksum: 86| 84|{ 87| 84| krb5_key key = NULL; 88| 84| krb5_error_code ret; 89| | 90| 84| if (keyblock != NULL) { ------------------ | Branch (90:9): [True: 84, False: 0] ------------------ 91| 84| ret = krb5_k_create_key(context, keyblock, &key); 92| 84| if (ret != 0) ------------------ | Branch (92:13): [True: 0, False: 84] ------------------ 93| 0| return ret; 94| 84| } 95| 84| ret = krb5_k_verify_checksum(context, key, usage, data, cksum, valid); 96| 84| krb5_k_free_key(context, key); 97| 84| return ret; 98| 84|} krb5int_cc_initialize: 109| 1|{ 110| 1| int err; 111| | 112| 1| err = k5_cc_mutex_finish_init(&cccol_lock); 113| 1| if (err) ------------------ | Branch (113:9): [True: 0, False: 1] ------------------ 114| 0| return err; 115| 1| err = k5_cc_mutex_finish_init(&krb5int_mcc_mutex); 116| 1| if (err) ------------------ | Branch (116:9): [True: 0, False: 1] ------------------ 117| 0| return err; 118| 1| err = k5_mutex_finish_init(&cc_typelist_lock); 119| 1| if (err) ------------------ | Branch (119:9): [True: 0, False: 1] ------------------ 120| 0| return err; 121| 1|#ifndef NO_FILE_CCACHE 122| 1| err = k5_cc_mutex_finish_init(&krb5int_cc_file_mutex); 123| 1| if (err) ------------------ | Branch (123:9): [True: 0, False: 1] ------------------ 124| 0| return err; 125| 1|#endif 126| |#ifdef USE_KEYRING_CCACHE 127| | err = k5_cc_mutex_finish_init(&krb5int_krcc_mutex); 128| | if (err) 129| | return err; 130| |#endif 131| 1| return 0; 132| 1|} k5_cc_mutex_finish_init: 482| 3|{ 483| 3| krb5_error_code ret = 0; 484| | 485| 3| ret = k5_mutex_finish_init(&m->lock); 486| 3| if (ret) return ret; ------------------ | Branch (486:9): [True: 0, False: 3] ------------------ 487| 3| m->owner = NULL; 488| 3| m->refcount = 0; 489| | 490| 3| return ret; 491| 3|} k5_ccselect_free_context: 201| 1.01k|{ 202| 1.01k| free_handles(context, context->ccselect_handles); 203| | context->ccselect_handles = NULL; 204| 1.01k|} ccselect.c:free_handles: 40| 1.01k|{ 41| 1.01k| struct ccselect_module_handle *h, **hp; 42| | 43| 1.01k| if (handles == NULL) ------------------ | Branch (43:9): [True: 1.01k, False: 0] ------------------ 44| 1.01k| return; 45| 0| for (hp = handles; *hp != NULL; hp++) { ------------------ | Branch (45:24): [True: 0, False: 0] ------------------ 46| 0| h = *hp; 47| 0| if (h->vt.fini) ------------------ | Branch (47:13): [True: 0, False: 0] ------------------ 48| 0| h->vt.fini(context, h->data); 49| 0| free(h); 50| 0| } 51| 0| free(handles); 52| 0|} krb5int_mkt_initialize: 138| 1|{ 139| 1| return k5_mutex_finish_init(&krb5int_mkt_mutex); 140| 1|} krb5int_kt_initialize: 82| 1|{ 83| 1| int err; 84| | 85| 1| err = k5_mutex_finish_init(&kt_typehead_lock); 86| 1| if (err) ------------------ | Branch (86:9): [True: 0, False: 1] ------------------ 87| 0| goto done; 88| 1| err = krb5int_mkt_initialize(); 89| 1| if (err) ------------------ | Branch (89:9): [True: 0, False: 1] ------------------ 90| 0| goto done; 91| | 92| 1|done: 93| 1| return(err); 94| 1|} k5_infer_principal_type: 32| 1.01k|{ 33| | /* RFC 4120 section 7.3 */ 34| 1.01k| if (princ->length == 2 && data_eq_string(princ->data[0], KRB5_TGS_NAME)) ------------------ | | 6461| 0|#define KRB5_TGS_NAME "krbtgt" ------------------ | Branch (34:9): [True: 0, False: 1.01k] | Branch (34:31): [True: 0, False: 0] ------------------ 35| 0| return KRB5_NT_SRV_INST; ------------------ | | 241| 0|#define KRB5_NT_SRV_INST 2 /**< Service and other unique instance (krbtgt) */ ------------------ 36| | 37| | /* RFC 6111 section 3.1 */ 38| 1.01k| if (princ->length >= 2 && ------------------ | Branch (38:9): [True: 0, False: 1.01k] ------------------ 39| 0| data_eq_string(princ->data[0], KRB5_WELLKNOWN_NAMESTR)) ------------------ | | 250| 0|#define KRB5_WELLKNOWN_NAMESTR "WELLKNOWN" /**< First component of ------------------ | Branch (39:9): [True: 0, False: 0] ------------------ 40| 0| return KRB5_NT_WELLKNOWN; ------------------ | | 249| 0|#define KRB5_NT_WELLKNOWN 11 /**< Well-known (special) principal */ ------------------ 41| | 42| 1.01k| return KRB5_NT_PRINCIPAL; ------------------ | | 239| 1.01k|#define KRB5_NT_PRINCIPAL 1 /**< Just the name of the principal ------------------ 43| 1.01k|} krb5int_copy_data_contents: 63| 252|{ 64| 252| if (!indata) { ------------------ | Branch (64:9): [True: 0, False: 252] ------------------ 65| 0| return EINVAL; 66| 0| } 67| | 68| 252| outdata->length = indata->length; 69| 252| if (outdata->length) { ------------------ | Branch (69:9): [True: 252, False: 0] ------------------ 70| 252| if (!(outdata->data = malloc(outdata->length))) { ------------------ | Branch (70:13): [True: 0, False: 252] ------------------ 71| 0| return ENOMEM; 72| 0| } 73| 252| memcpy(outdata->data, indata->data, outdata->length); 74| 252| } else 75| 0| outdata->data = 0; 76| 252| outdata->magic = KV5M_DATA; ------------------ | | 9038| 252|#define KV5M_DATA (-1760647422L) ------------------ 77| | 78| 252| return 0; 79| 252|} krb5_init_context: 125| 1.01k|{ 126| | /* 127| | * This is rather silly, but should improve our chances of 128| | * retaining the krb5_brand array in the final linked library, 129| | * better than a static variable that's unreferenced after 130| | * optimization, or even a non-static symbol that's not exported 131| | * from the library nor referenced from anywhere else in the 132| | * library. 133| | * 134| | * If someday we grow an API to actually return the string, we can 135| | * get rid of this silliness. 136| | */ 137| 1.01k| int my_zero = (krb5_brand[0] == 0); 138| | 139| | return krb5_init_context_profile(NULL, my_zero, context); 140| 1.01k|} krb5_init_context_profile: 157| 1.01k|{ 158| 1.01k| krb5_context ctx = 0; 159| 1.01k| krb5_error_code retval; 160| 1.01k| int tmp; 161| 1.01k| char *plugin_dir = NULL, *timeout_str = NULL; 162| | 163| | /* Verify some assumptions. If the assumptions hold and the 164| | compiler is optimizing, this should result in no code being 165| | executed. If we're guessing "unsigned long long" instead 166| | of using uint64_t, the possibility does exist that we're 167| | wrong. */ 168| 1.01k| { 169| 1.01k| uint64_t i64; 170| 1.01k| assert(sizeof(i64) == 8); ------------------ | Branch (170:9): [True: 0, Folded] | Branch (170:9): [True: 1.01k, Folded] ------------------ 171| 1.01k| i64 = 0, i64--, i64 >>= 62; 172| 1.01k| assert(i64 == 3); ------------------ | Branch (172:9): [True: 0, False: 1.01k] | Branch (172:9): [True: 1.01k, False: 0] ------------------ 173| 1.01k| i64 = 1, i64 <<= 31, i64 <<= 31, i64 <<= 1; 174| 1.01k| assert(i64 != 0); ------------------ | Branch (174:9): [True: 0, False: 1.01k] | Branch (174:9): [True: 1.01k, False: 0] ------------------ 175| 1.01k| i64 <<= 1; 176| 1.01k| assert(i64 == 0); ------------------ | Branch (176:9): [True: 0, False: 1.01k] | Branch (176:9): [True: 1.01k, False: 0] ------------------ 177| 1.01k| } 178| | 179| 1.01k| retval = krb5int_initialize_library(); 180| 1.01k| if (retval) ------------------ | Branch (180:9): [True: 0, False: 1.01k] ------------------ 181| 0| return retval; 182| | 183| |#if (defined(_WIN32)) 184| | /* 185| | * Load the krbcc32.dll if necessary. We do this here so that 186| | * we know to use API: later on during initialization. 187| | * The context being NULL is ok. 188| | */ 189| | krb5_win_ccdll_load(ctx); 190| | 191| | /* 192| | * krb5_vercheck() is defined in win_glue.c, and this is 193| | * where we handle the timebomb and version server checks. 194| | */ 195| | retval = krb5_vercheck(); 196| | if (retval) 197| | return retval; 198| |#endif 199| | 200| 1.01k| *context_out = NULL; 201| | 202| 1.01k| ctx = calloc(1, sizeof(struct _krb5_context)); 203| 1.01k| if (!ctx) ------------------ | Branch (203:9): [True: 0, False: 1.01k] ------------------ 204| 0| return ENOMEM; 205| 1.01k| ctx->magic = KV5M_CONTEXT; ------------------ | | 9072| 1.01k|#define KV5M_CONTEXT (-1760647388L) ------------------ 206| | 207| 1.01k| ctx->profile_secure = (flags & KRB5_INIT_CONTEXT_SECURE) != 0; ------------------ | | 2860| 1.01k|#define KRB5_INIT_CONTEXT_SECURE 0x1 /**< Use secure context configuration */ ------------------ 208| | 209| 1.01k| retval = k5_os_init_context(ctx, profile, flags); 210| 1.01k| if (retval) ------------------ | Branch (210:9): [True: 0, False: 1.01k] ------------------ 211| 0| goto cleanup; 212| | 213| 1.01k| ctx->trace_callback = NULL; 214| 1.01k|#ifndef DISABLE_TRACING 215| 1.01k| if (!ctx->profile_secure) ------------------ | Branch (215:9): [True: 1.01k, False: 0] ------------------ 216| 1.01k| k5_init_trace(ctx); 217| 1.01k|#endif 218| | 219| 1.01k| retval = get_boolean(ctx, KRB5_CONF_ALLOW_WEAK_CRYPTO, 0, &tmp); ------------------ | | 185| 1.01k|#define KRB5_CONF_ALLOW_WEAK_CRYPTO "allow_weak_crypto" ------------------ 220| 1.01k| if (retval) ------------------ | Branch (220:9): [True: 0, False: 1.01k] ------------------ 221| 0| goto cleanup; 222| 1.01k| ctx->allow_weak_crypto = tmp; 223| | 224| 1.01k| retval = get_boolean(ctx, KRB5_CONF_ALLOW_DES3, 0, &tmp); ------------------ | | 183| 1.01k|#define KRB5_CONF_ALLOW_DES3 "allow_des3" ------------------ 225| 1.01k| if (retval) ------------------ | Branch (225:9): [True: 0, False: 1.01k] ------------------ 226| 0| goto cleanup; 227| 1.01k| ctx->allow_des3 = tmp; 228| | 229| 1.01k| retval = get_boolean(ctx, KRB5_CONF_ALLOW_RC4, 0, &tmp); ------------------ | | 184| 1.01k|#define KRB5_CONF_ALLOW_RC4 "allow_rc4" ------------------ 230| 1.01k| if (retval) ------------------ | Branch (230:9): [True: 0, False: 1.01k] ------------------ 231| 0| goto cleanup; 232| 1.01k| ctx->allow_rc4 = tmp; 233| | 234| 1.01k| retval = get_boolean(ctx, KRB5_CONF_IGNORE_ACCEPTOR_HOSTNAME, 0, &tmp); ------------------ | | 226| 1.01k|#define KRB5_CONF_IGNORE_ACCEPTOR_HOSTNAME "ignore_acceptor_hostname" ------------------ 235| 1.01k| if (retval) ------------------ | Branch (235:9): [True: 0, False: 1.01k] ------------------ 236| 0| goto cleanup; 237| 1.01k| ctx->ignore_acceptor_hostname = tmp; 238| | 239| 1.01k| retval = get_boolean(ctx, KRB5_CONF_ENFORCE_OK_AS_DELEGATE, 0, &tmp); ------------------ | | 220| 1.01k|#define KRB5_CONF_ENFORCE_OK_AS_DELEGATE "enforce_ok_as_delegate" ------------------ 240| 1.01k| if (retval) ------------------ | Branch (240:9): [True: 0, False: 1.01k] ------------------ 241| 0| goto cleanup; 242| 1.01k| ctx->enforce_ok_as_delegate = tmp; 243| | 244| 1.01k| retval = get_tristate(ctx, KRB5_CONF_DNS_CANONICALIZE_HOSTNAME, "fallback", ------------------ | | 212| 1.01k|#define KRB5_CONF_DNS_CANONICALIZE_HOSTNAME "dns_canonicalize_hostname" ------------------ 245| 1.01k| CANONHOST_FALLBACK, 1, &tmp); 246| 1.01k| if (retval) ------------------ | Branch (246:9): [True: 0, False: 1.01k] ------------------ 247| 0| goto cleanup; 248| 1.01k| ctx->dns_canonicalize_hostname = tmp; 249| | 250| 1.01k| ctx->default_realm = 0; 251| 1.01k| get_integer(ctx, KRB5_CONF_CLOCKSKEW, DEFAULT_CLOCKSKEW, &tmp); ------------------ | | 191| 1.01k|#define KRB5_CONF_CLOCKSKEW "clockskew" ------------------ get_integer(ctx, KRB5_CONF_CLOCKSKEW, DEFAULT_CLOCKSKEW, &tmp); ------------------ | | 73| 1.01k|#define DEFAULT_CLOCKSKEW 300 /* 5 min */ ------------------ 252| 1.01k| ctx->clockskew = tmp; 253| | 254| 1.01k| retval = profile_get_string(ctx->profile, KRB5_CONF_LIBDEFAULTS, ------------------ | | 272| 1.01k|#define KRB5_CONF_LIBDEFAULTS "libdefaults" ------------------ 255| 1.01k| KRB5_CONF_REQUEST_TIMEOUT, NULL, NULL, ------------------ | | 303| 1.01k|#define KRB5_CONF_REQUEST_TIMEOUT "request_timeout" ------------------ 256| 1.01k| &timeout_str); 257| 1.01k| if (retval) ------------------ | Branch (257:9): [True: 0, False: 1.01k] ------------------ 258| 0| goto cleanup; 259| 1.01k| if (timeout_str != NULL) { ------------------ | Branch (259:9): [True: 0, False: 1.01k] ------------------ 260| 0| retval = krb5_string_to_deltat(timeout_str, &ctx->req_timeout); 261| 0| if (retval) ------------------ | Branch (261:13): [True: 0, False: 0] ------------------ 262| 0| goto cleanup; 263| 0| } 264| | 265| 1.01k| get_integer(ctx, KRB5_CONF_KDC_DEFAULT_OPTIONS, KDC_OPT_RENEWABLE_OK, ------------------ | | 244| 1.01k|#define KRB5_CONF_KDC_DEFAULT_OPTIONS "kdc_default_options" ------------------ get_integer(ctx, KRB5_CONF_KDC_DEFAULT_OPTIONS, KDC_OPT_RENEWABLE_OK, ------------------ | | 1649| 1.01k|#define KDC_OPT_RENEWABLE_OK 0x00000010 ------------------ 266| 1.01k| &tmp); 267| 1.01k| ctx->kdc_default_options = tmp; 268| 1.01k|#define DEFAULT_KDC_TIMESYNC 1 269| 1.01k| get_integer(ctx, KRB5_CONF_KDC_TIMESYNC, DEFAULT_KDC_TIMESYNC, &tmp); ------------------ | | 251| 1.01k|#define KRB5_CONF_KDC_TIMESYNC "kdc_timesync" ------------------ get_integer(ctx, KRB5_CONF_KDC_TIMESYNC, DEFAULT_KDC_TIMESYNC, &tmp); ------------------ | | 268| 1.01k|#define DEFAULT_KDC_TIMESYNC 1 ------------------ 270| 1.01k| ctx->library_options = tmp ? KRB5_LIBOPT_SYNC_KDCTIME : 0; ------------------ | | 1271| 1.01k|#define KRB5_LIBOPT_SYNC_KDCTIME 0x0001 ------------------ | Branch (270:28): [True: 1.01k, False: 0] ------------------ 271| | 272| 1.01k| retval = profile_get_string(ctx->profile, KRB5_CONF_LIBDEFAULTS, ------------------ | | 272| 1.01k|#define KRB5_CONF_LIBDEFAULTS "libdefaults" ------------------ 273| 1.01k| KRB5_CONF_PLUGIN_BASE_DIR, 0, ------------------ | | 287| 1.01k|#define KRB5_CONF_PLUGIN_BASE_DIR "plugin_base_dir" ------------------ 274| 1.01k| DEFAULT_PLUGIN_BASE_DIR, &plugin_dir); ------------------ | | 61| 1.01k|#define DEFAULT_PLUGIN_BASE_DIR "/usr/local/lib/krb5/plugins" ------------------ 275| 1.01k| if (!retval) ------------------ | Branch (275:9): [True: 1.01k, False: 0] ------------------ 276| 1.01k| retval = k5_expand_path_tokens(ctx, plugin_dir, &ctx->plugin_base_dir); 277| 1.01k| if (retval) { ------------------ | Branch (277:9): [True: 0, False: 1.01k] ------------------ 278| 0| TRACE_PROFILE_ERR(ctx, KRB5_CONF_PLUGIN_BASE_DIR, ------------------ | | 357| 0| TRACE(c, "Bad value of {str} from [{str}] in conf file: {kerr}", \ | | ------------------ | | | | 100| 0| do { if (ctx->trace_callback != NULL) \ | | | | ------------------ | | | | | Branch (100:14): [True: 0, False: 0] | | | | ------------------ | | | | 101| 0| krb5int_trace(ctx, __VA_ARGS__); } while (0) | | | | ------------------ | | | | | Branch (101:55): [Folded, False: 0] | | | | ------------------ | | ------------------ | | 358| 0| subsection, section, retval) ------------------ 279| 0| KRB5_CONF_LIBDEFAULTS, retval); 280| 0| goto cleanup; 281| 0| } 282| | 283| | /* 284| | * We use a default file credentials cache of 3. See 285| | * lib/krb5/krb/ccache/file/fcc.h for a description of the 286| | * credentials cache types. 287| | * 288| | * Note: DCE 1.0.3a only supports a cache type of 1 289| | * DCE 1.1 supports a cache type of 2. 290| | */ 291| 1.01k|#define DEFAULT_CCACHE_TYPE 4 292| 1.01k| get_integer(ctx, KRB5_CONF_CCACHE_TYPE, DEFAULT_CCACHE_TYPE, &tmp); ------------------ | | 190| 1.01k|#define KRB5_CONF_CCACHE_TYPE "ccache_type" ------------------ get_integer(ctx, KRB5_CONF_CCACHE_TYPE, DEFAULT_CCACHE_TYPE, &tmp); ------------------ | | 291| 1.01k|#define DEFAULT_CCACHE_TYPE 4 ------------------ 293| 1.01k| ctx->fcc_default_format = tmp + 0x0500; 294| 1.01k| ctx->prompt_types = 0; 295| 1.01k| ctx->use_conf_ktypes = 0; 296| 1.01k| ctx->udp_pref_limit = -1; 297| | 298| | /* It's OK if this fails */ 299| 1.01k| (void)profile_get_string(ctx->profile, KRB5_CONF_LIBDEFAULTS, ------------------ | | 272| 1.01k|#define KRB5_CONF_LIBDEFAULTS "libdefaults" ------------------ 300| 1.01k| KRB5_CONF_ERR_FMT, NULL, NULL, &ctx->err_fmt); ------------------ | | 221| 1.01k|#define KRB5_CONF_ERR_FMT "err_fmt" ------------------ 301| 1.01k| *context_out = ctx; 302| 1.01k| ctx = NULL; 303| | 304| 1.01k|cleanup: 305| 1.01k| profile_release_string(plugin_dir); 306| 1.01k| profile_release_string(timeout_str); 307| 1.01k| krb5_free_context(ctx); 308| 1.01k| return retval; 309| 1.01k|} krb5_free_context: 313| 2.02k|{ 314| 2.02k| if (ctx == NULL) ------------------ | Branch (314:9): [True: 1.01k, False: 1.01k] ------------------ 315| 1.01k| return; 316| 1.01k| k5_os_free_context(ctx); 317| | 318| 1.01k| free(ctx->tgs_etypes); 319| 1.01k| ctx->tgs_etypes = NULL; 320| 1.01k| free(ctx->default_realm); 321| 1.01k| ctx->default_realm = 0; 322| | 323| 1.01k| krb5_clear_error_message(ctx); 324| 1.01k| free(ctx->err_fmt); 325| | 326| 1.01k|#ifndef DISABLE_TRACING 327| 1.01k| if (ctx->trace_callback) ------------------ | Branch (327:9): [True: 0, False: 1.01k] ------------------ 328| 0| ctx->trace_callback(ctx, NULL, ctx->trace_callback_data); 329| 1.01k|#endif 330| | 331| 1.01k| k5_ccselect_free_context(ctx); 332| 1.01k| k5_hostrealm_free_context(ctx); 333| 1.01k| k5_localauth_free_context(ctx); 334| 1.01k| k5_plugin_free_context(ctx); 335| 1.01k| free(ctx->plugin_base_dir); 336| 1.01k| free(ctx->tls); 337| | 338| 1.01k| ctx->magic = 0; 339| 1.01k| free(ctx); 340| 1.01k|} init_ctx.c:get_boolean: 89| 5.07k|{ 90| 5.07k| krb5_error_code retval; 91| | 92| 5.07k| retval = profile_get_boolean(ctx->profile, KRB5_CONF_LIBDEFAULTS, ------------------ | | 272| 5.07k|#define KRB5_CONF_LIBDEFAULTS "libdefaults" ------------------ 93| 5.07k| name, NULL, def_val, boolean_out); 94| 5.07k| if (retval) ------------------ | Branch (94:9): [True: 0, False: 5.07k] ------------------ 95| | TRACE_PROFILE_ERR(ctx, name, KRB5_CONF_LIBDEFAULTS, retval); ------------------ | | 357| 0| TRACE(c, "Bad value of {str} from [{str}] in conf file: {kerr}", \ | | ------------------ | | | | 100| 0| do { if (ctx->trace_callback != NULL) \ | | | | ------------------ | | | | | Branch (100:14): [True: 0, False: 0] | | | | ------------------ | | | | 101| 0| krb5int_trace(ctx, __VA_ARGS__); } while (0) | | | | ------------------ | | | | | Branch (101:55): [Folded, False: 0] | | | | ------------------ | | ------------------ | | 358| 5.07k| subsection, section, retval) ------------------ 96| 5.07k| return retval; 97| 5.07k|} init_ctx.c:get_tristate: 102| 1.01k|{ 103| 1.01k| krb5_error_code retval; 104| 1.01k| char *str; 105| 1.01k| int match; 106| | 107| 1.01k| retval = profile_get_boolean(ctx->profile, KRB5_CONF_LIBDEFAULTS, name, ------------------ | | 272| 1.01k|#define KRB5_CONF_LIBDEFAULTS "libdefaults" ------------------ 108| 1.01k| NULL, def_val, val_out); 109| 1.01k| if (retval != PROF_BAD_BOOLEAN) ------------------ | | 334| 1.01k|#define PROF_BAD_BOOLEAN (-1429577700L) ------------------ | Branch (109:9): [True: 1.01k, False: 0] ------------------ 110| 1.01k| return retval; 111| 0| retval = profile_get_string(ctx->profile, KRB5_CONF_LIBDEFAULTS, name, ------------------ | | 272| 0|#define KRB5_CONF_LIBDEFAULTS "libdefaults" ------------------ 112| 0| NULL, NULL, &str); 113| 0| if (retval) ------------------ | Branch (113:9): [True: 0, False: 0] ------------------ 114| 0| return retval; 115| 0| match = (strcasecmp(third_option, str) == 0); 116| 0| free(str); 117| 0| if (!match) ------------------ | Branch (117:9): [True: 0, False: 0] ------------------ 118| 0| return EINVAL; 119| 0| *val_out = third_option_val; 120| 0| return 0; 121| 0|} init_ctx.c:get_integer: 77| 4.05k|{ 78| 4.05k| krb5_error_code retval; 79| | 80| 4.05k| retval = profile_get_integer(ctx->profile, KRB5_CONF_LIBDEFAULTS, ------------------ | | 272| 4.05k|#define KRB5_CONF_LIBDEFAULTS "libdefaults" ------------------ 81| 4.05k| name, NULL, def_val, int_out); 82| 4.05k| if (retval) ------------------ | Branch (82:9): [True: 0, False: 4.05k] ------------------ 83| | TRACE_PROFILE_ERR(ctx, name, KRB5_CONF_LIBDEFAULTS, retval); ------------------ | | 357| 0| TRACE(c, "Bad value of {str} from [{str}] in conf file: {kerr}", \ | | ------------------ | | | | 100| 0| do { if (ctx->trace_callback != NULL) \ | | | | ------------------ | | | | | Branch (100:14): [True: 0, False: 0] | | | | ------------------ | | | | 101| 0| krb5int_trace(ctx, __VA_ARGS__); } while (0) | | | | ------------------ | | | | | Branch (101:55): [Folded, False: 0] | | | | ------------------ | | ------------------ | | 358| 4.05k| subsection, section, retval) ------------------ 84| 4.05k| return retval; 85| 4.05k|} krb5_clear_error_message: 206| 1.01k|{ 207| |#ifdef DEBUG 208| | if (ERROR_MESSAGE_DEBUG()) 209| | fprintf(stderr, "krb5_clear_error_message(%p)\n", ctx); 210| |#endif 211| 1.01k| if (ctx == NULL) ------------------ | Branch (211:9): [True: 0, False: 1.01k] ------------------ 212| 0| return; 213| 1.01k| k5_clear_error(&ctx->err); 214| 1.01k|} krb5_free_principal: 400| 3.04k|{ 401| 3.04k| krb5_int32 i; 402| | 403| 3.04k| if (!val) ------------------ | Branch (403:9): [True: 2.02k, False: 1.01k] ------------------ 404| 2.02k| return; 405| | 406| 1.01k| if (val->data) { ------------------ | Branch (406:9): [True: 1.01k, False: 0] ------------------ 407| 1.01k| i = val->length; 408| 2.02k| while(--i >= 0) ------------------ | Branch (408:15): [True: 1.01k, False: 1.01k] ------------------ 409| 1.01k| free(val->data[i].data); 410| 1.01k| free(val->data); 411| 1.01k| } 412| 1.01k| free(val->realm.data); 413| 1.01k| free(val); 414| 1.01k|} krb5_free_unparsed_name: 496| 1.53k|{ 497| 1.53k| if (val != NULL) ------------------ | Branch (497:9): [True: 1.53k, False: 0] ------------------ 498| 1.53k| free(val); 499| 1.53k|} krb5_pac_free: 119| 890|{ 120| 890| if (pac != NULL) { ------------------ | Branch (120:9): [True: 890, False: 0] ------------------ 121| 890| zapfree(pac->data.data, pac->data.length); 122| 890| free(pac->buffers); 123| 890| zapfree(pac, sizeof(*pac)); 124| 890| } 125| 890|} k5_pac_locate_buffer: 130| 2.40k|{ 131| 2.40k| struct k5_pac_buffer *buffer = NULL; 132| 2.40k| size_t i; 133| | 134| 2.40k| if (pac == NULL) ------------------ | Branch (134:9): [True: 0, False: 2.40k] ------------------ 135| 0| return EINVAL; 136| | 137| 7.74k| for (i = 0; i < pac->nbuffers; i++) { ------------------ | Branch (137:17): [True: 5.35k, False: 2.39k] ------------------ 138| 5.35k| if (pac->buffers[i].type == type) { ------------------ | Branch (138:13): [True: 2.25k, False: 3.09k] ------------------ 139| 2.25k| if (buffer == NULL) ------------------ | Branch (139:17): [True: 2.24k, False: 9] ------------------ 140| 2.24k| buffer = &pac->buffers[i]; 141| 9| else 142| 9| return EINVAL; 143| 2.25k| } 144| 5.35k| } 145| | 146| 2.39k| if (buffer == NULL) ------------------ | Branch (146:9): [True: 159, False: 2.23k] ------------------ 147| 159| return ENOENT; 148| | 149| 2.39k| assert(buffer->offset <= pac->data.length); ------------------ | Branch (149:5): [True: 0, False: 2.23k] | Branch (149:5): [True: 2.23k, False: 0] ------------------ 150| 2.23k| assert(buffer->size <= pac->data.length - buffer->offset); ------------------ | Branch (150:5): [True: 0, False: 2.23k] | Branch (150:5): [True: 2.23k, False: 0] ------------------ 151| | 152| 2.23k| if (data_out != NULL) ------------------ | Branch (152:9): [True: 2.23k, False: 0] ------------------ 153| 2.23k| *data_out = make_data(pac->data.data + buffer->offset, buffer->size); 154| | 155| 2.23k| return 0; 156| 2.23k|} krb5_pac_init: 202| 890|{ 203| 890| krb5_error_code ret; 204| 890| krb5_pac pac; 205| | 206| 890| *pac_out = NULL; 207| | 208| 890| pac = malloc(sizeof(*pac)); 209| 890| if (pac == NULL) ------------------ | Branch (209:9): [True: 0, False: 890] ------------------ 210| 0| return ENOMEM; 211| | 212| 890| pac->nbuffers = 0; 213| 890| pac->buffers = NULL; 214| 890| pac->version = 0; 215| | 216| 890| pac->data.length = PACTYPE_LENGTH; ------------------ | | 68| 890|#define PACTYPE_LENGTH 8U ------------------ 217| 890| pac->data.data = k5alloc(pac->data.length, &ret); 218| 890| if (pac->data.data == NULL) { ------------------ | Branch (218:9): [True: 0, False: 890] ------------------ 219| 0| free(pac); 220| 0| return ret; 221| 0| } 222| | 223| 890| pac->verified = FALSE; ------------------ | | 164| 890|#define FALSE 0 ------------------ 224| | 225| 890| *pac_out = pac; 226| 890| return 0; 227| 890|} krb5_pac_parse: 266| 1.01k|{ 267| 1.01k| krb5_error_code ret; 268| 1.01k| size_t i; 269| 1.01k| krb5_pac pac; 270| 1.01k| size_t header_len; 271| 1.01k| uint32_t nbuffers, version; 272| 1.01k| struct k5input in; 273| 1.01k| char *ndata; 274| | 275| 1.01k| *ppac = NULL; 276| | 277| 1.01k| k5_input_init(&in, ptr, len); 278| | 279| 1.01k| nbuffers = k5_input_get_uint32_le(&in); 280| 1.01k| version = k5_input_get_uint32_le(&in); 281| 1.01k| if (in.status || version != 0) ------------------ | Branch (281:9): [True: 6, False: 1.00k] | Branch (281:22): [True: 49, False: 959] ------------------ 282| 55| return EINVAL; 283| | 284| 959| if (nbuffers < 1 || nbuffers > MAX_BUFFERS) ------------------ | | 32| 958|#define MAX_BUFFERS 4096 ------------------ | Branch (284:9): [True: 1, False: 958] | Branch (284:25): [True: 48, False: 910] ------------------ 285| 49| return ERANGE; 286| | 287| 910| header_len = PACTYPE_LENGTH + (nbuffers * PAC_INFO_BUFFER_LENGTH); ------------------ | | 68| 910|#define PACTYPE_LENGTH 8U ------------------ header_len = PACTYPE_LENGTH + (nbuffers * PAC_INFO_BUFFER_LENGTH); ------------------ | | 71| 910|#define PAC_INFO_BUFFER_LENGTH 16 ------------------ 288| 910| if (len < header_len) ------------------ | Branch (288:9): [True: 20, False: 890] ------------------ 289| 20| return ERANGE; 290| | 291| 890| ret = krb5_pac_init(context, &pac); 292| 890| if (ret) ------------------ | Branch (292:9): [True: 0, False: 890] ------------------ 293| 0| return ret; 294| | 295| 890| pac->buffers = k5calloc(nbuffers, sizeof(*pac->buffers), &ret); 296| 890| if (ret) ------------------ | Branch (296:9): [True: 0, False: 890] ------------------ 297| 0| goto fail; 298| | 299| 890| pac->nbuffers = nbuffers; 300| 890| pac->version = version; 301| | 302| 2.46k| for (i = 0; i < nbuffers; i++) { ------------------ | Branch (302:17): [True: 1.72k, False: 738] ------------------ 303| 1.72k| struct k5_pac_buffer *buffer = &pac->buffers[i]; 304| | 305| 1.72k| buffer->type = k5_input_get_uint32_le(&in); 306| 1.72k| buffer->size = k5_input_get_uint32_le(&in); 307| 1.72k| buffer->offset = k5_input_get_uint64_le(&in); 308| | 309| 1.72k| if (in.status || buffer->offset % PAC_ALIGNMENT) { ------------------ | | 67| 1.72k|#define PAC_ALIGNMENT 8 ------------------ | Branch (309:13): [True: 0, False: 1.72k] | Branch (309:26): [True: 5, False: 1.71k] ------------------ 310| 5| ret = EINVAL; 311| 5| goto fail; 312| 5| } 313| 1.71k| if (buffer->offset < header_len || buffer->offset > len || ------------------ | Branch (313:13): [True: 1, False: 1.71k] | Branch (313:44): [True: 114, False: 1.60k] ------------------ 314| 1.60k| buffer->size > len - buffer->offset) { ------------------ | Branch (314:13): [True: 32, False: 1.57k] ------------------ 315| 147| ret = ERANGE; 316| 147| goto fail; 317| 147| } 318| 1.71k| } 319| | 320| 738| ndata = realloc(pac->data.data, len); 321| 738| if (ndata == NULL) { ------------------ | Branch (321:9): [True: 0, False: 738] ------------------ 322| 0| krb5_pac_free(context, pac); 323| 0| return ENOMEM; 324| 0| } 325| 738| pac->data.data = ndata; 326| 738| memcpy(ndata, ptr, len); 327| | 328| 738| pac->data.length = len; 329| | 330| 738| *ppac = pac; 331| | 332| 738| return 0; 333| | 334| 152|fail: 335| 152| krb5_pac_free(context, pac); 336| 152| return ret; 337| 738|} krb5_pac_get_client_info: 362| 2.21k|{ 363| 2.21k| krb5_error_code ret; 364| 2.21k| krb5_data client_info; 365| 2.21k| char *pac_princname; 366| 2.21k| unsigned char *p; 367| 2.21k| krb5_timestamp pac_authtime; 368| 2.21k| uint16_t pac_princname_length; 369| 2.21k| uint64_t pac_nt_authtime; 370| | 371| 2.21k| if (authtime_out != NULL) ------------------ | Branch (371:9): [True: 2.21k, False: 0] ------------------ 372| 2.21k| *authtime_out = 0; 373| 2.21k| *princname_out = NULL; 374| | 375| 2.21k| ret = k5_pac_locate_buffer(context, pac, KRB5_PAC_CLIENT_INFO, ------------------ | | 8181| 2.21k|#define KRB5_PAC_CLIENT_INFO 10 /**< Client name and ticket info */ ------------------ 376| 2.21k| &client_info); 377| 2.21k| if (ret) ------------------ | Branch (377:9): [True: 165, False: 2.04k] ------------------ 378| 165| return ret; 379| | 380| 2.04k| if (client_info.length < PAC_CLIENT_INFO_LENGTH) ------------------ | | 70| 2.04k|#define PAC_CLIENT_INFO_LENGTH 10U ------------------ | Branch (380:9): [True: 63, False: 1.98k] ------------------ 381| 63| return ERANGE; 382| | 383| 1.98k| p = (unsigned char *)client_info.data; 384| 1.98k| pac_nt_authtime = load_64_le(p); 385| 1.98k| p += 8; 386| 1.98k| pac_princname_length = load_16_le(p); 387| 1.98k| p += 2; 388| | 389| 1.98k| ret = k5_time_to_seconds_since_1970(pac_nt_authtime, &pac_authtime); 390| 1.98k| if (ret) ------------------ | Branch (390:9): [True: 129, False: 1.85k] ------------------ 391| 129| return ret; 392| | 393| 1.85k| if (client_info.length < PAC_CLIENT_INFO_LENGTH + pac_princname_length || ------------------ | | 70| 1.85k|#define PAC_CLIENT_INFO_LENGTH 10U ------------------ | Branch (393:9): [True: 123, False: 1.73k] ------------------ 394| 1.73k| pac_princname_length % 2) ------------------ | Branch (394:9): [True: 3, False: 1.73k] ------------------ 395| 126| return ERANGE; 396| | 397| 1.73k| ret = k5_utf16le_to_utf8(p, pac_princname_length, &pac_princname); 398| 1.73k| if (ret) ------------------ | Branch (398:9): [True: 192, False: 1.53k] ------------------ 399| 192| return ret; 400| | 401| 1.53k| if (authtime_out != NULL) ------------------ | Branch (401:9): [True: 1.53k, False: 0] ------------------ 402| 1.53k| *authtime_out = pac_authtime; 403| 1.53k| *princname_out = pac_princname; 404| | 405| 1.53k| return 0; 406| 1.73k|} k5_pac_validate_client: 412| 2.21k|{ 413| 2.21k| krb5_error_code ret; 414| 2.21k| char *pac_princname, *princname; 415| 2.21k| krb5_timestamp pac_authtime; 416| 2.21k| int flags = 0; 417| | 418| 2.21k| ret = krb5_pac_get_client_info(context, pac, &pac_authtime, 419| 2.21k| &pac_princname); 420| 2.21k| if (ret) ------------------ | Branch (420:9): [True: 675, False: 1.53k] ------------------ 421| 675| return ret; 422| | 423| 1.53k| flags = KRB5_PRINCIPAL_UNPARSE_DISPLAY; ------------------ | | 3544| 1.53k|#define KRB5_PRINCIPAL_UNPARSE_DISPLAY 0x4 /**< Don't escape special characters */ ------------------ 424| 1.53k| if (!with_realm) ------------------ | Branch (424:9): [True: 1.02k, False: 513] ------------------ 425| 1.02k| flags |= KRB5_PRINCIPAL_UNPARSE_NO_REALM; ------------------ | | 3543| 1.02k|#define KRB5_PRINCIPAL_UNPARSE_NO_REALM 0x2 /**< Omit realm always */ ------------------ 426| | 427| 1.53k| ret = krb5_unparse_name_flags(context, principal, flags, &princname); 428| 1.53k| if (ret) { ------------------ | Branch (428:9): [True: 0, False: 1.53k] ------------------ 429| 0| free(pac_princname); 430| 0| return ret; 431| 0| } 432| | 433| 1.53k| if (pac_authtime != authtime || strcmp(pac_princname, princname) != 0) ------------------ | Branch (433:9): [True: 414, False: 1.12k] | Branch (433:37): [True: 621, False: 504] ------------------ 434| 1.03k| ret = KRB5KRB_AP_WRONG_PRINC; ------------------ | | 8797| 1.03k|#define KRB5KRB_AP_WRONG_PRINC (-1765328240L) ------------------ 435| | 436| 1.53k| free(pac_princname); 437| 1.53k| krb5_free_unparsed_name(context, princname); 438| | 439| 1.53k| return ret; 440| 1.53k|} krb5_pac_verify: 700| 1.47k|{ 701| 1.47k| return krb5_pac_verify_ext(context, pac, authtime, principal, server, 702| 1.47k| privsvr, FALSE); ------------------ | | 164| 1.47k|#define FALSE 0 ------------------ 703| 1.47k|} krb5_pac_verify_ext: 713| 2.21k|{ 714| 2.21k| krb5_error_code ret; 715| | 716| | /* Validate the client first, so that the PAC is only marked as verified 717| | * if all of the requested checks pass. */ 718| 2.21k| if (principal != NULL) { ------------------ | Branch (718:9): [True: 2.21k, False: 0] ------------------ 719| 2.21k| ret = k5_pac_validate_client(context, pac, authtime, 720| 2.21k| principal, with_realm); 721| 2.21k| if (ret) ------------------ | Branch (721:13): [True: 1.71k, False: 504] ------------------ 722| 1.71k| return ret; 723| 2.21k| } 724| | 725| 504| if (server != NULL || privsvr != NULL) { ------------------ | Branch (725:9): [True: 252, False: 252] | Branch (725:27): [True: 0, False: 252] ------------------ 726| 252| ret = verify_pac_checksums(context, pac, FALSE, server, privsvr); ------------------ | | 164| 252|#define FALSE 0 ------------------ 727| 252| if (ret) ------------------ | Branch (727:13): [True: 251, False: 1] ------------------ 728| 251| return ret; 729| 252| } 730| | 731| 253| return 0; 732| 504|} pac.c:k5_time_to_seconds_since_1970: 341| 1.98k|{ 342| 1.98k| uint64_t abstime = ntTime / 10000000 - NT_TIME_EPOCH; ------------------ | | 73| 1.98k|#define NT_TIME_EPOCH 11644473600LL ------------------ 343| | 344| 1.98k| if (abstime > UINT32_MAX) ------------------ | Branch (344:9): [True: 129, False: 1.85k] ------------------ 345| 129| return ERANGE; 346| 1.85k| *elapsedSeconds = abstime; 347| 1.85k| return 0; 348| 1.98k|} pac.c:verify_checksum: 482| 188|{ 483| 188| krb5_error_code ret; 484| 188| krb5_data buffer; 485| 188| krb5_cksumtype cksumtype; 486| 188| krb5_checksum checksum; 487| 188| krb5_boolean valid; 488| 188| size_t cksumlen; 489| | 490| 188| ret = k5_pac_locate_buffer(context, pac, buffer_type, &buffer); 491| 188| if (ret) ------------------ | Branch (491:9): [True: 3, False: 185] ------------------ 492| 3| return ret; 493| 185| if (buffer.length < PAC_SIGNATURE_DATA_LENGTH) ------------------ | | 69| 185|#define PAC_SIGNATURE_DATA_LENGTH 4U ------------------ | Branch (493:9): [True: 0, False: 185] ------------------ 494| 0| return KRB5_BAD_MSIZE; ------------------ | | 8843| 0|#define KRB5_BAD_MSIZE (-1765328194L) ------------------ 495| | 496| 185| cksumtype = load_32_le(buffer.data); 497| 185| if (buffer_type == KRB5_PAC_SERVER_CHECKSUM && cksumtype == CKSUMTYPE_SHA1) ------------------ | | 8179| 370|#define KRB5_PAC_SERVER_CHECKSUM 6 /**< Server checksum */ ------------------ if (buffer_type == KRB5_PAC_SERVER_CHECKSUM && cksumtype == CKSUMTYPE_SHA1) ------------------ | | 469| 183|#define CKSUMTYPE_SHA1 0x000e /**< RFC 3961 */ ------------------ | Branch (497:9): [True: 183, False: 2] | Branch (497:52): [True: 1, False: 182] ------------------ 498| 1| return KRB5KDC_ERR_SUMTYPE_NOSUPP; ------------------ | | 8668| 1|#define KRB5KDC_ERR_SUMTYPE_NOSUPP (-1765328369L) ------------------ 499| 184| if (!krb5_c_is_keyed_cksum(cksumtype)) ------------------ | Branch (499:9): [True: 91, False: 93] ------------------ 500| 91| return KRB5KRB_ERR_GENERIC; ------------------ | | 8713| 91|#define KRB5KRB_ERR_GENERIC (-1765328324L) ------------------ 501| | 502| | /* There may be an RODCIdentifier trailer (see [MS-PAC] 2.8), so look up 503| | * the length of the checksum by its type. */ 504| 93| ret = krb5_c_checksum_length(context, cksumtype, &cksumlen); 505| 93| if (ret) ------------------ | Branch (505:9): [True: 0, False: 93] ------------------ 506| 0| return ret; 507| 93| if (cksumlen > buffer.length - PAC_SIGNATURE_DATA_LENGTH) ------------------ | | 69| 93|#define PAC_SIGNATURE_DATA_LENGTH 4U ------------------ | Branch (507:9): [True: 9, False: 84] ------------------ 508| 9| return KRB5_BAD_MSIZE; ------------------ | | 8843| 9|#define KRB5_BAD_MSIZE (-1765328194L) ------------------ 509| 84| checksum.checksum_type = cksumtype; 510| 84| checksum.length = cksumlen; 511| 84| checksum.contents = (uint8_t *)buffer.data + PAC_SIGNATURE_DATA_LENGTH; ------------------ | | 69| 84|#define PAC_SIGNATURE_DATA_LENGTH 4U ------------------ 512| | 513| 84| ret = krb5_c_verify_checksum(context, key, usage, data, &checksum, &valid); 514| 84| return ret ? ret : (valid ? 0 : KRB5KRB_AP_ERR_MODIFIED); ------------------ | | 8694| 76|#define KRB5KRB_AP_ERR_MODIFIED (-1765328343L) ------------------ | Branch (514:12): [True: 5, False: 79] | Branch (514:25): [True: 3, False: 76] ------------------ 515| 93|} pac.c:verify_pac_checksums: 521| 252|{ 522| 252| krb5_error_code ret; 523| 252| krb5_data copy, server_checksum; 524| | 525| | /* Make a copy of the PAC with zeroed out server and privsvr checksums. */ 526| 252| ret = krb5int_copy_data_contents(context, &pac->data, ©); 527| 252| if (ret) ------------------ | Branch (527:9): [True: 0, False: 252] ------------------ 528| 0| return ret; 529| | 530| 252| ret = zero_signature(context, pac, KRB5_PAC_SERVER_CHECKSUM, ©); ------------------ | | 8179| 252|#define KRB5_PAC_SERVER_CHECKSUM 6 /**< Server checksum */ ------------------ 531| 252| if (ret) ------------------ | Branch (531:9): [True: 31, False: 221] ------------------ 532| 31| goto cleanup; 533| 221| ret = zero_signature(context, pac, KRB5_PAC_PRIVSVR_CHECKSUM, ©); ------------------ | | 8180| 221|#define KRB5_PAC_PRIVSVR_CHECKSUM 7 /**< KDC checksum */ ------------------ 534| 221| if (ret) ------------------ | Branch (534:9): [True: 35, False: 186] ------------------ 535| 35| goto cleanup; 536| | 537| 186| if (server != NULL) { ------------------ | Branch (537:9): [True: 186, False: 0] ------------------ 538| | /* Verify the server checksum over the PAC copy. */ 539| 186| ret = verify_checksum(context, pac, KRB5_PAC_SERVER_CHECKSUM, server, ------------------ | | 8179| 186|#define KRB5_PAC_SERVER_CHECKSUM 6 /**< Server checksum */ ------------------ 540| 186| KRB5_KEYUSAGE_APP_DATA_CKSUM, ©); ------------------ | | 963| 186|#define KRB5_KEYUSAGE_APP_DATA_CKSUM 17 ------------------ 541| 186| if (ret) ------------------ | Branch (541:13): [True: 184, False: 2] ------------------ 542| 184| goto cleanup; 543| 186| } 544| | 545| 2| if (privsvr != NULL && expect_full_checksum) { ------------------ | Branch (545:9): [True: 2, False: 0] | Branch (545:28): [True: 0, False: 2] ------------------ 546| | /* Zero the full checksum buffer in the copy and verify the full 547| | * checksum over the copy with all three checksums zeroed. */ 548| 0| ret = zero_signature(context, pac, KRB5_PAC_FULL_CHECKSUM, ©); ------------------ | | 8190| 0|#define KRB5_PAC_FULL_CHECKSUM 19 /**< KDC full checksum */ ------------------ 549| 0| if (ret) ------------------ | Branch (549:13): [True: 0, False: 0] ------------------ 550| 0| goto cleanup; 551| 0| ret = verify_checksum(context, pac, KRB5_PAC_FULL_CHECKSUM, privsvr, ------------------ | | 8190| 0|#define KRB5_PAC_FULL_CHECKSUM 19 /**< KDC full checksum */ ------------------ 552| 0| KRB5_KEYUSAGE_APP_DATA_CKSUM, ©); ------------------ | | 963| 0|#define KRB5_KEYUSAGE_APP_DATA_CKSUM 17 ------------------ 553| 0| if (ret) ------------------ | Branch (553:13): [True: 0, False: 0] ------------------ 554| 0| goto cleanup; 555| 0| } 556| | 557| 2| if (privsvr != NULL) { ------------------ | Branch (557:9): [True: 2, False: 0] ------------------ 558| | /* Verify the privsvr checksum over the server checksum. */ 559| 2| ret = k5_pac_locate_buffer(context, pac, KRB5_PAC_SERVER_CHECKSUM, ------------------ | | 8179| 2|#define KRB5_PAC_SERVER_CHECKSUM 6 /**< Server checksum */ ------------------ 560| 2| &server_checksum); 561| 2| if (ret) ------------------ | Branch (561:13): [True: 0, False: 2] ------------------ 562| 0| goto cleanup; 563| 2| if (server_checksum.length < PAC_SIGNATURE_DATA_LENGTH) { ------------------ | | 69| 2|#define PAC_SIGNATURE_DATA_LENGTH 4U ------------------ | Branch (563:13): [True: 0, False: 2] ------------------ 564| 0| ret = KRB5_BAD_MSIZE; ------------------ | | 8843| 0|#define KRB5_BAD_MSIZE (-1765328194L) ------------------ 565| 0| goto cleanup; 566| 0| } 567| 2| server_checksum.data += PAC_SIGNATURE_DATA_LENGTH; ------------------ | | 69| 2|#define PAC_SIGNATURE_DATA_LENGTH 4U ------------------ 568| 2| server_checksum.length -= PAC_SIGNATURE_DATA_LENGTH; ------------------ | | 69| 2|#define PAC_SIGNATURE_DATA_LENGTH 4U ------------------ 569| | 570| 2| ret = verify_checksum(context, pac, KRB5_PAC_PRIVSVR_CHECKSUM, privsvr, ------------------ | | 8180| 2|#define KRB5_PAC_PRIVSVR_CHECKSUM 7 /**< KDC checksum */ ------------------ 571| 2| KRB5_KEYUSAGE_APP_DATA_CKSUM, &server_checksum); ------------------ | | 963| 2|#define KRB5_KEYUSAGE_APP_DATA_CKSUM 17 ------------------ 572| 2| if (ret) ------------------ | Branch (572:13): [True: 1, False: 1] ------------------ 573| 1| goto cleanup; 574| 2| } 575| | 576| 1| pac->verified = TRUE; ------------------ | | 167| 1|#define TRUE 1 ------------------ 577| | 578| 252|cleanup: 579| 252| free(copy.data); 580| 252| return ret; 581| 1|} pac.c:zero_signature: 446| 473|{ 447| 473| struct k5_pac_buffer *buffer = NULL; 448| 473| size_t i; 449| | 450| 473| assert(type == KRB5_PAC_SERVER_CHECKSUM || ------------------ | Branch (450:5): [True: 473, False: 0] | Branch (450:5): [True: 0, False: 0] | Branch (450:5): [True: 0, False: 0] | Branch (450:5): [True: 252, False: 221] | Branch (450:5): [True: 221, False: 0] | Branch (450:5): [True: 0, False: 0] ------------------ 451| 473| type == KRB5_PAC_PRIVSVR_CHECKSUM || 452| 473| type == KRB5_PAC_FULL_CHECKSUM); 453| 473| assert(data->length >= pac->data.length); ------------------ | Branch (453:5): [True: 0, False: 473] | Branch (453:5): [True: 473, False: 0] ------------------ 454| | 455| 1.33k| for (i = 0; i < pac->nbuffers; i++) { ------------------ | Branch (455:17): [True: 1.27k, False: 58] ------------------ 456| 1.27k| if (pac->buffers[i].type == type) { ------------------ | Branch (456:13): [True: 415, False: 859] ------------------ 457| 415| buffer = &pac->buffers[i]; 458| 415| break; 459| 415| } 460| 1.27k| } 461| | 462| 473| if (buffer == NULL) ------------------ | Branch (462:9): [True: 58, False: 415] ------------------ 463| 58| return ENOENT; 464| | 465| 415| if (buffer->size < PAC_SIGNATURE_DATA_LENGTH) ------------------ | | 69| 415|#define PAC_SIGNATURE_DATA_LENGTH 4U ------------------ | Branch (465:9): [True: 8, False: 407] ------------------ 466| 8| return KRB5_BAD_MSIZE; ------------------ | | 8843| 8|#define KRB5_BAD_MSIZE (-1765328194L) ------------------ 467| 407| if (buffer->size > pac->data.length || ------------------ | Branch (467:9): [True: 0, False: 407] ------------------ 468| 407| buffer->offset > pac->data.length - buffer->size) ------------------ | Branch (468:9): [True: 0, False: 407] ------------------ 469| 0| return ERANGE; 470| | 471| | /* Within the copy, zero out the data portion of the checksum only. */ 472| 407| memset(data->data + buffer->offset + PAC_SIGNATURE_DATA_LENGTH, 0, ------------------ | | 69| 407|#define PAC_SIGNATURE_DATA_LENGTH 4U ------------------ 473| 407| buffer->size - PAC_SIGNATURE_DATA_LENGTH); ------------------ | | 69| 407|#define PAC_SIGNATURE_DATA_LENGTH 4U ------------------ 474| | 475| 407| return 0; 476| 407|} krb5_parse_name_flags: 178| 1.01k|{ 179| 1.01k| krb5_error_code ret; 180| 1.01k| krb5_principal princ = NULL; 181| 1.01k| char *default_realm; 182| 1.01k| krb5_boolean has_realm; 183| 1.01k| krb5_boolean enterprise = (flags & KRB5_PRINCIPAL_PARSE_ENTERPRISE); ------------------ | | 3454| 1.01k|#define KRB5_PRINCIPAL_PARSE_ENTERPRISE 0x4 /**< Create single-component ------------------ 184| 1.01k| krb5_boolean require_realm = (flags & KRB5_PRINCIPAL_PARSE_REQUIRE_REALM); ------------------ | | 3453| 1.01k|#define KRB5_PRINCIPAL_PARSE_REQUIRE_REALM 0x2 /**< Error if realm is not present */ ------------------ 185| 1.01k| krb5_boolean no_realm = (flags & KRB5_PRINCIPAL_PARSE_NO_REALM); ------------------ | | 3452| 1.01k|#define KRB5_PRINCIPAL_PARSE_NO_REALM 0x1 /**< Error if realm is present */ ------------------ 186| 1.01k| krb5_boolean ignore_realm = (flags & KRB5_PRINCIPAL_PARSE_IGNORE_REALM); ------------------ | | 3456| 1.01k|#define KRB5_PRINCIPAL_PARSE_IGNORE_REALM 0x8 /**< Ignore realm if present */ ------------------ 187| 1.01k| krb5_boolean no_def_realm = (flags & KRB5_PRINCIPAL_PARSE_NO_DEF_REALM); ------------------ | | 3457| 1.01k|#define KRB5_PRINCIPAL_PARSE_NO_DEF_REALM 0x10 /**< Don't add default realm */ ------------------ 188| | 189| 1.01k| *principal_out = NULL; 190| | 191| 1.01k| ret = allocate_princ(context, name, enterprise, &princ, &has_realm); 192| 1.01k| if (ret) ------------------ | Branch (192:9): [True: 0, False: 1.01k] ------------------ 193| 0| goto cleanup; 194| 1.01k| parse_name_into_princ(name, enterprise, princ); 195| | 196| | /* If a realm was not included, use the default realm, unless flags 197| | * indicate otherwise. */ 198| 1.01k| if (!has_realm) { ------------------ | Branch (198:9): [True: 0, False: 1.01k] ------------------ 199| 0| if (require_realm) { ------------------ | Branch (199:13): [True: 0, False: 0] ------------------ 200| 0| ret = KRB5_PARSE_MALFORMED; ------------------ | | 8787| 0|#define KRB5_PARSE_MALFORMED (-1765328250L) ------------------ 201| 0| k5_setmsg(context, ret, ------------------ | | 2415| 0|#define k5_setmsg krb5_set_error_message ------------------ 202| 0| _("Principal %s is missing required realm"), name); ------------------ | | 1069| 0|#define _(s) dgettext(KRB5_TEXTDOMAIN, s) ------------------ 203| 0| goto cleanup; 204| 0| } 205| 0| if (!no_realm && !ignore_realm && !no_def_realm) { ------------------ | Branch (205:13): [True: 0, False: 0] | Branch (205:26): [True: 0, False: 0] | Branch (205:43): [True: 0, False: 0] ------------------ 206| 0| ret = krb5_get_default_realm(context, &default_realm); 207| 0| if (ret) ------------------ | Branch (207:17): [True: 0, False: 0] ------------------ 208| 0| goto cleanup; 209| 0| krb5_free_data_contents(context, &princ->realm); 210| 0| princ->realm = string2data(default_realm); 211| 0| } 212| 1.01k| } else if (no_realm) { ------------------ | Branch (212:16): [True: 0, False: 1.01k] ------------------ 213| 0| ret = KRB5_PARSE_MALFORMED; ------------------ | | 8787| 0|#define KRB5_PARSE_MALFORMED (-1765328250L) ------------------ 214| 0| k5_setmsg(context, ret, _("Principal %s has realm present"), name); ------------------ | | 2415| 0|#define k5_setmsg krb5_set_error_message ------------------ k5_setmsg(context, ret, _("Principal %s has realm present"), name); ------------------ | | 1069| 0|#define _(s) dgettext(KRB5_TEXTDOMAIN, s) ------------------ 215| 0| goto cleanup; 216| 1.01k| } else if (ignore_realm) { ------------------ | Branch (216:16): [True: 0, False: 1.01k] ------------------ 217| 0| krb5_free_data_contents(context, &princ->realm); 218| 0| princ->realm = empty_data(); 219| 0| } 220| | 221| 1.01k| princ->type = (enterprise) ? KRB5_NT_ENTERPRISE_PRINCIPAL : ------------------ | | 248| 0|#define KRB5_NT_ENTERPRISE_PRINCIPAL 10 /**< Windows 2000 UPN */ ------------------ | Branch (221:19): [True: 0, False: 1.01k] ------------------ 222| 1.01k| k5_infer_principal_type(princ); 223| | 224| 1.01k| princ->magic = KV5M_PRINCIPAL; ------------------ | | 9037| 1.01k|#define KV5M_PRINCIPAL (-1760647423L) ------------------ 225| 1.01k| *principal_out = princ; 226| 1.01k| princ = NULL; 227| | 228| 1.01k|cleanup: 229| 1.01k| krb5_free_principal(context, princ); 230| 1.01k| return ret; 231| 1.01k|} krb5_parse_name: 236| 1.01k|{ 237| 1.01k| return krb5_parse_name_flags(context, name, 0, principal_out); 238| 1.01k|} parse.c:allocate_princ: 39| 1.01k|{ 40| 1.01k| krb5_error_code ret; 41| 1.01k| const char *p; 42| 1.01k| krb5_boolean first_at = TRUE; ------------------ | | 167| 1.01k|#define TRUE 1 ------------------ 43| 1.01k| krb5_principal princ = NULL; 44| 1.01k| krb5_data *cur_data, *new_comps; 45| 1.01k| krb5_int32 i; 46| | 47| 1.01k| *princ_out = NULL; 48| 1.01k| *has_realm_out = FALSE; ------------------ | | 164| 1.01k|#define FALSE 0 ------------------ 49| | 50| | /* Allocate a starting principal with one component. */ 51| 1.01k| princ = k5alloc(sizeof(*princ), &ret); 52| 1.01k| if (princ == NULL) ------------------ | Branch (52:9): [True: 0, False: 1.01k] ------------------ 53| 0| goto cleanup; 54| 1.01k| princ->data = k5alloc(sizeof(*princ->data), &ret); 55| 1.01k| if (princ->data == NULL) ------------------ | Branch (55:9): [True: 0, False: 1.01k] ------------------ 56| 0| goto cleanup; 57| 1.01k| princ->realm = empty_data(); 58| 1.01k| princ->data[0] = empty_data(); 59| 1.01k| princ->length = 1; 60| | 61| 1.01k| cur_data = &princ->data[0]; 62| 33.4k| for (p = name; *p != '\0'; p++) { ------------------ | Branch (62:20): [True: 32.4k, False: 1.01k] ------------------ 63| 32.4k| if (*p == '/' && !enterprise) { ------------------ | Branch (63:13): [True: 0, False: 32.4k] | Branch (63:26): [True: 0, False: 0] ------------------ 64| | /* Component separator (for non-enterprise principals). We 65| | * shouldn't see this in the realm name. */ 66| 0| if (cur_data == &princ->realm) { ------------------ | Branch (66:17): [True: 0, False: 0] ------------------ 67| 0| ret = KRB5_PARSE_MALFORMED; ------------------ | | 8787| 0|#define KRB5_PARSE_MALFORMED (-1765328250L) ------------------ 68| 0| goto cleanup; 69| 0| } 70| 0| new_comps = realloc(princ->data, 71| 0| (princ->length + 1) * sizeof(*princ->data)); 72| 0| if (new_comps == NULL) { ------------------ | Branch (72:17): [True: 0, False: 0] ------------------ 73| 0| ret = ENOMEM; 74| 0| goto cleanup; 75| 0| } 76| 0| princ->data = new_comps; 77| 0| princ->length++; 78| 0| cur_data = &princ->data[princ->length - 1]; 79| 0| *cur_data = empty_data(); 80| 32.4k| } else if (*p == '@' && (!enterprise || !first_at)) { ------------------ | Branch (80:20): [True: 1.01k, False: 31.4k] | Branch (80:34): [True: 1.01k, False: 0] | Branch (80:49): [True: 0, False: 0] ------------------ 81| | /* Realm separator. In enterprise principals, the first one of 82| | * these we see is part of the component. */ 83| 1.01k| if (cur_data == &princ->realm) { ------------------ | Branch (83:17): [True: 0, False: 1.01k] ------------------ 84| 0| ret = KRB5_PARSE_MALFORMED; ------------------ | | 8787| 0|#define KRB5_PARSE_MALFORMED (-1765328250L) ------------------ 85| 0| goto cleanup; 86| 0| } 87| 1.01k| cur_data = &princ->realm; 88| 31.4k| } else { 89| | /* Component or realm character, possibly quoted. Make note if 90| | * we're seeing the first '@' in an enterprise principal. */ 91| 31.4k| cur_data->length++; 92| 31.4k| if (*p == '@' && enterprise) ------------------ | Branch (92:17): [True: 0, False: 31.4k] | Branch (92:30): [True: 0, False: 0] ------------------ 93| 0| first_at = FALSE; ------------------ | | 164| 0|#define FALSE 0 ------------------ 94| 31.4k| if (*p == '\\') { ------------------ | Branch (94:17): [True: 0, False: 31.4k] ------------------ 95| | /* Quote character can't be the last character of the name. */ 96| 0| if (*++p == '\0') { ------------------ | Branch (96:21): [True: 0, False: 0] ------------------ 97| 0| ret = KRB5_PARSE_MALFORMED; ------------------ | | 8787| 0|#define KRB5_PARSE_MALFORMED (-1765328250L) ------------------ 98| 0| goto cleanup; 99| 0| } 100| 0| } 101| 31.4k| } 102| 32.4k| } 103| | 104| | /* Allocate space for each component and the realm, with space for null 105| | * terminators on each field. */ 106| 2.02k| for (i = 0; i < princ->length; i++) { ------------------ | Branch (106:17): [True: 1.01k, False: 1.01k] ------------------ 107| 1.01k| princ->data[i].data = k5alloc(princ->data[i].length + 1, &ret); 108| 1.01k| if (princ->data[i].data == NULL) ------------------ | Branch (108:13): [True: 0, False: 1.01k] ------------------ 109| 0| goto cleanup; 110| 1.01k| } 111| 1.01k| princ->realm.data = k5alloc(princ->realm.length + 1, &ret); 112| 1.01k| if (princ->realm.data == NULL) ------------------ | Branch (112:9): [True: 0, False: 1.01k] ------------------ 113| 0| goto cleanup; 114| | 115| 1.01k| *princ_out = princ; 116| 1.01k| *has_realm_out = (cur_data == &princ->realm); 117| 1.01k| princ = NULL; 118| 1.01k|cleanup: 119| 1.01k| krb5_free_principal(context, princ); 120| 1.01k| return ret; 121| 1.01k|} parse.c:parse_name_into_princ: 132| 1.01k|{ 133| 1.01k| const char *p; 134| 1.01k| char c; 135| 1.01k| krb5_boolean first_at = TRUE; ------------------ | | 167| 1.01k|#define TRUE 1 ------------------ 136| 1.01k| krb5_data *cur_data = princ->data; 137| 1.01k| unsigned int pos = 0; 138| | 139| 33.4k| for (p = name; *p != '\0'; p++) { ------------------ | Branch (139:20): [True: 32.4k, False: 1.01k] ------------------ 140| 32.4k| if (*p == '/' && !enterprise) { ------------------ | Branch (140:13): [True: 0, False: 32.4k] | Branch (140:26): [True: 0, False: 0] ------------------ 141| | /* Advance to the next component. */ 142| 0| assert(pos == cur_data->length); ------------------ | Branch (142:13): [True: 0, False: 0] | Branch (142:13): [True: 0, False: 0] ------------------ 143| 0| assert(cur_data != &princ->realm); ------------------ | Branch (143:13): [True: 0, False: 0] | Branch (143:13): [True: 0, False: 0] ------------------ 144| 0| assert(cur_data - princ->data + 1 < princ->length); ------------------ | Branch (144:13): [True: 0, False: 0] | Branch (144:13): [True: 0, False: 0] ------------------ 145| 0| cur_data++; 146| 0| pos = 0; 147| 32.4k| } else if (*p == '@' && (!enterprise || !first_at)) { ------------------ | Branch (147:20): [True: 1.01k, False: 31.4k] | Branch (147:34): [True: 1.01k, False: 0] | Branch (147:49): [True: 0, False: 0] ------------------ 148| | /* Advance to the realm. */ 149| 1.01k| assert(pos == cur_data->length); ------------------ | Branch (149:13): [True: 0, False: 1.01k] | Branch (149:13): [True: 1.01k, False: 0] ------------------ 150| 1.01k| cur_data = &princ->realm; 151| 1.01k| pos = 0; 152| 31.4k| } else { 153| | /* Add to the current component or to the realm. */ 154| 31.4k| if (*p == '@' && enterprise) ------------------ | Branch (154:17): [True: 0, False: 31.4k] | Branch (154:30): [True: 0, False: 0] ------------------ 155| 0| first_at = FALSE; ------------------ | | 164| 0|#define FALSE 0 ------------------ 156| 31.4k| c = *p; 157| 31.4k| if (c == '\\') { ------------------ | Branch (157:17): [True: 0, False: 31.4k] ------------------ 158| 0| c = *++p; 159| 0| if (c == 'n') ------------------ | Branch (159:21): [True: 0, False: 0] ------------------ 160| 0| c = '\n'; 161| 0| else if (c == 't') ------------------ | Branch (161:26): [True: 0, False: 0] ------------------ 162| 0| c = '\t'; 163| 0| else if (c == 'b') ------------------ | Branch (163:26): [True: 0, False: 0] ------------------ 164| 0| c = '\b'; 165| 0| else if (c == '0') ------------------ | Branch (165:26): [True: 0, False: 0] ------------------ 166| 0| c = '\0'; 167| 0| } 168| 31.4k| assert(pos < cur_data->length); ------------------ | Branch (168:13): [True: 0, False: 31.4k] | Branch (168:13): [True: 31.4k, False: 0] ------------------ 169| 31.4k| cur_data->data[pos++] = c; 170| 31.4k| } 171| 32.4k| } 172| 1.01k| assert(pos == cur_data->length); ------------------ | Branch (172:5): [True: 0, False: 1.01k] | Branch (172:5): [True: 1.01k, False: 0] ------------------ 173| 1.01k|} k5_plugin_free_context: 505| 1.01k|{ 506| 1.01k| int i; 507| | 508| 14.1k| for (i = 0; i < PLUGIN_NUM_INTERFACES; i++) ------------------ | | 1150| 14.1k|#define PLUGIN_NUM_INTERFACES 13 ------------------ | Branch (508:17): [True: 13.1k, False: 1.01k] ------------------ 509| 13.1k| free_mapping_list(context->plugins[i].modules); 510| 1.01k| memset(context->plugins, 0, sizeof(context->plugins)); 511| 1.01k|} plugin.c:free_mapping_list: 90| 13.1k|{ 91| 13.1k| struct plugin_mapping **mp; 92| | 93| 13.1k| for (mp = list; mp != NULL && *mp != NULL; mp++) ------------------ | Branch (93:21): [True: 0, False: 13.1k] | Branch (93:35): [True: 0, False: 0] ------------------ 94| 0| free_plugin_mapping(*mp); 95| 13.1k| free(list); 96| 13.1k|} krb5_unparse_name_flags: 240| 1.53k|{ 241| 1.53k| if (name != NULL) ------------------ | Branch (241:9): [True: 1.53k, False: 0] ------------------ 242| 1.53k| *name = NULL; 243| | return k5_unparse_name(context, principal, flags, name, NULL); 244| 1.53k|} unparse.c:k5_unparse_name: 139| 1.53k|{ 140| 1.53k| char *q; 141| 1.53k| krb5_int32 i; 142| 1.53k| unsigned int totalsize = 0; 143| 1.53k| char *default_realm = NULL; 144| 1.53k| krb5_error_code ret = 0; 145| | 146| 1.53k| if (!principal || !name) ------------------ | Branch (146:9): [True: 0, False: 1.53k] | Branch (146:23): [True: 0, False: 1.53k] ------------------ 147| 0| return KRB5_PARSE_MALFORMED; ------------------ | | 8787| 0|#define KRB5_PARSE_MALFORMED (-1765328250L) ------------------ 148| | 149| 1.53k| if (flags & KRB5_PRINCIPAL_UNPARSE_SHORT) { ------------------ | | 3542| 1.53k|#define KRB5_PRINCIPAL_UNPARSE_SHORT 0x1 /**< Omit realm if it is the local realm */ ------------------ | Branch (149:9): [True: 0, False: 1.53k] ------------------ 150| | /* omit realm if local realm */ 151| 0| krb5_principal_data p; 152| | 153| 0| ret = krb5_get_default_realm(context, &default_realm); 154| 0| if (ret != 0) ------------------ | Branch (154:13): [True: 0, False: 0] ------------------ 155| 0| goto cleanup; 156| | 157| 0| p.realm = string2data(default_realm); 158| | 159| 0| if (krb5_realm_compare(context, &p, principal)) ------------------ | Branch (159:13): [True: 0, False: 0] ------------------ 160| 0| flags |= KRB5_PRINCIPAL_UNPARSE_NO_REALM; ------------------ | | 3543| 0|#define KRB5_PRINCIPAL_UNPARSE_NO_REALM 0x2 /**< Omit realm always */ ------------------ 161| 0| } 162| | 163| 1.53k| if ((flags & KRB5_PRINCIPAL_UNPARSE_NO_REALM) == 0) { ------------------ | | 3543| 1.53k|#define KRB5_PRINCIPAL_UNPARSE_NO_REALM 0x2 /**< Omit realm always */ ------------------ | Branch (163:9): [True: 513, False: 1.02k] ------------------ 164| 513| totalsize += component_length_quoted(&principal->realm, flags); 165| 513| totalsize++; /* This is for the separator */ 166| 513| } 167| | 168| 3.07k| for (i = 0; i < principal->length; i++) { ------------------ | Branch (168:17): [True: 1.53k, False: 1.53k] ------------------ 169| 1.53k| totalsize += component_length_quoted(&principal->data[i], flags); 170| 1.53k| totalsize++; /* This is for the separator */ 171| 1.53k| } 172| 1.53k| if (principal->length == 0) ------------------ | Branch (172:9): [True: 0, False: 1.53k] ------------------ 173| 0| totalsize++; 174| | 175| | /* 176| | * Allocate space for the ascii string; if space has been 177| | * provided, use it, realloc'ing it if necessary. 178| | * 179| | * We need only n-1 separators for n components, but we need 180| | * an extra byte for the NUL at the end. 181| | */ 182| 1.53k| if (size) { ------------------ | Branch (182:9): [True: 0, False: 1.53k] ------------------ 183| 0| if (*name && (*size < totalsize)) { ------------------ | Branch (183:13): [True: 0, False: 0] | Branch (183:22): [True: 0, False: 0] ------------------ 184| 0| *name = realloc(*name, totalsize); 185| 0| } else { 186| 0| *name = malloc(totalsize); 187| 0| } 188| 0| *size = totalsize; 189| 1.53k| } else { 190| 1.53k| *name = malloc(totalsize); 191| 1.53k| } 192| | 193| 1.53k| if (!*name) { ------------------ | Branch (193:9): [True: 0, False: 1.53k] ------------------ 194| 0| ret = ENOMEM; 195| 0| goto cleanup; 196| 0| } 197| | 198| 1.53k| q = *name; 199| | 200| 3.07k| for (i = 0; i < principal->length; i++) { ------------------ | Branch (200:17): [True: 1.53k, False: 1.53k] ------------------ 201| 1.53k| q += copy_component_quoting(q, &principal->data[i], flags); 202| 1.53k| *q++ = COMPONENT_SEP; ------------------ | | 59| 1.53k|#define COMPONENT_SEP '/' ------------------ 203| 1.53k| } 204| | 205| 1.53k| if (i > 0) ------------------ | Branch (205:9): [True: 1.53k, False: 0] ------------------ 206| 1.53k| q--; /* Back up last component separator */ 207| 1.53k| if ((flags & KRB5_PRINCIPAL_UNPARSE_NO_REALM) == 0) { ------------------ | | 3543| 1.53k|#define KRB5_PRINCIPAL_UNPARSE_NO_REALM 0x2 /**< Omit realm always */ ------------------ | Branch (207:9): [True: 513, False: 1.02k] ------------------ 208| 513| *q++ = REALM_SEP; ------------------ | | 58| 513|#define REALM_SEP '@' ------------------ 209| 513| q += copy_component_quoting(q, &principal->realm, flags); 210| 513| } 211| 1.53k| *q++ = '\0'; 212| | 213| 1.53k|cleanup: 214| 1.53k| if (default_realm != NULL) ------------------ | Branch (214:9): [True: 0, False: 1.53k] ------------------ 215| 0| krb5_free_default_realm(context, default_realm); 216| | 217| 1.53k| return ret; 218| 1.53k|} unparse.c:component_length_quoted: 63| 2.05k|{ 64| 2.05k| const char *cp = src->data; 65| 2.05k| int length = src->length; 66| 2.05k| int j; 67| 2.05k| int size = length; 68| | 69| 2.05k| if ((flags & KRB5_PRINCIPAL_UNPARSE_DISPLAY) == 0) { ------------------ | | 3544| 2.05k|#define KRB5_PRINCIPAL_UNPARSE_DISPLAY 0x4 /**< Don't escape special characters */ ------------------ | Branch (69:9): [True: 0, False: 2.05k] ------------------ 70| 0| int no_realm = (flags & KRB5_PRINCIPAL_UNPARSE_NO_REALM) && ------------------ | | 3543| 0|#define KRB5_PRINCIPAL_UNPARSE_NO_REALM 0x2 /**< Omit realm always */ ------------------ | Branch (70:24): [True: 0, False: 0] ------------------ 71| 0| !(flags & KRB5_PRINCIPAL_UNPARSE_SHORT); ------------------ | | 3542| 0|#define KRB5_PRINCIPAL_UNPARSE_SHORT 0x1 /**< Omit realm if it is the local realm */ ------------------ | Branch (71:13): [True: 0, False: 0] ------------------ 72| | 73| 0| for (j = 0; j < length; j++,cp++) ------------------ | Branch (73:21): [True: 0, False: 0] ------------------ 74| 0| if ((!no_realm && *cp == REALM_SEP) || ------------------ | | 58| 0|#define REALM_SEP '@' ------------------ | Branch (74:18): [True: 0, False: 0] | Branch (74:31): [True: 0, False: 0] ------------------ 75| 0| *cp == COMPONENT_SEP || ------------------ | | 59| 0|#define COMPONENT_SEP '/' ------------------ | Branch (75:17): [True: 0, False: 0] ------------------ 76| 0| *cp == '\0' || *cp == '\\' || *cp == '\t' || ------------------ | Branch (76:17): [True: 0, False: 0] | Branch (76:32): [True: 0, False: 0] | Branch (76:47): [True: 0, False: 0] ------------------ 77| 0| *cp == '\n' || *cp == '\b') ------------------ | Branch (77:17): [True: 0, False: 0] | Branch (77:32): [True: 0, False: 0] ------------------ 78| 0| size++; 79| 0| } 80| | 81| 2.05k| return size; 82| 2.05k|} unparse.c:copy_component_quoting: 86| 2.05k|{ 87| 2.05k| int j; 88| 2.05k| const char *cp = src->data; 89| 2.05k| char *q = dest; 90| 2.05k| int length = src->length; 91| | 92| 2.05k| if (flags & KRB5_PRINCIPAL_UNPARSE_DISPLAY) { ------------------ | | 3544| 2.05k|#define KRB5_PRINCIPAL_UNPARSE_DISPLAY 0x4 /**< Don't escape special characters */ ------------------ | Branch (92:9): [True: 2.05k, False: 0] ------------------ 93| 2.05k| if (src->length > 0) ------------------ | Branch (93:13): [True: 2.05k, False: 0] ------------------ 94| 2.05k| memcpy(dest, src->data, src->length); 95| 2.05k| return src->length; 96| 2.05k| } 97| | 98| 0| for (j=0; j < length; j++,cp++) { ------------------ | Branch (98:15): [True: 0, False: 0] ------------------ 99| 0| int no_realm = (flags & KRB5_PRINCIPAL_UNPARSE_NO_REALM) && ------------------ | | 3543| 0|#define KRB5_PRINCIPAL_UNPARSE_NO_REALM 0x2 /**< Omit realm always */ ------------------ | Branch (99:24): [True: 0, False: 0] ------------------ 100| 0| !(flags & KRB5_PRINCIPAL_UNPARSE_SHORT); ------------------ | | 3542| 0|#define KRB5_PRINCIPAL_UNPARSE_SHORT 0x1 /**< Omit realm if it is the local realm */ ------------------ | Branch (100:13): [True: 0, False: 0] ------------------ 101| | 102| 0| switch (*cp) { 103| 0| case REALM_SEP: ------------------ | | 58| 0|#define REALM_SEP '@' ------------------ | Branch (103:9): [True: 0, False: 0] ------------------ 104| 0| if (no_realm) { ------------------ | Branch (104:17): [True: 0, False: 0] ------------------ 105| 0| *q++ = *cp; 106| 0| break; 107| 0| } 108| 0| case COMPONENT_SEP: ------------------ | | 59| 0|#define COMPONENT_SEP '/' ------------------ | Branch (108:9): [True: 0, False: 0] ------------------ 109| 0| case '\\': ------------------ | Branch (109:9): [True: 0, False: 0] ------------------ 110| 0| *q++ = '\\'; 111| 0| *q++ = *cp; 112| 0| break; 113| 0| case '\t': ------------------ | Branch (113:9): [True: 0, False: 0] ------------------ 114| 0| *q++ = '\\'; 115| 0| *q++ = 't'; 116| 0| break; 117| 0| case '\n': ------------------ | Branch (117:9): [True: 0, False: 0] ------------------ 118| 0| *q++ = '\\'; 119| 0| *q++ = 'n'; 120| 0| break; 121| 0| case '\b': ------------------ | Branch (121:9): [True: 0, False: 0] ------------------ 122| 0| *q++ = '\\'; 123| 0| *q++ = 'b'; 124| 0| break; 125| 0| case '\0': ------------------ | Branch (125:9): [True: 0, False: 0] ------------------ 126| 0| *q++ = '\\'; 127| 0| *q++ = '0'; 128| 0| break; 129| 0| default: ------------------ | Branch (129:9): [True: 0, False: 0] ------------------ 130| 0| *q++ = *cp; 131| 0| } 132| 0| } 133| 0| return q - dest; 134| 0|} krb5int_initialize_library: 59| 1.01k|{ 60| 1.01k| return CALL_INIT_FUNCTION(krb5int_lib_init); ------------------ | | 291| 1.01k| k5_call_init_function(& JOIN__2(NAME, once)) | | ------------------ | | | | 255| 1.01k| (__extension__ ({ \ | | | | 256| 1.01k| k5_init_t *k5int_i = (I); \ | | | | 257| 1.01k| int k5int_err = k5_once(&k5int_i->once, k5int_i->fn); \ | | | | 258| 1.01k| (k5int_err \ | | | | ------------------ | | | | | Branch (258:18): [True: 0, False: 1.01k] | | | | ------------------ | | | | 259| 1.01k| ? k5int_err \ | | | | 260| 1.01k| : (assert(k5int_i->did_run != 0), k5int_i->error)); \ | | | | 261| 1.01k| })) | | ------------------ ------------------ | Branch (60:12): [True: 0, False: 1.01k] | Branch (60:12): [True: 1.01k, False: 0] ------------------ 61| 1.01k|} krb5_libinit.c:krb5int_lib_init: 24| 1|{ 25| 1| int err; 26| | 27| 1| k5_set_error_info_callout_fn(error_message); 28| | 29| |#ifdef SHOW_INITFINI_FUNCS 30| | printf("krb5int_lib_init\n"); 31| |#endif 32| | 33| 1| add_error_table(&et_krb5_error_table); 34| 1| add_error_table(&et_k5e1_error_table); 35| 1| add_error_table(&et_kv5m_error_table); 36| 1| add_error_table(&et_kdb5_error_table); 37| 1| add_error_table(&et_asn1_error_table); 38| 1| add_error_table(&et_k524_error_table); 39| | 40| 1| bindtextdomain(KRB5_TEXTDOMAIN, LOCALEDIR); ------------------ | | 1068| 1|#define KRB5_TEXTDOMAIN "mit-krb5" ------------------ 41| | 42| 1|#ifndef LEAN_CLIENT 43| 1| err = krb5int_kt_initialize(); 44| 1| if (err) ------------------ | Branch (44:9): [True: 0, False: 1] ------------------ 45| 0| return err; 46| 1|#endif /* LEAN_CLIENT */ 47| 1| err = krb5int_cc_initialize(); 48| 1| if (err) ------------------ | Branch (48:9): [True: 0, False: 1] ------------------ 49| 0| return err; 50| 1| err = k5_mutex_finish_init(&krb5int_us_time_mutex); 51| 1| if (err) ------------------ | Branch (51:9): [True: 0, False: 1] ------------------ 52| 0| return err; 53| | 54| 1| return 0; 55| 1|} k5_expand_path_tokens: 432| 1.01k|{ 433| | return k5_expand_path_tokens_extra(context, path_in, path_out, NULL); 434| 1.01k|} k5_expand_path_tokens_extra: 454| 1.01k|{ 455| 1.01k| krb5_error_code ret; 456| 1.01k| struct k5buf buf; 457| 1.01k| const char *tok_begin, *tok_end; 458| 1.01k| char *tok_val, **extra_tokens = NULL, *path; 459| 1.01k| const char *path_left; 460| 1.01k| size_t nargs = 0, i; 461| 1.01k| va_list ap; 462| | 463| 1.01k| *path_out = NULL; 464| | 465| 1.01k| k5_buf_init_dynamic(&buf); 466| | 467| | /* Count extra tokens. */ 468| 1.01k| va_start(ap, path_out); 469| 1.01k| while (va_arg(ap, const char *) != NULL) ------------------ | Branch (469:12): [True: 0, False: 1.01k] ------------------ 470| 0| nargs++; 471| 1.01k| va_end(ap); 472| 1.01k| if (nargs % 2 != 0) ------------------ | Branch (472:9): [True: 0, False: 1.01k] ------------------ 473| 0| return EINVAL; 474| | 475| | /* Get extra tokens. */ 476| 1.01k| if (nargs > 0) { ------------------ | Branch (476:9): [True: 0, False: 1.01k] ------------------ 477| 0| extra_tokens = k5calloc(nargs + 1, sizeof(char *), &ret); 478| 0| if (extra_tokens == NULL) ------------------ | Branch (478:13): [True: 0, False: 0] ------------------ 479| 0| goto cleanup; 480| 0| va_start(ap, path_out); 481| 0| for (i = 0; i < nargs; i++) { ------------------ | Branch (481:21): [True: 0, False: 0] ------------------ 482| 0| extra_tokens[i] = strdup(va_arg(ap, const char *)); 483| 0| if (extra_tokens[i] == NULL) { ------------------ | Branch (483:17): [True: 0, False: 0] ------------------ 484| 0| ret = ENOMEM; 485| 0| va_end(ap); 486| 0| goto cleanup; 487| 0| } 488| 0| } 489| 0| va_end(ap); 490| 0| } 491| | 492| 1.01k| path_left = path_in; 493| 1.01k| while (TRUE) { ------------------ | | 167| 1.01k|#define TRUE 1 | | ------------------ | | | Branch (167:17): [True: 1.01k, Folded] | | ------------------ ------------------ 494| | /* Find the next token in path_left and add the literal text up to it. 495| | * If there are no more tokens, we can finish up. */ 496| 1.01k| tok_begin = strstr(path_left, "%{"); 497| 1.01k| if (tok_begin == NULL) { ------------------ | Branch (497:13): [True: 1.01k, False: 0] ------------------ 498| 1.01k| k5_buf_add(&buf, path_left); 499| 1.01k| break; 500| 1.01k| } 501| 0| k5_buf_add_len(&buf, path_left, tok_begin - path_left); 502| | 503| | /* Find the end of this token. */ 504| 0| tok_end = strchr(tok_begin, '}'); 505| 0| if (tok_end == NULL) { ------------------ | Branch (505:13): [True: 0, False: 0] ------------------ 506| 0| ret = EINVAL; 507| 0| k5_setmsg(context, ret, _("variable missing }")); ------------------ | | 2415| 0|#define k5_setmsg krb5_set_error_message ------------------ k5_setmsg(context, ret, _("variable missing }")); ------------------ | | 1069| 0|#define _(s) dgettext(KRB5_TEXTDOMAIN, s) ------------------ 508| 0| goto cleanup; 509| 0| } 510| | 511| | /* Expand this token and add its value. */ 512| 0| ret = expand_token(context, tok_begin, tok_end, extra_tokens, 513| 0| &tok_val); 514| 0| if (ret) ------------------ | Branch (514:13): [True: 0, False: 0] ------------------ 515| 0| goto cleanup; 516| 0| k5_buf_add(&buf, tok_val); 517| 0| free(tok_val); 518| 0| path_left = tok_end + 1; 519| 0| } 520| | 521| 1.01k| path = k5_buf_cstring(&buf); 522| 1.01k| if (path == NULL) { ------------------ | Branch (522:9): [True: 0, False: 1.01k] ------------------ 523| 0| ret = ENOMEM; 524| 0| goto cleanup; 525| 0| } 526| | 527| |#ifdef _WIN32 528| | /* Also deal with slashes. */ 529| | { 530| | char *p; 531| | for (p = path; *p != '\0'; p++) { 532| | if (*p == '/') 533| | *p = '\\'; 534| | } 535| | } 536| |#endif 537| 1.01k| *path_out = path; 538| 1.01k| memset(&buf, 0, sizeof(buf)); 539| 1.01k| ret = 0; 540| | 541| 1.01k|cleanup: 542| 1.01k| k5_buf_free(&buf); 543| 1.01k| free_extra_tokens(extra_tokens); 544| 1.01k| return ret; 545| 1.01k|} expand_path.c:free_extra_tokens: 438| 1.01k|{ 439| 1.01k| char **p; 440| | 441| 1.01k| for (p = extra_tokens; p != NULL && *p != NULL; p++) ------------------ | Branch (441:28): [True: 0, False: 1.01k] | Branch (441:41): [True: 0, False: 0] ------------------ 442| 0| free(*p); 443| 1.01k| free(extra_tokens); 444| 1.01k|} k5_hostrealm_free_context: 544| 1.01k|{ 545| 1.01k| free_handles(context, context->hostrealm_handles); 546| | context->hostrealm_handles = NULL; 547| 1.01k|} hostrealm.c:free_handles: 53| 1.01k|{ 54| 1.01k| struct hostrealm_module_handle *h, **hp; 55| | 56| 1.01k| if (handles == NULL) ------------------ | Branch (56:9): [True: 1.01k, False: 0] ------------------ 57| 1.01k| return; 58| 0| for (hp = handles; *hp != NULL; hp++) { ------------------ | Branch (58:24): [True: 0, False: 0] ------------------ 59| 0| h = *hp; 60| 0| if (h->vt.fini != NULL) ------------------ | Branch (60:13): [True: 0, False: 0] ------------------ 61| 0| h->vt.fini(context, h->data); 62| 0| free(h); 63| 0| } 64| 0| free(handles); 65| 0|} k5_os_init_context: 417| 1.01k|{ 418| 1.01k| krb5_os_context os_ctx; 419| 1.01k| krb5_error_code retval = 0; 420| |#ifdef _WIN32 421| | WSADATA wsaData; 422| | 423| | /* Initialize winsock to version 1.1. Do this first so that we know it was 424| | * done in k5_os_free_context(), and can safely call WSACleanup(). */ 425| | WSAStartup(0x0101, &wsaData); 426| |#endif /* _WIN32 */ 427| | 428| 1.01k| os_ctx = &ctx->os_context; 429| 1.01k| os_ctx->magic = KV5M_OS_CONTEXT; ------------------ | | 9073| 1.01k|#define KV5M_OS_CONTEXT (-1760647387L) ------------------ 430| 1.01k| os_ctx->time_offset = 0; 431| 1.01k| os_ctx->usec_offset = 0; 432| 1.01k| os_ctx->os_flags = 0; 433| 1.01k| os_ctx->default_ccname = 0; 434| | 435| 1.01k| PLUGIN_DIR_INIT(&ctx->libkrb5_plugins); ------------------ | | 86| 1.01k|#define PLUGIN_DIR_INIT(P) ((P)->files = NULL) ------------------ 436| 1.01k| ctx->preauth_context = NULL; 437| | 438| | /* Use the profile we were handed, or create one from config files. */ 439| 1.01k| if (profile) ------------------ | Branch (439:9): [True: 0, False: 1.01k] ------------------ 440| 0| retval = profile_copy(profile, &ctx->profile); 441| 1.01k| else 442| 1.01k| retval = os_init_paths(ctx, (flags & KRB5_INIT_CONTEXT_KDC) != 0); ------------------ | | 2861| 1.01k|#define KRB5_INIT_CONTEXT_KDC 0x2 /**< Use KDC configuration if available */ ------------------ 443| 1.01k| if (retval) ------------------ | Branch (443:9): [True: 0, False: 1.01k] ------------------ 444| 0| return retval; 445| | 446| 1.01k| return 0; 447| 1.01k|} k5_os_free_context: 489| 1.01k|{ 490| 1.01k| krb5_os_context os_ctx; 491| | 492| 1.01k| os_ctx = &ctx->os_context; 493| | 494| 1.01k| if (os_ctx->default_ccname) { ------------------ | Branch (494:9): [True: 0, False: 1.01k] ------------------ 495| 0| free(os_ctx->default_ccname); 496| 0| os_ctx->default_ccname = 0; 497| 0| } 498| | 499| 1.01k| os_ctx->magic = 0; 500| | 501| 1.01k| if (ctx->profile) { ------------------ | Branch (501:9): [True: 1.01k, False: 0] ------------------ 502| 1.01k| profile_abandon(ctx->profile); 503| 1.01k| ctx->profile = 0; 504| 1.01k| } 505| | 506| 1.01k| if (ctx->preauth_context) { ------------------ | Branch (506:9): [True: 0, False: 1.01k] ------------------ 507| 0| k5_free_preauth_context(ctx); 508| 0| ctx->preauth_context = NULL; 509| 0| } 510| 1.01k| krb5int_close_plugin_dirs (&ctx->libkrb5_plugins); 511| | 512| |#ifdef _WIN32 513| | WSACleanup(); 514| |#endif /* _WIN32 */ 515| 1.01k|} init_os_ctx.c:os_init_paths: 377| 1.01k|{ 378| 1.01k| krb5_error_code retval = 0; 379| 1.01k| profile_filespec_t *files = 0; 380| 1.01k| krb5_boolean secure = ctx->profile_secure; 381| | 382| 1.01k| retval = os_get_default_config_files(&files, secure); 383| | 384| 1.01k| if (retval == 0 && kdc) ------------------ | Branch (384:9): [True: 1.01k, False: 0] | Branch (384:24): [True: 0, False: 1.01k] ------------------ 385| 0| retval = add_kdc_config_file(&files); 386| | 387| 1.01k| if (!retval) { ------------------ | Branch (387:9): [True: 1.01k, False: 0] ------------------ 388| 1.01k| retval = profile_init_flags((const_profile_filespec_t *) files, 389| 1.01k| PROFILE_INIT_ALLOW_MODULE, &ctx->profile); ------------------ | | 27| 1.01k|#define PROFILE_INIT_ALLOW_MODULE 0x0001 /* Allow module declaration */ ------------------ 390| | 391| | /* If none of the filenames can be opened, use an empty profile. */ 392| 1.01k| if (retval == ENOENT) ------------------ | Branch (392:13): [True: 1.01k, False: 0] ------------------ 393| 1.01k| retval = profile_init(NULL, &ctx->profile); 394| 1.01k| } 395| | 396| 1.01k| if (files) ------------------ | Branch (396:9): [True: 1.01k, False: 0] ------------------ 397| 1.01k| free_filespecs(files); 398| | 399| 1.01k| if (retval) ------------------ | Branch (399:9): [True: 0, False: 1.01k] ------------------ 400| 0| ctx->profile = 0; 401| | 402| 1.01k| if (retval == ENOENT) ------------------ | Branch (402:9): [True: 0, False: 1.01k] ------------------ 403| 0| return KRB5_CONFIG_CANTOPEN; ------------------ | | 8788| 0|#define KRB5_CONFIG_CANTOPEN (-1765328249L) ------------------ 404| | 405| 1.01k| if ((retval == PROF_SECTION_NOTOP) || ------------------ | | 319| 1.01k|#define PROF_SECTION_NOTOP (-1429577715L) ------------------ | Branch (405:9): [True: 0, False: 1.01k] ------------------ 406| 1.01k| (retval == PROF_SECTION_SYNTAX) || ------------------ | | 320| 1.01k|#define PROF_SECTION_SYNTAX (-1429577714L) ------------------ | Branch (406:9): [True: 0, False: 1.01k] ------------------ 407| 1.01k| (retval == PROF_RELATION_SYNTAX) || ------------------ | | 321| 1.01k|#define PROF_RELATION_SYNTAX (-1429577713L) ------------------ | Branch (407:9): [True: 0, False: 1.01k] ------------------ 408| 1.01k| (retval == PROF_EXTRA_CBRACE) || ------------------ | | 322| 1.01k|#define PROF_EXTRA_CBRACE (-1429577712L) ------------------ | Branch (408:9): [True: 0, False: 1.01k] ------------------ 409| 1.01k| (retval == PROF_MISSING_OBRACE)) ------------------ | | 323| 1.01k|#define PROF_MISSING_OBRACE (-1429577711L) ------------------ | Branch (409:9): [True: 0, False: 1.01k] ------------------ 410| 0| return KRB5_CONFIG_BADFORMAT; ------------------ | | 8789| 0|#define KRB5_CONFIG_BADFORMAT (-1765328248L) ------------------ 411| | 412| 1.01k| return retval; 413| 1.01k|} init_os_ctx.c:os_get_default_config_files: 238| 1.01k|{ 239| 1.01k| profile_filespec_t* files; 240| |#if defined(_WIN32) 241| | krb5_error_code retval = 0; 242| | char *name = 0; 243| | 244| | if (!secure) { 245| | char *env = secure_getenv("KRB5_CONFIG"); 246| | if (env) { 247| | name = strdup(env); 248| | if (!name) return ENOMEM; 249| | } 250| | } 251| | if (!name && !secure) { 252| | /* HKCU */ 253| | retval = get_from_registry(&name, HKEY_CURRENT_USER); 254| | if (retval) return retval; 255| | } 256| | if (!name) { 257| | /* HKLM */ 258| | retval = get_from_registry(&name, HKEY_LOCAL_MACHINE); 259| | if (retval) return retval; 260| | } 261| | 262| | if (!name && !secure) { 263| | retval = get_from_known_folder(CSIDL_APPDATA, "\\MIT\\Kerberos5", 264| | &name); 265| | if (retval) return retval; 266| | } 267| | 268| | if (!name) { 269| | retval = get_from_known_folder(CSIDL_PROGRAM_FILES, "\\MIT\\Kerberos", 270| | &name); 271| | if (retval) return retval; 272| | } 273| | 274| | if (!name && !secure) { 275| | /* module dir */ 276| | retval = get_from_module_dir(&name); 277| | if (retval) return retval; 278| | } 279| | if (!name) { 280| | /* windows dir */ 281| | retval = get_from_windows_dir(&name); 282| | } 283| | if (retval) 284| | return retval; 285| | if (!name) 286| | return KRB5_CONFIG_CANTOPEN; /* should never happen */ 287| | 288| | files = malloc(2 * sizeof(char *)); 289| | if (!files) 290| | return ENOMEM; 291| | files[0] = name; 292| | files[1] = 0; 293| |#else /* !_WIN32 */ 294| 1.01k| char* filepath = 0; 295| 1.01k| int n_entries, i; 296| 1.01k| unsigned int ent_len; 297| 1.01k| const char *s, *t; 298| | 299| 1.01k| if (secure) { ------------------ | Branch (299:9): [True: 0, False: 1.01k] ------------------ 300| 0| filepath = DEFAULT_SECURE_PROFILE_PATH; ------------------ | | 53| 0|#define DEFAULT_SECURE_PROFILE_PATH "/etc/krb5.conf:/usr/local/etc/krb5.conf" ------------------ 301| 1.01k| } else { 302| 1.01k| filepath = secure_getenv("KRB5_CONFIG"); 303| 1.01k| if (!filepath) filepath = DEFAULT_PROFILE_PATH; ------------------ | | 54| 1.01k|#define DEFAULT_PROFILE_PATH DEFAULT_SECURE_PROFILE_PATH | | ------------------ | | | | 53| 1.01k|#define DEFAULT_SECURE_PROFILE_PATH "/etc/krb5.conf:/usr/local/etc/krb5.conf" | | ------------------ ------------------ | Branch (303:13): [True: 1.01k, False: 0] ------------------ 304| 1.01k| } 305| | 306| | /* count the distinct filename components */ 307| 40.5k| for(s = filepath, n_entries = 1; *s; s++) { ------------------ | Branch (307:38): [True: 39.5k, False: 1.01k] ------------------ 308| 39.5k| if (*s == ':') ------------------ | Branch (308:13): [True: 1.01k, False: 38.5k] ------------------ 309| 1.01k| n_entries++; 310| 39.5k| } 311| | 312| | /* the array is NULL terminated */ 313| 1.01k| files = (char**) malloc((n_entries+1) * sizeof(char*)); 314| 1.01k| if (files == 0) ------------------ | Branch (314:9): [True: 0, False: 1.01k] ------------------ 315| 0| return ENOMEM; 316| | 317| | /* measure, copy, and skip each one */ 318| 2.02k| for(s = filepath, i=0; (t = strchr(s, ':')) || (t=s+strlen(s)); s=t+1, i++) { ------------------ | Branch (318:28): [True: 1.01k, False: 1.01k] | Branch (318:52): [True: 1.01k, False: 0] ------------------ 319| 2.02k| ent_len = t-s; 320| 2.02k| files[i] = (char*) malloc(ent_len + 1); 321| 2.02k| if (files[i] == 0) { ------------------ | Branch (321:13): [True: 0, False: 2.02k] ------------------ 322| | /* if malloc fails, free the ones that worked */ 323| 0| while(--i >= 0) free(files[i]); ------------------ | Branch (323:19): [True: 0, False: 0] ------------------ 324| 0| free(files); 325| 0| return ENOMEM; 326| 0| } 327| 2.02k| strncpy(files[i], s, ent_len); 328| 2.02k| files[i][ent_len] = 0; 329| 2.02k| if (*t == 0) { ------------------ | Branch (329:13): [True: 1.01k, False: 1.01k] ------------------ 330| 1.01k| i++; 331| 1.01k| break; 332| 1.01k| } 333| 2.02k| } 334| | /* cap the array */ 335| 1.01k| files[i] = 0; 336| 1.01k|#endif /* !_WIN32 */ 337| 1.01k| *pfiles = (profile_filespec_t *)files; 338| 1.01k| return 0; 339| 1.01k|} init_os_ctx.c:free_filespecs: 223| 1.01k|{ 224| 1.01k| char **cp; 225| | 226| 1.01k| if (files == 0) ------------------ | Branch (226:9): [True: 0, False: 1.01k] ------------------ 227| 0| return; 228| | 229| 3.04k| for (cp = files; *cp; cp++) ------------------ | Branch (229:22): [True: 2.02k, False: 1.01k] ------------------ 230| 2.02k| free(*cp); 231| 1.01k| free(files); 232| 1.01k|} k5_localauth_free_context: 440| 1.01k|{ 441| 1.01k| free_handles(context, context->localauth_handles); 442| | context->localauth_handles = NULL; 443| 1.01k|} localauth.c:free_handles: 52| 1.01k|{ 53| 1.01k| struct localauth_module_handle *h, **hp; 54| | 55| 1.01k| if (handles == NULL) ------------------ | Branch (55:9): [True: 1.01k, False: 0] ------------------ 56| 1.01k| return; 57| 0| for (hp = handles; *hp != NULL; hp++) { ------------------ | Branch (57:24): [True: 0, False: 0] ------------------ 58| 0| h = *hp; 59| 0| if (h->vt.fini != NULL) ------------------ | Branch (59:13): [True: 0, False: 0] ------------------ 60| 0| h->vt.fini(context, h->data); 61| 0| free(h); 62| 0| } 63| 0| free(handles); 64| 0|} k5_init_trace: 386| 1.01k|{ 387| 1.01k| const char *filename; 388| | 389| 1.01k| filename = secure_getenv("KRB5_TRACE"); 390| 1.01k| if (filename) ------------------ | Branch (390:9): [True: 0, False: 1.01k] ------------------ 391| 0| (void) krb5_set_trace_filename(context, filename); 392| 1.01k|} LLVMFuzzerTestOneInput: 60| 1.03k|{ 61| 1.03k| krb5_error_code ret; 62| 1.03k| krb5_context context = NULL; 63| 1.03k| krb5_pac pac; 64| 1.03k| krb5_principal princ = NULL; 65| | 66| 1.03k| if (size < kMinInputLength || size > kMaxInputLength) ------------------ | | 40| 2.07k|#define kMinInputLength 2 ------------------ if (size < kMinInputLength || size > kMaxInputLength) ------------------ | | 41| 1.03k|#define kMaxInputLength 1024 ------------------ | Branch (66:9): [True: 1, False: 1.03k] | Branch (66:35): [True: 23, False: 1.01k] ------------------ 67| 24| return 0; 68| | 69| 1.01k| ret = krb5_init_context(&context); 70| 1.01k| if (ret) ------------------ | Branch (70:9): [True: 0, False: 1.01k] ------------------ 71| 0| return 0; 72| | 73| 1.01k| ret = krb5_parse_name(context, user, &princ); 74| 1.01k| if (ret) ------------------ | Branch (74:9): [True: 0, False: 1.01k] ------------------ 75| 0| goto cleanup; 76| | 77| 1.01k| ret = krb5_pac_parse(context, data, size, &pac); 78| 1.01k| if (ret) ------------------ | Branch (78:9): [True: 276, False: 738] ------------------ 79| 276| goto cleanup; 80| | 81| 738| krb5_pac_verify(context, pac, authtime, princ, NULL, NULL); 82| 738| krb5_pac_verify_ext(context, pac, authtime, princ, NULL, NULL, TRUE); ------------------ | | 167| 738|#define TRUE 1 ------------------ 83| 738| krb5_pac_verify(context, pac, authtime, princ, &member_keyblock, 84| 738| &kdc_keyblock); 85| | 86| 738| krb5_pac_free(context, pac); 87| | 88| 1.01k|cleanup: 89| 1.01k| krb5_free_principal(context, princ); 90| 1.01k| krb5_free_context(context); 91| | 92| 1.01k| return 0; 93| 738|} add_error_table: 254| 7|{ 255| 7| struct et_list *e; 256| | 257| 7| if (CALL_INIT_FUNCTION(com_err_initialize)) ------------------ | | 291| 7| k5_call_init_function(& JOIN__2(NAME, once)) | | ------------------ | | | | 255| 7| (__extension__ ({ \ | | | | ------------------ | | | | | Branch (255:9): [True: 0, False: 7] | | | | ------------------ | | | | 256| 7| k5_init_t *k5int_i = (I); \ | | | | 257| 7| int k5int_err = k5_once(&k5int_i->once, k5int_i->fn); \ | | | | 258| 7| (k5int_err \ | | | | ------------------ | | | | | Branch (258:18): [True: 0, False: 7] | | | | ------------------ | | | | 259| 7| ? k5int_err \ | | | | 260| 7| : (assert(k5int_i->did_run != 0), k5int_i->error)); \ | | | | 261| 7| })) | | ------------------ ------------------ | Branch (257:9): [True: 0, False: 7] | Branch (257:9): [True: 7, False: 0] ------------------ 258| 0| return 0; 259| | 260| 7| e = malloc(sizeof(struct et_list)); 261| 7| if (e == NULL) ------------------ | Branch (261:9): [True: 0, False: 7] ------------------ 262| 0| return ENOMEM; 263| | 264| 7| e->table = et; 265| | 266| 7| k5_mutex_lock(&et_list_lock); 267| 7| e->next = et_list; 268| 7| et_list = e; 269| | 270| | /* If there are two strings at the end of the table, they are a text domain 271| | * and locale dir, and we are supposed to call bindtextdomain. */ 272| 7| if (et->msgs[et->n_msgs] != NULL && et->msgs[et->n_msgs + 1] != NULL) ------------------ | Branch (272:9): [True: 7, False: 0] | Branch (272:41): [True: 0, False: 7] ------------------ 273| 0| bindtextdomain(et->msgs[et->n_msgs], et->msgs[et->n_msgs + 1]); 274| | 275| 7| k5_mutex_unlock(&et_list_lock); 276| 7| return 0; 277| 7|} error_message.c:com_err_initialize: 35| 1|{ 36| 1| int err; 37| |#ifdef SHOW_INITFINI_FUNCS 38| | printf("com_err_initialize\n"); 39| |#endif 40| 1| terminated = 0; 41| 1| err = k5_mutex_finish_init(&et_list_lock); 42| 1| if (err) ------------------ | Branch (42:9): [True: 0, False: 1] ------------------ 43| 0| return err; 44| 1| err = k5_mutex_finish_init(&com_err_hook_lock); 45| 1| if (err) ------------------ | Branch (45:9): [True: 0, False: 1] ------------------ 46| 0| return err; 47| 1| err = k5_key_register(K5_KEY_COM_ERR, free); ------------------ | | 413| 1|#define k5_key_register krb5int_key_register ------------------ 48| 1| if (err) ------------------ | Branch (48:9): [True: 0, False: 1] ------------------ 49| 0| return err; 50| 1| return 0; 51| 1|} profile_make_prf_data: 140| 2.02k|{ 141| 2.02k| prf_data_t d; 142| 2.02k| size_t len, flen, slen; 143| 2.02k| char *fcopy; 144| | 145| 2.02k| flen = strlen(filename); 146| 2.02k| slen = offsetof(struct _prf_data_t, filespec); 147| 2.02k| len = slen + flen + 1; 148| 2.02k| if (len < sizeof(struct _prf_data_t)) ------------------ | Branch (148:9): [True: 1.01k, False: 1.01k] ------------------ 149| 1.01k| len = sizeof(struct _prf_data_t); 150| 2.02k| d = malloc(len); 151| 2.02k| if (d == NULL) ------------------ | Branch (151:9): [True: 0, False: 2.02k] ------------------ 152| 0| return NULL; 153| 2.02k| memset(d, 0, len); 154| 2.02k| fcopy = (char *) d + slen; 155| 2.02k| assert(fcopy == d->filespec); ------------------ | Branch (155:5): [True: 0, False: 2.02k] | Branch (155:5): [True: 2.02k, False: 0] ------------------ 156| 2.02k| strlcpy(fcopy, filename, flen + 1); 157| 2.02k| d->refcount = 1; 158| 2.02k| d->magic = PROF_MAGIC_FILE_DATA; ------------------ | | 336| 2.02k|#define PROF_MAGIC_FILE_DATA (-1429577698L) ------------------ 159| 2.02k| d->root = NULL; 160| 2.02k| d->next = NULL; 161| 2.02k| d->fslen = flen; 162| 2.02k| if (k5_mutex_init(&d->lock) != 0) { ------------------ | Branch (162:9): [True: 0, False: 2.02k] ------------------ 163| 0| free(d); 164| 0| return NULL; 165| 0| } 166| 2.02k| return d; 167| 2.02k|} profile_open_file: 171| 2.02k|{ 172| 2.02k| prf_file_t prf; 173| 2.02k| errcode_t retval; 174| 2.02k| char *home_env = 0; 175| 2.02k| prf_data_t data; 176| 2.02k| char *expanded_filename; 177| | 178| 2.02k| retval = CALL_INIT_FUNCTION(profile_library_initializer); ------------------ | | 291| 2.02k| k5_call_init_function(& JOIN__2(NAME, once)) | | ------------------ | | | | 255| 2.02k| (__extension__ ({ \ | | | | 256| 2.02k| k5_init_t *k5int_i = (I); \ | | | | 257| 2.02k| int k5int_err = k5_once(&k5int_i->once, k5int_i->fn); \ | | | | 258| 2.02k| (k5int_err \ | | | | ------------------ | | | | | Branch (258:18): [True: 0, False: 2.02k] | | | | ------------------ | | | | 259| 2.02k| ? k5int_err \ | | | | 260| 2.02k| : (assert(k5int_i->did_run != 0), k5int_i->error)); \ | | | | 261| 2.02k| })) | | ------------------ ------------------ | Branch (178:14): [True: 0, False: 2.02k] | Branch (178:14): [True: 2.02k, False: 0] ------------------ 179| 2.02k| if (retval) ------------------ | Branch (179:9): [True: 0, False: 2.02k] ------------------ 180| 0| return retval; 181| | 182| 2.02k| prf = malloc(sizeof(struct _prf_file_t)); 183| 2.02k| if (!prf) ------------------ | Branch (183:9): [True: 0, False: 2.02k] ------------------ 184| 0| return ENOMEM; 185| 2.02k| memset(prf, 0, sizeof(struct _prf_file_t)); 186| 2.02k| prf->magic = PROF_MAGIC_FILE; ------------------ | | 331| 2.02k|#define PROF_MAGIC_FILE (-1429577703L) ------------------ 187| | 188| 2.02k| if (filespec[0] == '~' && filespec[1] == '/') { ------------------ | Branch (188:9): [True: 0, False: 2.02k] | Branch (188:31): [True: 0, False: 0] ------------------ 189| 0| home_env = secure_getenv("HOME"); 190| 0|#ifdef HAVE_PWD_H 191| 0| if (home_env == NULL) { ------------------ | Branch (191:13): [True: 0, False: 0] ------------------ 192| 0| uid_t uid; 193| 0| struct passwd *pw, pwx; 194| 0| char pwbuf[BUFSIZ]; 195| | 196| 0| uid = getuid(); 197| 0| if (!k5_getpwuid_r(uid, &pwx, pwbuf, sizeof(pwbuf), &pw) ------------------ | | 802| 0| (getpwuid_r(UID,REC,BUF,BUFSIZE,OUT) == 0 \ | | ------------------ | | | Branch (802:10): [True: 0, False: 0] | | ------------------ | | 803| 0| ? (*(OUT) == NULL ? -1 : 0) : -1) | | ------------------ | | | Branch (803:13): [True: 0, False: 0] | | ------------------ ------------------ | Branch (197:17): [True: 0, False: 0] ------------------ 198| 0| && pw != NULL && pw->pw_dir[0] != 0) ------------------ | Branch (198:20): [True: 0, False: 0] | Branch (198:34): [True: 0, False: 0] ------------------ 199| 0| home_env = pw->pw_dir; 200| 0| } 201| 0|#endif 202| 0| } 203| 2.02k| if (home_env) { ------------------ | Branch (203:9): [True: 0, False: 2.02k] ------------------ 204| 0| if (asprintf(&expanded_filename, "%s%s", home_env, ------------------ | Branch (204:13): [True: 0, False: 0] ------------------ 205| 0| filespec + 1) < 0) 206| 0| expanded_filename = 0; 207| 0| } else 208| 2.02k| expanded_filename = strdup(filespec); 209| 2.02k| if (expanded_filename == 0) { ------------------ | Branch (209:9): [True: 0, False: 2.02k] ------------------ 210| 0| free(prf); 211| 0| return ENOMEM; 212| 0| } 213| | 214| 2.02k| k5_mutex_lock(&g_shared_trees_mutex); ------------------ | | 44| 2.02k|#define g_shared_trees_mutex (krb5int_profile_shared_data.mutex) ------------------ 215| 2.02k| for (data = g_shared_trees; data; data = data->next) { ------------------ | | 43| 2.02k|#define g_shared_trees (krb5int_profile_shared_data.trees) ------------------ | Branch (215:33): [True: 0, False: 2.02k] ------------------ 216| 0| if (!strcmp(data->filespec, expanded_filename) ------------------ | Branch (216:13): [True: 0, False: 0] ------------------ 217| | /* Check that current uid has read access. */ 218| 0| && r_access(data->filespec)) ------------------ | Branch (218:16): [True: 0, False: 0] ------------------ 219| 0| break; 220| 0| } 221| 2.02k| if (data) { ------------------ | Branch (221:9): [True: 0, False: 2.02k] ------------------ 222| 0| data->refcount++; 223| 0| k5_mutex_unlock(&g_shared_trees_mutex); ------------------ | | 44| 0|#define g_shared_trees_mutex (krb5int_profile_shared_data.mutex) ------------------ 224| 0| k5_mutex_lock(&data->lock); 225| 0| data->last_stat = 0; /* Make sure to stat when updating. */ 226| 0| retval = profile_update_file_data_locked(data, NULL); 227| 0| k5_mutex_unlock(&data->lock); 228| 0| free(expanded_filename); 229| 0| if (retval) { ------------------ | Branch (229:13): [True: 0, False: 0] ------------------ 230| 0| profile_dereference_data(data); 231| 0| free(prf); 232| 0| return retval; 233| 0| } 234| 0| prf->data = data; 235| 0| *ret_prof = prf; 236| 0| return 0; 237| 0| } 238| 2.02k| k5_mutex_unlock(&g_shared_trees_mutex); ------------------ | | 44| 2.02k|#define g_shared_trees_mutex (krb5int_profile_shared_data.mutex) ------------------ 239| 2.02k| data = profile_make_prf_data(expanded_filename); 240| 2.02k| if (data == NULL) { ------------------ | Branch (240:9): [True: 0, False: 2.02k] ------------------ 241| 0| free(prf); 242| 0| free(expanded_filename); 243| 0| return ENOMEM; 244| 0| } 245| 2.02k| free(expanded_filename); 246| 2.02k| prf->data = data; 247| | 248| 2.02k| retval = profile_update_file(prf, ret_modspec); ------------------ | | 220| 2.02k|#define profile_update_file(P, M) profile_update_file_data((P)->data, M) ------------------ 249| 2.02k| if (retval) { ------------------ | Branch (249:9): [True: 2.02k, False: 0] ------------------ 250| 2.02k| profile_close_file(prf); 251| 2.02k| return retval; 252| 2.02k| } 253| | 254| 0| k5_mutex_lock(&g_shared_trees_mutex); ------------------ | | 44| 0|#define g_shared_trees_mutex (krb5int_profile_shared_data.mutex) ------------------ 255| 0| data->flags |= PROFILE_FILE_SHARED; ------------------ | | 78| 0|#define PROFILE_FILE_SHARED 0x0004 ------------------ 256| 0| data->next = g_shared_trees; ------------------ | | 43| 0|#define g_shared_trees (krb5int_profile_shared_data.trees) ------------------ 257| 0| g_shared_trees = data; ------------------ | | 43| 0|#define g_shared_trees (krb5int_profile_shared_data.trees) ------------------ 258| 0| k5_mutex_unlock(&g_shared_trees_mutex); ------------------ | | 44| 0|#define g_shared_trees_mutex (krb5int_profile_shared_data.mutex) ------------------ 259| | 260| 0| *ret_prof = prf; 261| 0| return 0; 262| 2.02k|} profile_update_file_data_locked: 296| 2.02k|{ 297| 2.02k| errcode_t retval; 298| 2.02k|#ifdef HAVE_STAT 299| 2.02k| struct stat st; 300| 2.02k| unsigned long frac; 301| 2.02k| time_t now; 302| 2.02k|#endif 303| 2.02k| FILE *f; 304| 2.02k| int isdir = 0; 305| | 306| | /* Don't reload if the backing file isn't a regular file. */ 307| 2.02k| if ((data->flags & PROFILE_FILE_NO_RELOAD) && data->root != NULL) ------------------ | | 76| 2.02k|#define PROFILE_FILE_NO_RELOAD 0x0001 ------------------ | Branch (307:9): [True: 0, False: 2.02k] | Branch (307:51): [True: 0, False: 0] ------------------ 308| 0| return 0; 309| | /* Don't reload a modified data object, as the modifications may be 310| | * important for this object's use. */ 311| 2.02k| if (data->flags & PROFILE_FILE_DIRTY) ------------------ | | 77| 2.02k|#define PROFILE_FILE_DIRTY 0x0002 ------------------ | Branch (311:9): [True: 0, False: 2.02k] ------------------ 312| 0| return 0; 313| | 314| 2.02k|#ifdef HAVE_STAT 315| 2.02k| now = time(0); 316| 2.02k| if (now == data->last_stat && data->root != NULL) { ------------------ | Branch (316:9): [True: 0, False: 2.02k] | Branch (316:35): [True: 0, False: 0] ------------------ 317| 0| return 0; 318| 0| } 319| 2.02k| if (stat(data->filespec, &st)) { ------------------ | Branch (319:9): [True: 2.02k, False: 0] ------------------ 320| 2.02k| return errno; 321| 2.02k| } 322| 0| data->last_stat = now; 323| |#if defined HAVE_STRUCT_STAT_ST_MTIMENSEC 324| | frac = st.st_mtimensec; 325| |#elif defined HAVE_STRUCT_STAT_ST_MTIMESPEC_TV_NSEC 326| | frac = st.st_mtimespec.tv_nsec; 327| |#elif defined HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC 328| | frac = st.st_mtim.tv_nsec; 329| |#else 330| | frac = 0; 331| |#endif 332| 0| if (st.st_mtime == data->timestamp ------------------ | Branch (332:9): [True: 0, False: 0] ------------------ 333| 0| && frac == data->frac_ts ------------------ | Branch (333:12): [True: 0, False: 0] ------------------ 334| 0| && data->root != NULL) { ------------------ | Branch (334:12): [True: 0, False: 0] ------------------ 335| 0| return 0; 336| 0| } 337| 0| if (data->root) { ------------------ | Branch (337:9): [True: 0, False: 0] ------------------ 338| 0| profile_free_node(data->root); 339| 0| data->root = 0; 340| 0| } 341| | 342| | /* Only try to reload regular files, not devices such as pipes. */ 343| 0| if ((st.st_mode & S_IFMT) != S_IFREG) ------------------ | Branch (343:9): [True: 0, False: 0] ------------------ 344| 0| data->flags |= PROFILE_FILE_NO_RELOAD; ------------------ | | 76| 0|#define PROFILE_FILE_NO_RELOAD 0x0001 ------------------ 345| |#else 346| | /* 347| | * If we don't have the stat() call, assume that our in-core 348| | * memory image is correct. That is, we won't reread the 349| | * profile file if it changes. 350| | */ 351| | if (data->root) { 352| | return 0; 353| | } 354| |#endif 355| | 356| 0|#ifdef HAVE_STAT 357| 0| isdir = S_ISDIR(st.st_mode); 358| 0|#endif 359| 0| if (!isdir) { ------------------ | Branch (359:9): [True: 0, False: 0] ------------------ 360| 0| errno = 0; 361| 0| f = fopen(data->filespec, "r"); 362| 0| if (f == NULL) ------------------ | Branch (362:13): [True: 0, False: 0] ------------------ 363| 0| return (errno != 0) ? errno : ENOENT; ------------------ | Branch (363:20): [True: 0, False: 0] ------------------ 364| 0| set_cloexec_file(f); ------------------ | | 842| 0|#define set_cloexec_file(F) set_cloexec_fd(fileno(F)) | | ------------------ | | | | 835| 0|# define set_cloexec_fd(FD) ((void)fcntl((FD), F_SETFD, FD_CLOEXEC)) | | ------------------ ------------------ 365| 0| } 366| | 367| 0| data->upd_serial++; 368| | 369| 0| if (isdir) { ------------------ | Branch (369:9): [True: 0, False: 0] ------------------ 370| 0| retval = profile_process_directory(data->filespec, &data->root); 371| 0| } else { 372| 0| retval = profile_parse_file(f, &data->root, ret_modspec); 373| 0| (void)fclose(f); 374| 0| } 375| 0| if (retval) { ------------------ | Branch (375:9): [True: 0, False: 0] ------------------ 376| 0| return retval; 377| 0| } 378| 0| assert(data->root != NULL); ------------------ | Branch (378:5): [True: 0, False: 0] | Branch (378:5): [True: 0, False: 0] ------------------ 379| 0|#ifdef HAVE_STAT 380| 0| data->timestamp = st.st_mtime; 381| 0| data->frac_ts = frac; 382| 0|#endif 383| 0| return 0; 384| 0|} profile_update_file_data: 387| 2.02k|{ 388| 2.02k| errcode_t retval; 389| | 390| 2.02k| k5_mutex_lock(&data->lock); 391| 2.02k| retval = profile_update_file_data_locked(data, ret_modspec); 392| 2.02k| k5_mutex_unlock(&data->lock); 393| 2.02k| return retval; 394| 2.02k|} profile_flush_file_data: 499| 2.02k|{ 500| 2.02k| errcode_t retval = 0; 501| | 502| 2.02k| if (!data || data->magic != PROF_MAGIC_FILE_DATA) ------------------ | | 336| 2.02k|#define PROF_MAGIC_FILE_DATA (-1429577698L) ------------------ | Branch (502:9): [True: 0, False: 2.02k] | Branch (502:18): [True: 0, False: 2.02k] ------------------ 503| 0| return PROF_MAGIC_FILE_DATA; ------------------ | | 336| 0|#define PROF_MAGIC_FILE_DATA (-1429577698L) ------------------ 504| | 505| | /* Do nothing if this data object has no backing file. */ 506| 2.02k| if (*data->filespec == '\0') ------------------ | Branch (506:9): [True: 0, False: 2.02k] ------------------ 507| 0| return 0; 508| | 509| 2.02k| k5_mutex_lock(&data->lock); 510| | 511| 2.02k| if ((data->flags & PROFILE_FILE_DIRTY) == 0) { ------------------ | | 77| 2.02k|#define PROFILE_FILE_DIRTY 0x0002 ------------------ | Branch (511:9): [True: 2.02k, False: 0] ------------------ 512| 2.02k| k5_mutex_unlock(&data->lock); 513| 2.02k| return 0; 514| 2.02k| } 515| | 516| 0| retval = write_data_to_file(data, data->filespec, 0); 517| 0| data->flags &= ~PROFILE_FILE_DIRTY; ------------------ | | 77| 0|#define PROFILE_FILE_DIRTY 0x0002 ------------------ 518| 0| k5_mutex_unlock(&data->lock); 519| 0| return retval; 520| 2.02k|} profile_dereference_data: 538| 2.02k|{ 539| 2.02k| k5_mutex_lock(&g_shared_trees_mutex); ------------------ | | 44| 2.02k|#define g_shared_trees_mutex (krb5int_profile_shared_data.mutex) ------------------ 540| 2.02k| profile_dereference_data_locked(data); 541| 2.02k| k5_mutex_unlock(&g_shared_trees_mutex); ------------------ | | 44| 2.02k|#define g_shared_trees_mutex (krb5int_profile_shared_data.mutex) ------------------ 542| 2.02k|} profile_dereference_data_locked: 544| 2.02k|{ 545| 2.02k| data->refcount--; 546| 2.02k| if (data->refcount == 0) ------------------ | Branch (546:9): [True: 2.02k, False: 0] ------------------ 547| 2.02k| profile_free_file_data(data); 548| 2.02k|} profile_free_file: 598| 2.02k|{ 599| 2.02k| profile_dereference_data(prf->data); 600| 2.02k| free(prf); 601| 2.02k|} profile_close_file: 632| 2.02k|{ 633| 2.02k| errcode_t retval; 634| | 635| 2.02k| retval = profile_flush_file(prf); ------------------ | | 227| 2.02k|#define profile_flush_file(P) (((P) && (P)->magic == PROF_MAGIC_FILE) ? profile_flush_file_data((P)->data) : PROF_MAGIC_FILE) | | ------------------ | | | | 331| 2.02k|#define PROF_MAGIC_FILE (-1429577703L) | | ------------------ | | #define profile_flush_file(P) (((P) && (P)->magic == PROF_MAGIC_FILE) ? profile_flush_file_data((P)->data) : PROF_MAGIC_FILE) | | ------------------ | | | | 331| 0|#define PROF_MAGIC_FILE (-1429577703L) | | ------------------ | | | Branch (227:33): [True: 2.02k, False: 0] | | | Branch (227:40): [True: 2.02k, False: 0] | | ------------------ ------------------ 636| 2.02k| if (retval) ------------------ | Branch (636:9): [True: 0, False: 2.02k] ------------------ 637| 0| return retval; 638| 2.02k| profile_free_file(prf); 639| 2.02k| return 0; 640| 2.02k|} prof_file.c:profile_library_initializer: 55| 1|{ 56| |#ifdef SHOW_INITFINI_FUNCS 57| | printf("profile_library_initializer\n"); 58| |#endif 59| 1| add_error_table(&et_prof_error_table); 60| | 61| 1| return k5_mutex_finish_init(&g_shared_trees_mutex); ------------------ | | 44| 1|#define g_shared_trees_mutex (krb5int_profile_shared_data.mutex) ------------------ 62| 1|} prof_file.c:profile_free_file_data: 605| 2.02k|{ 606| 2.02k| if (data->flags & PROFILE_FILE_SHARED) { ------------------ | | 78| 2.02k|#define PROFILE_FILE_SHARED 0x0004 ------------------ | Branch (606:9): [True: 0, False: 2.02k] ------------------ 607| | /* Remove from linked list. */ 608| 0| if (g_shared_trees == data) ------------------ | | 43| 0|#define g_shared_trees (krb5int_profile_shared_data.trees) ------------------ | Branch (608:13): [True: 0, False: 0] ------------------ 609| 0| g_shared_trees = data->next; ------------------ | | 43| 0|#define g_shared_trees (krb5int_profile_shared_data.trees) ------------------ 610| 0| else { 611| 0| prf_data_t prev, next; 612| 0| prev = g_shared_trees; ------------------ | | 43| 0|#define g_shared_trees (krb5int_profile_shared_data.trees) ------------------ 613| 0| next = prev->next; 614| 0| while (next) { ------------------ | Branch (614:20): [True: 0, False: 0] ------------------ 615| 0| if (next == data) { ------------------ | Branch (615:21): [True: 0, False: 0] ------------------ 616| 0| prev->next = next->next; 617| 0| break; 618| 0| } 619| 0| prev = next; 620| 0| next = next->next; 621| 0| } 622| 0| } 623| 0| } 624| 2.02k| if (data->root) ------------------ | Branch (624:9): [True: 0, False: 2.02k] ------------------ 625| 0| profile_free_node(data->root); 626| 2.02k| data->magic = 0; 627| 2.02k| k5_mutex_destroy(&data->lock); ------------------ | | 365| 2.02k| (k5_os_mutex_destroy(M)) ------------------ 628| 2.02k| free(data); 629| 2.02k|} profile_get_value: 221| 13.1k|{ 222| 13.1k| errcode_t retval; 223| 13.1k| void *state; 224| 13.1k| char *value; 225| | 226| 13.1k| *ret_value = NULL; 227| 13.1k| if (!profile) ------------------ | Branch (227:9): [True: 0, False: 13.1k] ------------------ 228| 0| return PROF_NO_PROFILE; ------------------ | | 330| 0|#define PROF_NO_PROFILE (-1429577704L) ------------------ 229| 13.1k| if (profile->vt) ------------------ | Branch (229:9): [True: 0, False: 13.1k] ------------------ 230| 0| return get_value_vt(profile, names, ret_value); 231| | 232| 13.1k| retval = profile_iterator_create(profile, names, 233| 13.1k| PROFILE_ITER_RELATIONS_ONLY, &state); ------------------ | | 108| 13.1k|#define PROFILE_ITER_RELATIONS_ONLY 0x0004 ------------------ 234| 13.1k| if (retval) ------------------ | Branch (234:9): [True: 0, False: 13.1k] ------------------ 235| 0| return retval; 236| | 237| 13.1k| retval = profile_iterator(&state, NULL, &value); 238| 13.1k| if (retval) ------------------ | Branch (238:9): [True: 0, False: 13.1k] ------------------ 239| 0| goto cleanup; 240| | 241| 13.1k| if (value) ------------------ | Branch (241:9): [True: 0, False: 13.1k] ------------------ 242| 0| *ret_value = value; 243| 13.1k| else 244| 13.1k| retval = PROF_NO_RELATION; ------------------ | | 309| 13.1k|#define PROF_NO_RELATION (-1429577725L) ------------------ 245| | 246| 13.1k|cleanup: 247| 13.1k| profile_iterator_free(&state); 248| 13.1k| return retval; 249| 13.1k|} profile_get_string: 255| 3.04k|{ 256| 3.04k| char *value; 257| 3.04k| errcode_t retval; 258| 3.04k| const char *names[4]; 259| | 260| 3.04k| if (profile) { ------------------ | Branch (260:9): [True: 3.04k, False: 0] ------------------ 261| 3.04k| names[0] = name; 262| 3.04k| names[1] = subname; 263| 3.04k| names[2] = subsubname; 264| 3.04k| names[3] = 0; 265| 3.04k| retval = profile_get_value(profile, names, &value); 266| 3.04k| if (retval == 0) { ------------------ | Branch (266:13): [True: 0, False: 3.04k] ------------------ 267| 0| *ret_string = value; 268| 0| return 0; 269| 3.04k| } else if (retval != PROF_NO_SECTION && retval != PROF_NO_RELATION) ------------------ | | 308| 6.08k|#define PROF_NO_SECTION (-1429577726L) ------------------ } else if (retval != PROF_NO_SECTION && retval != PROF_NO_RELATION) ------------------ | | 309| 3.04k|#define PROF_NO_RELATION (-1429577725L) ------------------ | Branch (269:20): [True: 3.04k, False: 0] | Branch (269:49): [True: 0, False: 3.04k] ------------------ 270| 0| return retval; 271| 3.04k| } 272| | 273| 3.04k| if (def_val) { ------------------ | Branch (273:9): [True: 1.01k, False: 2.02k] ------------------ 274| 1.01k| *ret_string = strdup(def_val); 275| 1.01k| if (*ret_string == NULL) ------------------ | Branch (275:13): [True: 0, False: 1.01k] ------------------ 276| 0| return ENOMEM; 277| 1.01k| } else 278| 2.02k| *ret_string = NULL; 279| 3.04k| return 0; 280| 3.04k|} profile_get_integer: 311| 4.05k|{ 312| 4.05k| char *value; 313| 4.05k| errcode_t retval; 314| 4.05k| const char *names[4]; 315| | 316| 4.05k| *ret_int = def_val; 317| 4.05k| if (profile == 0) ------------------ | Branch (317:9): [True: 0, False: 4.05k] ------------------ 318| 0| return 0; 319| | 320| 4.05k| names[0] = name; 321| 4.05k| names[1] = subname; 322| 4.05k| names[2] = subsubname; 323| 4.05k| names[3] = 0; 324| 4.05k| retval = profile_get_value(profile, names, &value); 325| 4.05k| if (retval == PROF_NO_SECTION || retval == PROF_NO_RELATION) { ------------------ | | 308| 8.11k|#define PROF_NO_SECTION (-1429577726L) ------------------ if (retval == PROF_NO_SECTION || retval == PROF_NO_RELATION) { ------------------ | | 309| 4.05k|#define PROF_NO_RELATION (-1429577725L) ------------------ | Branch (325:9): [True: 0, False: 4.05k] | Branch (325:38): [True: 4.05k, False: 0] ------------------ 326| 4.05k| *ret_int = def_val; 327| 4.05k| return 0; 328| 4.05k| } else if (retval) ------------------ | Branch (328:16): [True: 0, False: 0] ------------------ 329| 0| return retval; 330| | 331| 0| retval = parse_int(value, ret_int); 332| 0| free(value); 333| 0| return retval; 334| 4.05k|} profile_get_boolean: 374| 6.08k|{ 375| 6.08k| char *value; 376| 6.08k| errcode_t retval; 377| 6.08k| const char *names[4]; 378| | 379| 6.08k| if (profile == 0) { ------------------ | Branch (379:9): [True: 0, False: 6.08k] ------------------ 380| 0| *ret_boolean = def_val; 381| 0| return 0; 382| 0| } 383| | 384| 6.08k| names[0] = name; 385| 6.08k| names[1] = subname; 386| 6.08k| names[2] = subsubname; 387| 6.08k| names[3] = 0; 388| 6.08k| retval = profile_get_value(profile, names, &value); 389| 6.08k| if (retval == PROF_NO_SECTION || retval == PROF_NO_RELATION) { ------------------ | | 308| 12.1k|#define PROF_NO_SECTION (-1429577726L) ------------------ if (retval == PROF_NO_SECTION || retval == PROF_NO_RELATION) { ------------------ | | 309| 6.08k|#define PROF_NO_RELATION (-1429577725L) ------------------ | Branch (389:9): [True: 0, False: 6.08k] | Branch (389:38): [True: 6.08k, False: 0] ------------------ 390| 6.08k| *ret_boolean = def_val; 391| 6.08k| return 0; 392| 6.08k| } else if (retval) ------------------ | Branch (392:16): [True: 0, False: 0] ------------------ 393| 0| return retval; 394| | 395| 0| retval = profile_parse_boolean(value, ret_boolean); 396| 0| free(value); 397| 0| return retval; 398| 6.08k|} profile_iterator_create: 485| 13.1k|{ 486| 13.1k| struct profile_iterator *iter; 487| 13.1k| errcode_t retval; 488| | 489| 13.1k| *ret_iter = NULL; 490| 13.1k| if (!profile) ------------------ | Branch (490:9): [True: 0, False: 13.1k] ------------------ 491| 0| return PROF_NO_PROFILE; ------------------ | | 330| 0|#define PROF_NO_PROFILE (-1429577704L) ------------------ 492| | 493| 13.1k| iter = malloc(sizeof(*iter)); 494| 13.1k| if (iter == NULL) ------------------ | Branch (494:9): [True: 0, False: 13.1k] ------------------ 495| 0| return ENOMEM; 496| 13.1k| iter->magic = PROF_MAGIC_ITERATOR; ------------------ | | 315| 13.1k|#define PROF_MAGIC_ITERATOR (-1429577719L) ------------------ 497| 13.1k| iter->profile = profile; 498| | 499| | /* Create the underlying iterator representation using the vtable or the 500| | * built-in node iterator. */ 501| 13.1k| if (profile->vt) { ------------------ | Branch (501:9): [True: 0, False: 13.1k] ------------------ 502| 0| if (!profile->vt->iterator_create) ------------------ | Branch (502:13): [True: 0, False: 0] ------------------ 503| 0| retval = PROF_UNSUPPORTED; ------------------ | | 339| 0|#define PROF_UNSUPPORTED (-1429577695L) ------------------ 504| 0| else 505| 0| retval = profile->vt->iterator_create(profile->cbdata, names, 506| 0| flags, &iter->idata); 507| 13.1k| } else { 508| 13.1k| retval = profile_node_iterator_create(profile, names, flags, 509| 13.1k| &iter->idata); 510| 13.1k| } 511| 13.1k| if (retval) { ------------------ | Branch (511:9): [True: 0, False: 13.1k] ------------------ 512| 0| free(iter); 513| 0| return retval; 514| 0| } 515| | 516| 13.1k| *ret_iter = iter; 517| 13.1k| return 0; 518| 13.1k|} profile_iterator_free: 522| 13.1k|{ 523| 13.1k| struct profile_iterator *iter; 524| 13.1k| profile_t profile; 525| | 526| 13.1k| if (!iter_p) ------------------ | Branch (526:9): [True: 0, False: 13.1k] ------------------ 527| 0| return; 528| 13.1k| iter = *iter_p; 529| 13.1k| if (!iter || iter->magic != PROF_MAGIC_ITERATOR) ------------------ | | 315| 0|#define PROF_MAGIC_ITERATOR (-1429577719L) ------------------ | Branch (529:9): [True: 13.1k, False: 0] | Branch (529:18): [True: 0, False: 0] ------------------ 530| 13.1k| return; 531| 0| profile = iter->profile; 532| 0| if (profile->vt) ------------------ | Branch (532:9): [True: 0, False: 0] ------------------ 533| 0| profile->vt->iterator_free(profile->cbdata, iter->idata); 534| 0| else 535| 0| profile_node_iterator_free(&iter->idata); 536| 0| free(iter); 537| | *iter_p = NULL; 538| 0|} profile_iterator: 571| 13.1k|{ 572| 13.1k| char *name, *value; 573| 13.1k| errcode_t retval; 574| 13.1k| struct profile_iterator *iter = *iter_p; 575| 13.1k| profile_t profile; 576| | 577| 13.1k| if (ret_name) ------------------ | Branch (577:9): [True: 0, False: 13.1k] ------------------ 578| 0| *ret_name = NULL; 579| 13.1k| if (ret_value) ------------------ | Branch (579:9): [True: 13.1k, False: 0] ------------------ 580| 13.1k| *ret_value = NULL; 581| 13.1k| if (iter == NULL || iter->magic != PROF_MAGIC_ITERATOR) ------------------ | | 315| 13.1k|#define PROF_MAGIC_ITERATOR (-1429577719L) ------------------ | Branch (581:9): [True: 0, False: 13.1k] | Branch (581:25): [True: 0, False: 13.1k] ------------------ 582| 0| return PROF_MAGIC_ITERATOR; ------------------ | | 315| 0|#define PROF_MAGIC_ITERATOR (-1429577719L) ------------------ 583| 13.1k| profile = iter->profile; 584| | 585| 13.1k| if (profile->vt) { ------------------ | Branch (585:9): [True: 0, False: 13.1k] ------------------ 586| 0| retval = profile->vt->iterator(profile->cbdata, iter->idata, &name, 587| 0| &value); 588| 0| if (retval) ------------------ | Branch (588:13): [True: 0, False: 0] ------------------ 589| 0| return retval; 590| 0| if (name == NULL) { ------------------ | Branch (590:13): [True: 0, False: 0] ------------------ 591| 0| profile->vt->iterator_free(profile->cbdata, iter->idata); 592| 0| free(iter); 593| 0| *iter_p = NULL; 594| 0| } 595| 0| retval = set_results(name, value, ret_name, ret_value); 596| 0| if (name) ------------------ | Branch (596:13): [True: 0, False: 0] ------------------ 597| 0| profile->vt->free_string(profile->cbdata, name); 598| 0| if (value) ------------------ | Branch (598:13): [True: 0, False: 0] ------------------ 599| 0| profile->vt->free_string(profile->cbdata, value); 600| 0| return retval; 601| 0| } 602| | 603| 13.1k| retval = profile_node_iterator(&iter->idata, 0, &name, &value); 604| 13.1k| if (iter->idata == NULL) { ------------------ | Branch (604:9): [True: 13.1k, False: 0] ------------------ 605| 13.1k| free(iter); 606| 13.1k| *iter_p = NULL; 607| 13.1k| } 608| 13.1k| if (retval) ------------------ | Branch (608:9): [True: 0, False: 13.1k] ------------------ 609| 0| return retval; 610| 13.1k| return set_results(name, value, ret_name, ret_value); 611| 13.1k|} profile_release_string: 615| 2.02k|{ 616| 2.02k| free(str); 617| 2.02k|} prof_get.c:set_results: 545| 13.1k|{ 546| 13.1k| char *name_copy = NULL, *value_copy = NULL; 547| | 548| 13.1k| if (ret_name && name) { ------------------ | Branch (548:9): [True: 0, False: 13.1k] | Branch (548:21): [True: 0, False: 0] ------------------ 549| 0| name_copy = strdup(name); 550| 0| if (name_copy == NULL) ------------------ | Branch (550:13): [True: 0, False: 0] ------------------ 551| 0| goto oom; 552| 0| } 553| 13.1k| if (ret_value && value) { ------------------ | Branch (553:9): [True: 13.1k, False: 0] | Branch (553:22): [True: 0, False: 13.1k] ------------------ 554| 0| value_copy = strdup(value); 555| 0| if (value_copy == NULL) ------------------ | Branch (555:13): [True: 0, False: 0] ------------------ 556| 0| goto oom; 557| 0| } 558| 13.1k| if (ret_name) ------------------ | Branch (558:9): [True: 0, False: 13.1k] ------------------ 559| 0| *ret_name = name_copy; 560| 13.1k| if (ret_value) ------------------ | Branch (560:9): [True: 13.1k, False: 0] ------------------ 561| 13.1k| *ret_value = value_copy; 562| 13.1k| return 0; 563| 0|oom: 564| 0| free(name_copy); 565| 0| free(value_copy); 566| | return ENOMEM; 567| 13.1k|} profile_init_flags: 167| 2.02k|{ 168| 2.02k| const_profile_filespec_t *fs; 169| 2.02k| profile_t profile; 170| 2.02k| prf_file_t new_file, last = 0; 171| 2.02k| errcode_t retval = 0, access_retval = 0; 172| 2.02k| char *modspec = NULL, **modspec_arg; 173| | 174| 2.02k| profile = malloc(sizeof(struct _profile_t)); 175| 2.02k| if (!profile) ------------------ | Branch (175:9): [True: 0, False: 2.02k] ------------------ 176| 0| return ENOMEM; 177| 2.02k| memset(profile, 0, sizeof(struct _profile_t)); 178| 2.02k| profile->magic = PROF_MAGIC_PROFILE; ------------------ | | 324| 2.02k|#define PROF_MAGIC_PROFILE (-1429577710L) ------------------ 179| | 180| | /* 181| | * If the filenames list is not specified or empty, return an empty 182| | * profile. 183| | */ 184| 2.02k| if ( files && !PROFILE_LAST_FILESPEC(*files) ) { ------------------ | | 116| 1.01k|#define PROFILE_LAST_FILESPEC(x) (((x) == NULL) || ((x)[0] == '\0')) | | ------------------ | | | Branch (116:35): [True: 0, False: 1.01k] | | | Branch (116:52): [True: 0, False: 1.01k] | | ------------------ ------------------ | Branch (184:10): [True: 1.01k, False: 1.01k] ------------------ 185| 3.04k| for (fs = files; !PROFILE_LAST_FILESPEC(*fs); fs++) { ------------------ | | 116| 3.04k|#define PROFILE_LAST_FILESPEC(x) (((x) == NULL) || ((x)[0] == '\0')) | | ------------------ | | | Branch (116:35): [True: 1.01k, False: 2.02k] | | | Branch (116:52): [True: 0, False: 2.02k] | | ------------------ ------------------ 186| | /* Allow a module declaration if it is permitted by flags and this 187| | * is the first file parsed. */ 188| 2.02k| modspec_arg = ((flags & PROFILE_INIT_ALLOW_MODULE) && !last) ? ------------------ | | 27| 2.02k|#define PROFILE_INIT_ALLOW_MODULE 0x0001 /* Allow module declaration */ ------------------ | Branch (188:28): [True: 2.02k, False: 0] | Branch (188:67): [True: 2.02k, False: 0] ------------------ 189| 2.02k| &modspec : NULL; 190| 2.02k| retval = profile_open_file(*fs, &new_file, modspec_arg); 191| 2.02k| if (retval == PROF_MODULE && modspec) { ------------------ | | 341| 4.05k|#define PROF_MODULE (-1429577693L) ------------------ | Branch (191:17): [True: 0, False: 2.02k] | Branch (191:42): [True: 0, False: 0] ------------------ 192| | /* Stop parsing files and load a dynamic module instead. */ 193| 0| free(profile); 194| 0| retval = init_load_module(modspec, ret_profile); 195| 0| free(modspec); 196| 0| return retval; 197| 0| } 198| | /* if this file is missing, skip to the next */ 199| 2.02k| if (retval == ENOENT) { ------------------ | Branch (199:17): [True: 2.02k, False: 0] ------------------ 200| 2.02k| continue; 201| 2.02k| } 202| | /* If we can't read this file, remember it but keep going. */ 203| 0| if (retval == EACCES || retval == EPERM) { ------------------ | Branch (203:17): [True: 0, False: 0] | Branch (203:37): [True: 0, False: 0] ------------------ 204| 0| access_retval = retval; 205| 0| continue; 206| 0| } 207| 0| if (retval) { ------------------ | Branch (207:17): [True: 0, False: 0] ------------------ 208| 0| profile_release(profile); 209| 0| return retval; 210| 0| } 211| 0| if (last) ------------------ | Branch (211:17): [True: 0, False: 0] ------------------ 212| 0| last->next = new_file; 213| 0| else 214| 0| profile->first_file = new_file; 215| 0| last = new_file; 216| 0| } 217| | /* 218| | * If last is still null after the loop, then all the files were 219| | * missing or unreadable, so return the appropriate error. 220| | */ 221| 1.01k| if (!last) { ------------------ | Branch (221:13): [True: 1.01k, False: 0] ------------------ 222| 1.01k| profile_release(profile); 223| 1.01k| return access_retval ? access_retval : ENOENT; ------------------ | Branch (223:20): [True: 0, False: 1.01k] ------------------ 224| 1.01k| } 225| 1.01k| } 226| | 227| 1.01k| *ret_profile = profile; 228| 1.01k| return 0; 229| 2.02k|} profile_init: 233| 1.01k|{ 234| 1.01k| return profile_init_flags(files, 0, ret_profile); 235| 1.01k|} profile_abandon: 474| 1.01k|{ 475| 1.01k| prf_file_t p, next; 476| | 477| 1.01k| if (!profile || profile->magic != PROF_MAGIC_PROFILE) ------------------ | | 324| 1.01k|#define PROF_MAGIC_PROFILE (-1429577710L) ------------------ | Branch (477:9): [True: 0, False: 1.01k] | Branch (477:21): [True: 0, False: 1.01k] ------------------ 478| 0| return; 479| | 480| 1.01k| if (profile->vt) { ------------------ | Branch (480:9): [True: 0, False: 1.01k] ------------------ 481| 0| if (profile->vt->cleanup) ------------------ | Branch (481:13): [True: 0, False: 0] ------------------ 482| 0| profile->vt->cleanup(profile->cbdata); 483| 0| if (profile->lib_handle) { ------------------ | Branch (483:13): [True: 0, False: 0] ------------------ 484| | /* Decrement the refcount on the handle and maybe free it. */ 485| 0| k5_mutex_lock(&profile->lib_handle->lock); 486| 0| if (--profile->lib_handle->refcount == 0) { ------------------ | Branch (486:17): [True: 0, False: 0] ------------------ 487| 0| krb5int_close_plugin(profile->lib_handle->plugin_handle); 488| 0| k5_mutex_unlock(&profile->lib_handle->lock); 489| 0| k5_mutex_destroy(&profile->lib_handle->lock); ------------------ | | 365| 0| (k5_os_mutex_destroy(M)) ------------------ 490| 0| free(profile->lib_handle); 491| 0| } else 492| 0| k5_mutex_unlock(&profile->lib_handle->lock); 493| 0| } 494| 0| free(profile->vt); 495| 1.01k| } else { 496| 1.01k| for (p = profile->first_file; p; p = next) { ------------------ | Branch (496:39): [True: 0, False: 1.01k] ------------------ 497| 0| next = p->next; 498| 0| profile_free_file(p); 499| 0| } 500| 1.01k| } 501| 1.01k| profile->magic = 0; 502| 1.01k| free(profile); 503| 1.01k|} profile_release: 507| 1.01k|{ 508| 1.01k| prf_file_t p, next; 509| | 510| 1.01k| if (!profile || profile->magic != PROF_MAGIC_PROFILE) ------------------ | | 324| 1.01k|#define PROF_MAGIC_PROFILE (-1429577710L) ------------------ | Branch (510:9): [True: 0, False: 1.01k] | Branch (510:21): [True: 0, False: 1.01k] ------------------ 511| 0| return; 512| | 513| 1.01k| if (profile->vt) { ------------------ | Branch (513:9): [True: 0, False: 1.01k] ------------------ 514| | /* Flush the profile and then delegate to profile_abandon. */ 515| 0| if (profile->vt->flush) ------------------ | Branch (515:13): [True: 0, False: 0] ------------------ 516| 0| profile->vt->flush(profile->cbdata); 517| 0| profile_abandon(profile); 518| 0| return; 519| 1.01k| } else { 520| 1.01k| for (p = profile->first_file; p; p = next) { ------------------ | Branch (520:39): [True: 0, False: 1.01k] ------------------ 521| 0| next = p->next; 522| 0| profile_close_file(p); 523| 0| } 524| 1.01k| } 525| 1.01k| profile->magic = 0; 526| 1.01k| free(profile); 527| 1.01k|} profile_node_iterator_create: 466| 13.1k|{ 467| 13.1k| struct profile_node_iterator *iter; 468| 13.1k| int done_idx = 0; 469| | 470| 13.1k| if (profile == 0) ------------------ | Branch (470:9): [True: 0, False: 13.1k] ------------------ 471| 0| return PROF_NO_PROFILE; ------------------ | | 330| 0|#define PROF_NO_PROFILE (-1429577704L) ------------------ 472| 13.1k| if (profile->magic != PROF_MAGIC_PROFILE) ------------------ | | 324| 13.1k|#define PROF_MAGIC_PROFILE (-1429577710L) ------------------ | Branch (472:9): [True: 0, False: 13.1k] ------------------ 473| 0| return PROF_MAGIC_PROFILE; ------------------ | | 324| 0|#define PROF_MAGIC_PROFILE (-1429577710L) ------------------ 474| 13.1k| if (!names) ------------------ | Branch (474:9): [True: 0, False: 13.1k] ------------------ 475| 0| return PROF_BAD_NAMESET; ------------------ | | 329| 0|#define PROF_BAD_NAMESET (-1429577705L) ------------------ 476| 13.1k| if (!(flags & PROFILE_ITER_LIST_SECTION)) { ------------------ | | 106| 13.1k|#define PROFILE_ITER_LIST_SECTION 0x0001 ------------------ | Branch (476:9): [True: 13.1k, False: 0] ------------------ 477| 13.1k| if (!names[0]) ------------------ | Branch (477:13): [True: 0, False: 13.1k] ------------------ 478| 0| return PROF_BAD_NAMESET; ------------------ | | 329| 0|#define PROF_BAD_NAMESET (-1429577705L) ------------------ 479| 13.1k| done_idx = 1; 480| 13.1k| } 481| | 482| 13.1k| iter = malloc(sizeof(*iter)); 483| 13.1k| if (iter == NULL) ------------------ | Branch (483:9): [True: 0, False: 13.1k] ------------------ 484| 0| return ENOMEM; 485| | 486| 13.1k| iter->magic = PROF_MAGIC_NODE_ITERATOR; ------------------ | | 340| 13.1k|#define PROF_MAGIC_NODE_ITERATOR (-1429577694L) ------------------ 487| 13.1k| iter->names = names; 488| 13.1k| iter->flags = flags; 489| 13.1k| iter->file = profile->first_file; 490| 13.1k| iter->done_idx = done_idx; 491| 13.1k| iter->node = 0; 492| 13.1k| iter->num = 0; 493| 13.1k| *ret_iter = iter; 494| 13.1k| return 0; 495| 13.1k|} profile_node_iterator_free: 498| 13.1k|{ 499| 13.1k| struct profile_node_iterator *iter; 500| | 501| 13.1k| if (!iter_p) ------------------ | Branch (501:9): [True: 0, False: 13.1k] ------------------ 502| 0| return; 503| 13.1k| iter = *iter_p; 504| 13.1k| if (!iter || iter->magic != PROF_MAGIC_NODE_ITERATOR) ------------------ | | 340| 13.1k|#define PROF_MAGIC_NODE_ITERATOR (-1429577694L) ------------------ | Branch (504:9): [True: 0, False: 13.1k] | Branch (504:18): [True: 0, False: 13.1k] ------------------ 505| 0| return; 506| 13.1k| free(iter); 507| 13.1k| *iter_p = 0; 508| 13.1k|} profile_node_iterator: 520| 13.1k|{ 521| 13.1k| struct profile_node_iterator *iter = *iter_p; 522| 13.1k| struct profile_node *section, *p; 523| 13.1k| const char *const *cpp; 524| 13.1k| errcode_t retval; 525| 13.1k| int skip_num = 0; 526| | 527| 13.1k| if (!iter || iter->magic != PROF_MAGIC_NODE_ITERATOR) ------------------ | | 340| 13.1k|#define PROF_MAGIC_NODE_ITERATOR (-1429577694L) ------------------ | Branch (527:9): [True: 0, False: 13.1k] | Branch (527:18): [True: 0, False: 13.1k] ------------------ 528| 0| return PROF_MAGIC_NODE_ITERATOR; ------------------ | | 340| 0|#define PROF_MAGIC_NODE_ITERATOR (-1429577694L) ------------------ 529| 13.1k| if (iter->file && iter->file->magic != PROF_MAGIC_FILE) ------------------ | | 331| 0|#define PROF_MAGIC_FILE (-1429577703L) ------------------ | Branch (529:9): [True: 0, False: 13.1k] | Branch (529:23): [True: 0, False: 0] ------------------ 530| 0| return PROF_MAGIC_FILE; ------------------ | | 331| 0|#define PROF_MAGIC_FILE (-1429577703L) ------------------ 531| 13.1k| if (iter->file && iter->file->data->magic != PROF_MAGIC_FILE_DATA) ------------------ | | 336| 0|#define PROF_MAGIC_FILE_DATA (-1429577698L) ------------------ | Branch (531:9): [True: 0, False: 13.1k] | Branch (531:23): [True: 0, False: 0] ------------------ 532| 0| return PROF_MAGIC_FILE_DATA; ------------------ | | 336| 0|#define PROF_MAGIC_FILE_DATA (-1429577698L) ------------------ 533| | /* 534| | * If the file has changed, then the node pointer is invalid, 535| | * so we'll have search the file again looking for it. 536| | */ 537| 13.1k| if (iter->file) ------------------ | Branch (537:9): [True: 0, False: 13.1k] ------------------ 538| 0| k5_mutex_lock(&iter->file->data->lock); 539| 13.1k| if (iter->node && (iter->file->data->upd_serial != iter->file_serial)) { ------------------ | Branch (539:9): [True: 0, False: 13.1k] | Branch (539:23): [True: 0, False: 0] ------------------ 540| 0| iter->flags &= ~PROFILE_ITER_FINAL_SEEN; ------------------ | | 110| 0|#define PROFILE_ITER_FINAL_SEEN 0x0100 ------------------ 541| 0| skip_num = iter->num; 542| 0| iter->node = 0; 543| 0| } 544| 13.1k| if (iter->node && iter->node->magic != PROF_MAGIC_NODE) { ------------------ | | 307| 0|#define PROF_MAGIC_NODE (-1429577727L) ------------------ | Branch (544:9): [True: 0, False: 13.1k] | Branch (544:23): [True: 0, False: 0] ------------------ 545| 0| if (iter->file) ------------------ | Branch (545:13): [True: 0, False: 0] ------------------ 546| 0| k5_mutex_unlock(&iter->file->data->lock); 547| 0| return PROF_MAGIC_NODE; ------------------ | | 307| 0|#define PROF_MAGIC_NODE (-1429577727L) ------------------ 548| 0| } 549| 13.1k|get_new_file: 550| 13.1k| if (iter->node == 0) { ------------------ | Branch (550:9): [True: 13.1k, False: 0] ------------------ 551| 13.1k| if (iter->file == 0 || ------------------ | Branch (551:13): [True: 13.1k, False: 0] ------------------ 552| 13.1k| (iter->flags & PROFILE_ITER_FINAL_SEEN)) { ------------------ | | 110| 0|#define PROFILE_ITER_FINAL_SEEN 0x0100 ------------------ | Branch (552:13): [True: 0, False: 0] ------------------ 553| 13.1k| if (iter->file) ------------------ | Branch (553:17): [True: 0, False: 13.1k] ------------------ 554| 0| k5_mutex_unlock(&iter->file->data->lock); 555| 13.1k| profile_node_iterator_free(iter_p); 556| 13.1k| if (ret_node) ------------------ | Branch (556:17): [True: 0, False: 13.1k] ------------------ 557| 0| *ret_node = 0; 558| 13.1k| if (ret_name) ------------------ | Branch (558:17): [True: 13.1k, False: 0] ------------------ 559| 13.1k| *ret_name = 0; 560| 13.1k| if (ret_value) ------------------ | Branch (560:17): [True: 13.1k, False: 0] ------------------ 561| 13.1k| *ret_value =0; 562| 13.1k| return 0; 563| 13.1k| } 564| 0| if ((retval = profile_update_file_locked(iter->file, NULL))) { ------------------ | | 223| 0|#define profile_update_file_locked(P, M) profile_update_file_data_locked((P)->data, M) ------------------ | Branch (564:13): [True: 0, False: 0] ------------------ 565| 0| k5_mutex_unlock(&iter->file->data->lock); 566| 0| if (retval == ENOENT || retval == EACCES) { ------------------ | Branch (566:17): [True: 0, False: 0] | Branch (566:37): [True: 0, False: 0] ------------------ 567| | /* XXX memory leak? */ 568| 0| iter->file = iter->file->next; 569| 0| if (iter->file) ------------------ | Branch (569:21): [True: 0, False: 0] ------------------ 570| 0| k5_mutex_lock(&iter->file->data->lock); 571| 0| skip_num = 0; 572| 0| retval = 0; 573| 0| goto get_new_file; 574| 0| } else { 575| 0| profile_node_iterator_free(iter_p); 576| 0| return retval; 577| 0| } 578| 0| } 579| 0| iter->file_serial = iter->file->data->upd_serial; 580| | /* 581| | * Find the section to list if we are a LIST_SECTION, 582| | * or find the containing section if not. 583| | */ 584| 0| section = iter->file->data->root; 585| 0| assert(section != NULL); ------------------ | Branch (585:9): [True: 0, False: 0] | Branch (585:9): [True: 0, False: 0] ------------------ 586| 0| for (cpp = iter->names; cpp[iter->done_idx]; cpp++) { ------------------ | Branch (586:33): [True: 0, False: 0] ------------------ 587| 0| for (p=section->first_child; p; p = p->next) { ------------------ | Branch (587:42): [True: 0, False: 0] ------------------ 588| 0| if (!strcmp(p->name, *cpp) && !p->value && !p->deleted) ------------------ | Branch (588:21): [True: 0, False: 0] | Branch (588:47): [True: 0, False: 0] | Branch (588:60): [True: 0, False: 0] ------------------ 589| 0| break; 590| 0| } 591| 0| if (!p) { ------------------ | Branch (591:17): [True: 0, False: 0] ------------------ 592| 0| section = 0; 593| 0| break; 594| 0| } 595| 0| section = p; 596| 0| if (p->final) ------------------ | Branch (596:17): [True: 0, False: 0] ------------------ 597| 0| iter->flags |= PROFILE_ITER_FINAL_SEEN; ------------------ | | 110| 0|#define PROFILE_ITER_FINAL_SEEN 0x0100 ------------------ 598| 0| } 599| 0| if (!section) { ------------------ | Branch (599:13): [True: 0, False: 0] ------------------ 600| 0| k5_mutex_unlock(&iter->file->data->lock); 601| 0| iter->file = iter->file->next; 602| 0| if (iter->file) ------------------ | Branch (602:17): [True: 0, False: 0] ------------------ 603| 0| k5_mutex_lock(&iter->file->data->lock); 604| 0| skip_num = 0; 605| 0| goto get_new_file; 606| 0| } 607| 0| iter->name = *cpp; 608| 0| iter->node = section->first_child; 609| 0| } 610| | /* 611| | * OK, now we know iter->node is set up correctly. Let's do 612| | * the search. 613| | */ 614| 0| for (p = iter->node; p; p = p->next) { ------------------ | Branch (614:26): [True: 0, False: 0] ------------------ 615| 0| if (iter->name && strcmp(p->name, iter->name)) ------------------ | Branch (615:13): [True: 0, False: 0] | Branch (615:27): [True: 0, False: 0] ------------------ 616| 0| continue; 617| 0| if ((iter->flags & PROFILE_ITER_SECTIONS_ONLY) && ------------------ | | 107| 0|#define PROFILE_ITER_SECTIONS_ONLY 0x0002 ------------------ | Branch (617:13): [True: 0, False: 0] ------------------ 618| 0| p->value) ------------------ | Branch (618:13): [True: 0, False: 0] ------------------ 619| 0| continue; 620| 0| if ((iter->flags & PROFILE_ITER_RELATIONS_ONLY) && ------------------ | | 108| 0|#define PROFILE_ITER_RELATIONS_ONLY 0x0004 ------------------ | Branch (620:13): [True: 0, False: 0] ------------------ 621| 0| !p->value) ------------------ | Branch (621:13): [True: 0, False: 0] ------------------ 622| 0| continue; 623| 0| if (skip_num > 0) { ------------------ | Branch (623:13): [True: 0, False: 0] ------------------ 624| 0| skip_num--; 625| 0| continue; 626| 0| } 627| 0| if (p->deleted) ------------------ | Branch (627:13): [True: 0, False: 0] ------------------ 628| 0| continue; 629| 0| if (p->final) ------------------ | Branch (629:13): [True: 0, False: 0] ------------------ 630| 0| iter->flags |= PROFILE_ITER_FINAL_SEEN; ------------------ | | 110| 0|#define PROFILE_ITER_FINAL_SEEN 0x0100 ------------------ 631| 0| break; 632| 0| } 633| 0| iter->num++; 634| 0| if (!p) { ------------------ | Branch (634:9): [True: 0, False: 0] ------------------ 635| 0| k5_mutex_unlock(&iter->file->data->lock); 636| 0| iter->file = iter->file->next; 637| 0| if (iter->file) ------------------ | Branch (637:13): [True: 0, False: 0] ------------------ 638| 0| k5_mutex_lock(&iter->file->data->lock); 639| 0| iter->node = 0; 640| 0| skip_num = 0; 641| 0| goto get_new_file; 642| 0| } 643| 0| k5_mutex_unlock(&iter->file->data->lock); 644| 0| if ((iter->node = p->next) == NULL) ------------------ | Branch (644:9): [True: 0, False: 0] ------------------ 645| 0| iter->file = iter->file->next; 646| 0| if (ret_node) ------------------ | Branch (646:9): [True: 0, False: 0] ------------------ 647| 0| *ret_node = p; 648| 0| if (ret_name) ------------------ | Branch (648:9): [True: 0, False: 0] ------------------ 649| 0| *ret_name = p->name; 650| 0| if (ret_value) ------------------ | Branch (650:9): [True: 0, False: 0] ------------------ 651| 0| *ret_value = p->value; 652| 0| return 0; 653| 0|} k5_bcmp: 37| 79|{ 38| 79| const unsigned char *c1 = p1, *c2 = p2; 39| 79| unsigned char x = 0; 40| | 41| 1.34k| for (; n > 0; c1++, c2++, n--) ------------------ | Branch (41:12): [True: 1.26k, False: 79] ------------------ 42| 1.26k| x |= *c1 ^ *c2; 43| 79| return x; 44| 79|} krb5int_err_init: 31| 1|{ 32| 1| return k5_mutex_finish_init(&krb5int_error_info_support_mutex); 33| 1|} k5_free_error: 103| 1.01k|{ 104| 1.01k| if (msg != oom_msg) ------------------ | Branch (104:9): [True: 1.01k, False: 0] ------------------ 105| 1.01k| free((char *)msg); 106| 1.01k|} k5_clear_error: 110| 1.01k|{ 111| 1.01k| k5_free_error(ep, ep->msg); 112| | ep->msg = NULL; 113| 1.01k|} k5_set_error_info_callout_fn: 117| 1|{ 118| 1| initialize(); ------------------ | | 34| 1|#define initialize() krb5int_call_thread_support_init() ------------------ 119| 1| lock(); ------------------ | | 35| 1|#define lock() k5_mutex_lock(&krb5int_error_info_support_mutex) ------------------ 120| 1| fptr = f; 121| 1| unlock(); ------------------ | | 36| 1|#define unlock() k5_mutex_unlock(&krb5int_error_info_support_mutex) ------------------ 122| 1|} krb5int_init_fac: 61| 1|{ 62| 1| return k5_mutex_finish_init(&krb5int_fac.lock); 63| 1|} k5_buf_init_dynamic: 125| 2.74k|{ 126| 2.74k| buf->buftype = K5BUF_DYNAMIC; 127| 2.74k| buf->space = 128; 128| 2.74k| buf->data = malloc(buf->space); 129| 2.74k| if (buf->data == NULL) { ------------------ | Branch (129:9): [True: 0, False: 2.74k] ------------------ 130| 0| set_error(buf); 131| 0| return; 132| 0| } 133| 2.74k| buf->len = 0; 134| 2.74k|} k5_buf_add: 146| 1.01k|{ 147| 1.01k| k5_buf_add_len(buf, data, strlen(data)); 148| 1.01k|} k5_buf_add_len: 152| 1.01k|{ 153| 1.01k| if (!ensure_space(buf, len)) ------------------ | Branch (153:9): [True: 0, False: 1.01k] ------------------ 154| 0| return; 155| 1.01k| if (len > 0) ------------------ | Branch (155:9): [True: 1.01k, False: 0] ------------------ 156| 1.01k| memcpy(endptr(buf), data, len); 157| 1.01k| buf->len += len; 158| 1.01k|} k5_buf_cstring: 234| 2.55k|{ 235| 2.55k| if (!ensure_space(buf, 1)) ------------------ | Branch (235:9): [True: 0, False: 2.55k] ------------------ 236| 0| return NULL; 237| 2.55k| *endptr(buf) = '\0'; 238| 2.55k| return buf->data; 239| 2.55k|} k5_buf_get_space: 243| 25.2k|{ 244| 25.2k| if (!ensure_space(buf, len)) ------------------ | Branch (244:9): [True: 0, False: 25.2k] ------------------ 245| 0| return NULL; 246| 25.2k| buf->len += len; 247| 25.2k| return endptr(buf) - len; 248| 25.2k|} k5_buf_free: 267| 1.20k|{ 268| 1.20k| if (buf->buftype == K5BUF_ERROR) ------------------ | Branch (268:9): [True: 1.01k, False: 192] ------------------ 269| 1.01k| return; 270| 1.20k| assert(buf->buftype == K5BUF_DYNAMIC || buf->buftype == K5BUF_DYNAMIC_ZAP); ------------------ | Branch (270:5): [True: 192, False: 0] | Branch (270:5): [True: 0, False: 0] | Branch (270:5): [True: 192, False: 0] | Branch (270:5): [True: 0, False: 0] ------------------ 271| 192| if (buf->buftype == K5BUF_DYNAMIC_ZAP) ------------------ | Branch (271:9): [True: 0, False: 192] ------------------ 272| 0| zap(buf->data, buf->len); ------------------ | | 1009| 0|# define zap(ptr, len) explicit_bzero(ptr, len) ------------------ 273| 192| free(buf->data); 274| 192| set_error(buf); 275| 192|} k5buf.c:set_error: 57| 192|{ 58| 192| buf->buftype = K5BUF_ERROR; 59| | buf->data = NULL; 60| 192| buf->space = buf->len = 0; 61| 192|} k5buf.c:ensure_space: 70| 28.8k|{ 71| 28.8k| size_t new_space; 72| 28.8k| char *new_data; 73| | 74| 28.8k| if (buf->buftype == K5BUF_ERROR) ------------------ | Branch (74:9): [True: 0, False: 28.8k] ------------------ 75| 0| return 0; 76| 28.8k| if (buf->space - buf->len >= len) /* Enough room already. */ ------------------ | Branch (76:9): [True: 28.7k, False: 102] ------------------ 77| 28.7k| return 1; 78| 102| if (buf->buftype == K5BUF_FIXED) /* Can't resize a fixed buffer. */ ------------------ | Branch (78:9): [True: 0, False: 102] ------------------ 79| 0| goto error_exit; 80| 102| assert(buf->buftype == K5BUF_DYNAMIC || buf->buftype == K5BUF_DYNAMIC_ZAP); ------------------ | Branch (80:5): [True: 102, False: 0] | Branch (80:5): [True: 0, False: 0] | Branch (80:5): [True: 102, False: 0] | Branch (80:5): [True: 0, False: 0] ------------------ 81| 102| new_space = buf->space * 2; 82| 102| while (new_space - buf->len < len) { ------------------ | Branch (82:12): [True: 0, False: 102] ------------------ 83| 0| if (new_space > SIZE_MAX / 2) ------------------ | Branch (83:13): [True: 0, False: 0] ------------------ 84| 0| goto error_exit; 85| 0| new_space *= 2; 86| 0| } 87| 102| if (buf->buftype == K5BUF_DYNAMIC_ZAP) { ------------------ | Branch (87:9): [True: 0, False: 102] ------------------ 88| | /* realloc() could leave behind a partial copy of sensitive data. */ 89| 0| new_data = malloc(new_space); 90| 0| if (new_data == NULL) ------------------ | Branch (90:13): [True: 0, False: 0] ------------------ 91| 0| goto error_exit; 92| 0| memcpy(new_data, buf->data, buf->len); 93| 0| zap(buf->data, buf->len); ------------------ | | 1009| 0|# define zap(ptr, len) explicit_bzero(ptr, len) ------------------ 94| 0| free(buf->data); 95| 102| } else { 96| 102| new_data = realloc(buf->data, new_space); 97| 102| if (new_data == NULL) ------------------ | Branch (97:13): [True: 0, False: 102] ------------------ 98| 0| goto error_exit; 99| 102| } 100| 102| buf->data = new_data; 101| 102| buf->space = new_space; 102| 102| return 1; 103| | 104| 0|error_exit: 105| 0| if (buf->buftype == K5BUF_DYNAMIC_ZAP) ------------------ | Branch (105:9): [True: 0, False: 0] ------------------ 106| 0| zap(buf->data, buf->len); ------------------ | | 1009| 0|# define zap(ptr, len) explicit_bzero(ptr, len) ------------------ 107| 0| if (buf->buftype == K5BUF_DYNAMIC_ZAP || buf->buftype == K5BUF_DYNAMIC) ------------------ | Branch (107:9): [True: 0, False: 0] | Branch (107:46): [True: 0, False: 0] ------------------ 108| 0| free(buf->data); 109| 0| set_error(buf); 110| 0| return 0; 111| 102|} k5buf.c:endptr: 51| 28.8k|{ 52| 28.8k| return (char *)buf->data + buf->len; 53| 28.8k|} krb5int_close_plugin_dirs: 466| 1.01k|{ 467| 1.01k| size_t i; 468| | 469| 1.01k| if (dirhandle->files != NULL) { ------------------ | Branch (469:9): [True: 0, False: 1.01k] ------------------ 470| 0| for (i = 0; dirhandle->files[i] != NULL; i++) { ------------------ | Branch (470:21): [True: 0, False: 0] ------------------ 471| 0| krb5int_close_plugin (dirhandle->files[i]); 472| 0| } 473| 0| free (dirhandle->files); 474| | dirhandle->files = NULL; 475| 0| } 476| 1.01k|} krb5int_pthread_loaded: 139| 23.3k|{ 140| 23.3k| int x = flag_pthread_loaded; 141| 23.3k| if (x != -1) ------------------ | Branch (141:9): [True: 23.3k, False: 1] ------------------ 142| 23.3k| return x; 143| 1| if (&pthread_getspecific == 0 ------------------ | Branch (143:9): [True: 0, False: 1] ------------------ 144| 1| || &pthread_setspecific == 0 ------------------ | Branch (144:12): [True: 0, False: 1] ------------------ 145| 1| || &pthread_key_create == 0 ------------------ | Branch (145:12): [True: 0, False: 1] ------------------ 146| 1| || &pthread_key_delete == 0 ------------------ | Branch (146:12): [True: 0, False: 1] ------------------ 147| 1| || &pthread_once == 0 ------------------ | Branch (147:12): [True: 0, False: 1] ------------------ 148| 1| || &pthread_mutex_lock == 0 ------------------ | Branch (148:12): [True: 0, False: 1] ------------------ 149| 1| || &pthread_mutex_unlock == 0 ------------------ | Branch (149:12): [True: 0, False: 1] ------------------ 150| 1| || &pthread_mutex_destroy == 0 ------------------ | Branch (150:12): [True: 0, False: 1] ------------------ 151| 1| || &pthread_mutex_init == 0 ------------------ | Branch (151:12): [True: 0, False: 1] ------------------ 152| 1| || &pthread_self == 0 ------------------ | Branch (152:12): [True: 0, False: 1] ------------------ 153| | /* Any program that's really multithreaded will have to be 154| | able to create threads. */ 155| 1| || &pthread_create == 0 ------------------ | Branch (155:12): [True: 0, False: 1] ------------------ 156| 1| || &pthread_join == 0 ------------------ | Branch (156:12): [True: 0, False: 1] ------------------ 157| | /* Okay, all the interesting functions -- or stubs for them -- 158| | seem to be present. If we call pthread_once, does it 159| | actually seem to cause the indicated function to get called 160| | exactly one time? */ 161| 1| || pthread_once(&loaded_test_once, loaded_test_aux) != 0 ------------------ | Branch (161:12): [True: 0, False: 1] ------------------ 162| 1| || pthread_once(&loaded_test_once, loaded_test_aux) != 0 ------------------ | Branch (162:12): [True: 0, False: 1] ------------------ 163| | /* This catches cases where pthread_once does nothing, and 164| | never causes the function to get called. That's a pretty 165| | clear violation of the POSIX spec, but hey, it happens. */ 166| 1| || flag_pthread_loaded < 0) { ------------------ | Branch (166:12): [True: 0, False: 1] ------------------ 167| 0| flag_pthread_loaded = 0; 168| 0| return 0; 169| 0| } 170| | /* If we wanted to be super-paranoid, we could try testing whether 171| | pthread_get/setspecific work, too. I don't know -- so far -- 172| | of any system with non-functional stubs for those. */ 173| 1| return flag_pthread_loaded; 174| 1|} krb5int_key_register: 326| 1|{ 327| 1| int err; 328| | 329| 1| err = CALL_INIT_FUNCTION(krb5int_thread_support_init); ------------------ | | 291| 1| k5_call_init_function(& JOIN__2(NAME, once)) | | ------------------ | | | | 255| 1| (__extension__ ({ \ | | | | 256| 1| k5_init_t *k5int_i = (I); \ | | | | 257| 1| int k5int_err = k5_once(&k5int_i->once, k5int_i->fn); \ | | | | 258| 1| (k5int_err \ | | | | ------------------ | | | | | Branch (258:18): [True: 0, False: 1] | | | | ------------------ | | | | 259| 1| ? k5int_err \ | | | | 260| 1| : (assert(k5int_i->did_run != 0), k5int_i->error)); \ | | | | 261| 1| })) | | ------------------ ------------------ | Branch (329:11): [True: 0, False: 1] | Branch (329:11): [True: 1, False: 0] ------------------ 330| 1| if (err) ------------------ | Branch (330:9): [True: 0, False: 1] ------------------ 331| 0| return err; 332| | 333| |#ifndef ENABLE_THREADS 334| | 335| | assert(destructors_set[keynum] == 0); 336| | destructors[keynum] = destructor; 337| | destructors_set[keynum] = 1; 338| | 339| |#elif defined(_WIN32) 340| | 341| | /* XXX: This can raise EXCEPTION_POSSIBLE_DEADLOCK. */ 342| | EnterCriticalSection(&key_lock); 343| | assert(destructors_set[keynum] == 0); 344| | destructors_set[keynum] = 1; 345| | destructors[keynum] = destructor; 346| | LeaveCriticalSection(&key_lock); 347| | 348| |#else /* POSIX */ 349| | 350| 1| k5_mutex_lock(&key_lock); 351| 1| assert(destructors_set[keynum] == 0); ------------------ | Branch (351:5): [True: 0, False: 1] | Branch (351:5): [True: 1, False: 0] ------------------ 352| 1| destructors_set[keynum] = 1; 353| 1| destructors[keynum] = destructor; 354| 1| k5_mutex_unlock(&key_lock); 355| | 356| 1|#endif 357| 1| return 0; 358| 1|} krb5int_call_thread_support_init: 398| 1|{ 399| 1| return CALL_INIT_FUNCTION(krb5int_thread_support_init); ------------------ | | 291| 1| k5_call_init_function(& JOIN__2(NAME, once)) | | ------------------ | | | | 255| 1| (__extension__ ({ \ | | | | 256| 1| k5_init_t *k5int_i = (I); \ | | | | 257| 1| int k5int_err = k5_once(&k5int_i->once, k5int_i->fn); \ | | | | 258| 1| (k5int_err \ | | | | ------------------ | | | | | Branch (258:18): [True: 0, False: 1] | | | | ------------------ | | | | 259| 1| ? k5int_err \ | | | | 260| 1| : (assert(k5int_i->did_run != 0), k5int_i->error)); \ | | | | 261| 1| })) | | ------------------ ------------------ | Branch (399:12): [True: 0, False: 1] | Branch (399:12): [True: 1, False: 0] ------------------ 400| 1|} k5_os_mutex_init: 522| 2.02k|{ 523| 2.02k| if (krb5int_pthread_loaded()) ------------------ | Branch (523:9): [True: 2.02k, False: 0] ------------------ 524| 2.02k| return pthread_mutex_init(m, 0); 525| 0| else 526| 0| return 0; 527| 2.02k|} k5_os_mutex_destroy: 531| 2.02k|{ 532| 2.02k| if (krb5int_pthread_loaded()) ------------------ | Branch (532:9): [True: 2.02k, False: 0] ------------------ 533| 2.02k| return pthread_mutex_destroy(m); 534| 0| else 535| 0| return 0; 536| 2.02k|} k5_os_mutex_lock: 540| 8.12k|{ 541| 8.12k| if (krb5int_pthread_loaded()) ------------------ | Branch (541:9): [True: 8.12k, False: 0] ------------------ 542| 8.12k| return pthread_mutex_lock(m); 543| 0| else 544| 0| return 0; 545| 8.12k|} k5_os_mutex_unlock: 549| 8.12k|{ 550| 8.12k| if (krb5int_pthread_loaded()) ------------------ | Branch (550:9): [True: 8.12k, False: 0] ------------------ 551| 8.12k| return pthread_mutex_unlock(m); 552| 0| else 553| 0| return 0; 554| 8.12k|} k5_once: 558| 3.05k|{ 559| 3.05k| if (krb5int_pthread_loaded()) ------------------ | Branch (559:9): [True: 3.05k, False: 0] ------------------ 560| 3.05k| return pthread_once(&once->o, fn); 561| 0| else 562| 0| return k5_os_nothread_once(&once->n, fn); ------------------ | | 191| 0| (*(O) == 3 ? 0 \ | | ------------------ | | | Branch (191:6): [True: 0, False: 0] | | ------------------ | | 192| 0| : *(O) == 2 ? (*(O) = 4, (F)(), *(O) = 3, 0) \ | | ------------------ | | | Branch (192:8): [True: 0, False: 0] | | ------------------ | | 193| 0| : (assert(*(O) != 4), assert(*(O) == 2 || *(O) == 3), 0)) ------------------ | Branch (562:16): [True: 0, False: 0] | Branch (562:16): [True: 0, False: 0] | Branch (562:16): [True: 0, False: 0] | Branch (562:16): [True: 0, False: 0] | Branch (562:16): [True: 0, False: 0] | Branch (562:16): [True: 0, False: 0] ------------------ 563| 3.05k|} threads.c:loaded_test_aux: 130| 1|{ 131| 1| if (flag_pthread_loaded == -1) ------------------ | Branch (131:9): [True: 1, False: 0] ------------------ 132| 1| flag_pthread_loaded = 1; 133| 0| else 134| | /* Could we have been called twice? */ 135| 0| flag_pthread_loaded = 0; 136| 1|} threads.c:krb5int_thread_support_init: 405| 1|{ 406| 1| int err; 407| | 408| |#ifdef SHOW_INITFINI_FUNCS 409| | printf("krb5int_thread_support_init\n"); 410| |#endif 411| | 412| |#ifndef ENABLE_THREADS 413| | 414| | /* Nothing to do for TLS initialization. */ 415| | 416| |#elif defined(_WIN32) 417| | 418| | tls_idx = TlsAlloc(); 419| | /* XXX This can raise an exception if memory is low! */ 420| | InitializeCriticalSection(&key_lock); 421| | 422| |#else /* POSIX */ 423| | 424| 1| err = k5_mutex_finish_init(&key_lock); 425| 1| if (err) ------------------ | Branch (425:9): [True: 0, False: 1] ------------------ 426| 0| return err; 427| 1| if (K5_PTHREADS_LOADED) { ------------------ | | 127| 1|# define K5_PTHREADS_LOADED (krb5int_pthread_loaded()) | | ------------------ | | | Branch (127:33): [True: 1, False: 0] | | ------------------ ------------------ 428| 1| err = pthread_key_create(&key, thread_termination); 429| 1| if (err) ------------------ | Branch (429:13): [True: 0, False: 1] ------------------ 430| 0| return err; 431| 1| } 432| | 433| 1|#endif 434| | 435| 1| err = krb5int_init_fac(); 436| 1| if (err) ------------------ | Branch (436:9): [True: 0, False: 1] ------------------ 437| 0| return err; 438| | 439| 1| err = krb5int_err_init(); 440| 1| if (err) ------------------ | Branch (440:9): [True: 0, False: 1] ------------------ 441| 0| return err; 442| | 443| 1| return 0; 444| 1|} krb5int_ucs4_to_utf8: 135| 50.4k|{ 136| 50.4k| size_t len = 0; 137| 50.4k| unsigned char *p = (unsigned char *) buf; 138| | 139| | /* not a valid Unicode character */ 140| 50.4k| if (c > 0x10ffff) ------------------ | Branch (140:9): [True: 0, False: 50.4k] ------------------ 141| 0| return 0; 142| | 143| | /* Just return length, don't convert */ 144| 50.4k| if (buf == NULL) { ------------------ | Branch (144:9): [True: 25.2k, False: 25.2k] ------------------ 145| 25.2k| if (c < 0x80) return 1; ------------------ | Branch (145:13): [True: 15.8k, False: 9.35k] ------------------ 146| 9.35k| else if (c < 0x800) return 2; ------------------ | Branch (146:18): [True: 1.87k, False: 7.48k] ------------------ 147| 7.48k| else if (c < 0x10000) return 3; ------------------ | Branch (147:18): [True: 7.14k, False: 339] ------------------ 148| 339| else return 4; 149| 25.2k| } 150| | 151| 25.2k| if (c < 0x80) { ------------------ | Branch (151:9): [True: 15.8k, False: 9.35k] ------------------ 152| 15.8k| p[len++] = c; 153| 15.8k| } else if (c < 0x800) { ------------------ | Branch (153:16): [True: 1.87k, False: 7.48k] ------------------ 154| 1.87k| p[len++] = 0xc0 | ( c >> 6 ); 155| 1.87k| p[len++] = 0x80 | ( c & 0x3f ); 156| 7.48k| } else if (c < 0x10000) { ------------------ | Branch (156:16): [True: 7.14k, False: 339] ------------------ 157| 7.14k| p[len++] = 0xe0 | ( c >> 12 ); 158| 7.14k| p[len++] = 0x80 | ( (c >> 6) & 0x3f ); 159| 7.14k| p[len++] = 0x80 | ( c & 0x3f ); 160| 7.14k| } else /* if (c < 0x110000) */ { 161| 339| p[len++] = 0xf0 | ( c >> 18 ); 162| 339| p[len++] = 0x80 | ( (c >> 12) & 0x3f ); 163| 339| p[len++] = 0x80 | ( (c >> 6) & 0x3f ); 164| 339| p[len++] = 0x80 | ( c & 0x3f ); 165| 339| } 166| | 167| 25.2k| return len; 168| 50.4k|} k5_utf16le_to_utf8: 153| 1.73k|{ 154| 1.73k| struct k5buf buf; 155| 1.73k| struct k5input in; 156| 1.73k| uint16_t ch1, ch2; 157| 1.73k| krb5_ucs4 ch; 158| 1.73k| size_t chlen; 159| 1.73k| void *p; 160| | 161| 1.73k| *utf8_out = NULL; 162| | 163| 1.73k| if (nbytes % 2 != 0) ------------------ | Branch (163:9): [True: 0, False: 1.73k] ------------------ 164| 0| return EINVAL; 165| | 166| 1.73k| k5_buf_init_dynamic(&buf); 167| 1.73k| k5_input_init(&in, utf16bytes, nbytes); 168| 26.9k| while (!in.status && in.len > 0) { ------------------ | Branch (168:12): [True: 26.9k, False: 0] | Branch (168:26): [True: 25.4k, False: 1.53k] ------------------ 169| | /* Get the next character or high surrogate. A low surrogate without a 170| | * preceding high surrogate is invalid. */ 171| 25.4k| ch1 = k5_input_get_uint16_le(&in); 172| 25.4k| if (IS_LOW_SURROGATE(ch1)) ------------------ | | 73| 25.4k|#define IS_LOW_SURROGATE(c) ((c) >= 0xDC00 && (c) <= 0xDFFF) | | ------------------ | | | Branch (73:30): [True: 3.50k, False: 21.9k] | | | Branch (73:47): [True: 48, False: 3.45k] | | ------------------ ------------------ 173| 48| goto invalid; 174| 25.3k| if (IS_HIGH_SURROGATE(ch1)) { ------------------ | | 70| 25.3k|#define IS_HIGH_SURROGATE(c) ((c) >= 0xD800 && (c) <= 0xDBFF) | | ------------------ | | | Branch (70:31): [True: 3.94k, False: 21.4k] | | | Branch (70:48): [True: 483, False: 3.45k] | | ------------------ ------------------ 175| | /* Get the low surrogate and combine the pair. */ 176| 483| ch2 = k5_input_get_uint16_le(&in); 177| 483| if (!IS_LOW_SURROGATE(ch2)) ------------------ | | 73| 483|#define IS_LOW_SURROGATE(c) ((c) >= 0xDC00 && (c) <= 0xDFFF) | | ------------------ | | | Branch (73:30): [True: 354, False: 129] | | | Branch (73:47): [True: 339, False: 15] | | ------------------ ------------------ 178| 144| goto invalid; 179| 339| ch = COMPOSE(ch1, ch2); ------------------ | | 89| 339|#define COMPOSE(c1, c2) (BASE + ((((c1) & 0x3FF) << 10) | ((c2) & 0x3FF))) | | ------------------ | | | | 86| 339|#define BASE 0x10000 | | ------------------ ------------------ 180| 24.8k| } else { 181| 24.8k| ch = ch1; 182| 24.8k| } 183| | 184| 25.2k| chlen = krb5int_ucs4_to_utf8(ch, NULL); 185| 25.2k| p = k5_buf_get_space(&buf, chlen); 186| 25.2k| if (p == NULL) ------------------ | Branch (186:13): [True: 0, False: 25.2k] ------------------ 187| 0| return ENOMEM; 188| 25.2k| (void)krb5int_ucs4_to_utf8(ch, p); 189| 25.2k| } 190| | 191| 1.53k| if (in.status) ------------------ | Branch (191:9): [True: 0, False: 1.53k] ------------------ 192| 0| goto invalid; 193| | 194| 1.53k| *utf8_out = k5_buf_cstring(&buf); 195| 1.53k| return (*utf8_out == NULL) ? ENOMEM : 0; ------------------ | Branch (195:12): [True: 0, False: 1.53k] ------------------ 196| | 197| 192|invalid: 198| 192| k5_buf_free(&buf); 199| | return EINVAL; 200| 1.53k|}