LCOV - code coverage report
Current view: directory - src/trusted/service_runtime/name_service - default_name_service.c (source / functions) Found Hit Coverage
Test: coverage.lcov Lines: 13 9 69.2 %
Date: 2014-06-18 Functions: 0 0 -

       1                 : /*
       2                 :  * Copyright (c) 2011 The Native Client Authors. All rights reserved.
       3                 :  * Use of this source code is governed by a BSD-style license that can be
       4                 :  * found in the LICENSE file.
       5                 :  */
       6                 : 
       7                 : #include "native_client/src/trusted/service_runtime/name_service/default_name_service.h"
       8                 : 
       9                 : #include "native_client/src/shared/platform/nacl_log.h"
      10                 : #include "native_client/src/trusted/desc/nacl_desc_rng.h"
      11                 : #include "native_client/src/trusted/manifest_name_service_proxy/manifest_proxy.h"
      12                 : #include "native_client/src/trusted/service_runtime/include/sys/fcntl.h"
      13                 : #include "native_client/src/trusted/service_runtime/sel_ldr_thread_interface.h"
      14                 : 
      15             295 : int NaClDefaultNameServiceInit(struct NaClNameService *ns) {
      16                 :   /*
      17                 :    * Create an CSPRNG and enter it into the name server.
      18                 :    */
      19             295 :   struct NaClDescRng  *rng = NULL;
      20                 : 
      21             295 :   rng = (struct NaClDescRng *) malloc(sizeof *rng);
      22             295 :   if (NULL == rng) {
      23               0 :     goto malloc_failed;
      24                 :   }
      25             295 :   if (!NaClDescRngCtor(rng)) {
      26               0 :     goto rng_ctor_failed;
      27                 :   }
      28                 : 
      29                 :   /*
      30                 :    * It may appear desirable to insert a factory for rng, so there can
      31                 :    * be per-thread secure rng access.  However, note that the only way
      32                 :    * we "transfer" a RNG is to create a new (but indistinguishable)
      33                 :    * RNG at the recipient, so each lookup results in a new generator
      34                 :    * anyway.
      35                 :    */
      36             295 :   (*NACL_VTBL(NaClNameService, ns)->
      37                 :    CreateDescEntry)(ns,
      38                 :                     "SecureRandom", NACL_ABI_O_RDWR,
      39                 :                     (struct NaClDesc *) rng);
      40             295 :   rng = NULL;
      41                 : 
      42             295 :   return 1;
      43                 : 
      44                 :  rng_ctor_failed:
      45               0 :   free(rng);
      46                 :  malloc_failed:
      47               0 :   return 0;
      48             295 : }

Generated by: LCOV version 1.7