]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
access: use bin2hex() instead own bin to hex converter
authorJaroslav Kysela <perex@perex.cz>
Wed, 27 Dec 2017 08:30:35 +0000 (09:30 +0100)
committerJaroslav Kysela <perex@perex.cz>
Wed, 27 Dec 2017 08:30:35 +0000 (09:30 +0100)
src/access.c

index 2c4d0a0f822a95ef0eef0b6f64efbac0eaaf74db..20e798f5284a32abc92dcff56b102d9a740b5e32 100644 (file)
@@ -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);