From: Jaroslav Kysela Date: Wed, 27 Dec 2017 08:30:35 +0000 (+0100) Subject: access: use bin2hex() instead own bin to hex converter X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=94ce31d7735023b66a63a14e4951958664248717;p=thirdparty%2Ftvheadend.git access: use bin2hex() instead own bin to hex converter --- diff --git a/src/access.c b/src/access.c index 2c4d0a0f8..20e798f52 100644 --- a/src/access.c +++ b/src/access.c @@ -129,7 +129,6 @@ access_ticket_create(const char *resource, access_t *a) char id[41]; uint_fast32_t i; access_ticket_t *at; - static const char hex_string[16] = "0123456789ABCDEF"; assert(a); @@ -146,14 +145,8 @@ access_ticket_create(const char *resource, access_t *a) at = calloc(1, sizeof(access_ticket_t)); - uuid_random(buf, 20); - - //convert to hexstring - for (i=0; i < sizeof(buf); i++){ - id[i*2] = hex_string[((buf[i] >> 4) & 0xF)]; - id[(i*2)+1] = hex_string[(buf[i]) & 0x0F]; - } - id[40] = '\0'; + uuid_random(buf, sizeof(buf)); + bin2hex(id, sizeof(id), buf, sizeof(buf)); at->at_id = strdup(id); at->at_resource = strdup(resource);