changeset 905:698b6a9bd75e

Fix coding style for C code astyle --style=gnu --indent=spaces=2
author Andre Heinecke <andre.heinecke@intevation.de>
date Wed, 13 Aug 2014 15:49:47 +0200
parents f89b41fa7048
children 1dc1f5a4b577
files cinst/main.c cinst/mozilla.c cinst/nssstore_linux.c cinst/nssstore_win.c cinst/windowsstore.c common/binverify.c common/listutil.c common/logging.c common/strhelp.c common/util.c
diffstat 10 files changed, 354 insertions(+), 317 deletions(-) [+]
line wrap: on
line diff
--- a/cinst/main.c	Wed Aug 13 15:44:35 2014 +0200
+++ b/cinst/main.c	Wed Aug 13 15:49:47 2014 +0200
@@ -75,7 +75,7 @@
  */
 static int
 read_choices_file (char *file_name, char ***to_install,
-                        char ***to_remove)
+                   char ***to_remove)
 {
   int lines_read = 0;
   char buf[MAX_LINE_LENGTH + 2];
@@ -205,13 +205,13 @@
 {
   /* TODO handle wchar arguments on Windows or do conversion dance */
   char **to_install = NULL,
-       **to_remove = NULL,
-       **all_valid_certs = NULL;
+         **to_remove = NULL,
+           **all_valid_certs = NULL;
   int ret = -1;
 
   char *certificate_list = NULL,
-       *certificate_file_name = NULL,
-       *choices_file_name = NULL;
+        *certificate_file_name = NULL,
+         *choices_file_name = NULL;
   size_t list_len = 0;
   list_status_t list_status;
   bool do_uninstall = false;
@@ -220,7 +220,7 @@
      added to make it more transparent how this programm is called if
      a user looks at the detailed uac dialog. */
   if (argc != 3 || strncmp(argv[1], "list=", 5) != 0 ||
-                   strncmp(argv[2], "choices=", 8) != 0)
+      strncmp(argv[2], "choices=", 8) != 0)
     {
       ERRORPRINTF ("Invalid arguments.\n"
                    "Expected arguments: list=<certificate_list> \n"
@@ -284,7 +284,7 @@
     }
 
   ret = read_choices_file (choices_file_name, &to_install,
-                                &to_remove);
+                           &to_remove);
 
   if (ret)
     {
--- a/cinst/mozilla.c	Wed Aug 13 15:44:35 2014 +0200
+++ b/cinst/mozilla.c	Wed Aug 13 15:49:47 2014 +0200
@@ -349,11 +349,12 @@
       DEBUGPRINTF("Listing certs in \"%s\"\n", confdir);
       list = PK11_ListCerts(PK11CertListAll, NULL);
       for (node = CERT_LIST_HEAD(list); !CERT_LIST_END(node, list);
-           node = CERT_LIST_NEXT(node)) {
-        name = node->appData;
+           node = CERT_LIST_NEXT(node))
+        {
+          name = node->appData;
 
-        DEBUGPRINTF("Found certificate \"%s\"\n", name);
-      }
+          DEBUGPRINTF("Found certificate \"%s\"\n", name);
+        }
       CERT_DestroyCertList(list);
       NSS_Shutdown();
     }
@@ -687,8 +688,8 @@
       strv_free(dbdirs);
     }
 
- fclose(input_stream);
+  fclose(input_stream);
 
- exit:
+exit:
   exit(exit_code);
 }
--- a/cinst/nssstore_linux.c	Wed Aug 13 15:44:35 2014 +0200
+++ b/cinst/nssstore_linux.c	Wed Aug 13 15:49:47 2014 +0200
@@ -50,8 +50,8 @@
   int pipe_fd[2];
   pid_t pid = 0;
   char *argv[2] = {NULL, NULL},
-       *envp[2] = {NULL, NULL},
-       *inst_dir = NULL;
+                  *envp[2] = {NULL, NULL},
+                             *inst_dir = NULL;
   size_t homedir_len = 0,
          exe_path_len = 0;
   int ret = -1,
@@ -179,9 +179,10 @@
   success = true;
 
 done:
-  if (stream) {
-    fclose (stream);
-  }
+  if (stream)
+    {
+      fclose (stream);
+    }
   xfree (argv[0]);
   xfree (envp[0]);
   close (pipe_fd[0]);
--- a/cinst/nssstore_win.c	Wed Aug 13 15:44:35 2014 +0200
+++ b/cinst/nssstore_win.c	Wed Aug 13 15:49:47 2014 +0200
@@ -71,7 +71,8 @@
 #define PROFILE_LIST L"Software\\Microsoft\\Windows NT\\CurrentVersion\\ProfileList"
 #define RUNONCE_PATH L"Software\\Microsoft\\Windows\\CurrentVersion\\RunOnce"
 
-struct profile_key_path {
+struct profile_key_path
+{
   char *sid;
   char *hive_path;
   struct profile_key_path *next;
@@ -118,13 +119,13 @@
       return NULL;
     }
 
-   if (!SaferComputeTokenFromLevel(user_level, NULL, &retval, 0, NULL))
+  if (!SaferComputeTokenFromLevel(user_level, NULL, &retval, 0, NULL))
     {
-        SaferCloseLevel(user_level);
-        return NULL;
+      SaferCloseLevel(user_level);
+      return NULL;
     }
 
-   return retval;
+  return retval;
 }
 
 /**@brief Write strv of instructions to a handle
@@ -227,7 +228,7 @@
   wchar_t key_name[257],
           *current_user_sid = NULL;
   pkp_t *retval = NULL,
-        *cur_item = NULL;
+         *cur_item = NULL;
   bool error = true;
   PSID current_user = NULL;
 
@@ -376,7 +377,7 @@
   /* installdir + dirsep +  quotes + process name + space + quotes + selection_file
      + NULL */
   cmd_line_len = wcslen (w_inst_dir) + 1 + 2 + wcslen (NSS_APP_NAME) +
-    + 1 + 2 + wcslen(selection_file) + 1;
+                 + 1 + 2 + wcslen(selection_file) + 1;
   retval = xmalloc (cmd_line_len * sizeof(wchar_t));
 
   wcscpy_s (retval, cmd_line_len, L"\"");
@@ -508,7 +509,7 @@
 register_proccesses_for_others (wchar_t *selection_file)
 {
   pkp_t *pkplist = locate_other_hives(),
-        *cur = NULL;
+         *cur = NULL;
   wchar_t *run_command = NULL;
 
   if (pkplist == NULL)
@@ -547,7 +548,7 @@
              in the standard location or already loaded. Try to access
              the loaded registry in that case*/
           wchar_t *user_key = NULL,
-                  *w_sid = NULL;
+                   *w_sid = NULL;
           size_t user_key_len = 0;
 
           SetLastError((DWORD)ret);
@@ -817,7 +818,7 @@
 
   /* Initialize a security descriptor */
   descriptor = (PSECURITY_DESCRIPTOR) LocalAlloc(LPTR,
-                                                 SECURITY_DESCRIPTOR_MIN_LENGTH);
+               SECURITY_DESCRIPTOR_MIN_LENGTH);
   if (descriptor == NULL)
     {
       PRINTLASTERROR("Failed to allocate descriptor.");
@@ -892,7 +893,7 @@
 write_selection_file (char **to_install, char **to_remove)
 {
   wchar_t *folder_name = NULL,
-          *path = NULL;
+           *path = NULL;
   HRESULT result = E_FAIL;
   HANDLE hFile = NULL;
   size_t path_len;
--- a/cinst/windowsstore.c	Wed Aug 13 15:44:35 2014 +0200
+++ b/cinst/windowsstore.c	Wed Aug 13 15:49:47 2014 +0200
@@ -141,11 +141,11 @@
         }
 
       found_cert = CertFindCertificateInStore (hStore,
-                                               X509_ASN_ENCODING | PKCS_7_ASN_ENCODING,
-                                               0,
-                                               CERT_FIND_EXISTING,
-                                               pc_to_add,
-                                               NULL);
+                   X509_ASN_ENCODING | PKCS_7_ASN_ENCODING,
+                   0,
+                   CERT_FIND_EXISTING,
+                   pc_to_add,
+                   NULL);
       if (found_cert != NULL)
         {
           DEBUGPRINTF ("Certificate already in store\n");
--- a/common/binverify.c	Wed Aug 13 15:44:35 2014 +0200
+++ b/common/binverify.c	Wed Aug 13 15:49:47 2014 +0200
@@ -17,7 +17,8 @@
 #endif
 
 bin_verify_result
-verify_binary(const char *filename, size_t name_len) {
+verify_binary(const char *filename, size_t name_len)
+{
   if (!filename || !name_len)
     return VerifyUnknownError;
 #ifdef WIN32
@@ -98,7 +99,8 @@
 }
 
 bin_verify_result
-verify_binary_win(const char *filename, size_t name_len) {
+verify_binary_win(const char *filename, size_t name_len)
+{
   bin_verify_result retval = VerifyUnknownError;
   WCHAR *filenameW = NULL;
   BOOL result = FALSE;
@@ -166,9 +168,9 @@
     }
 
   pSignerCertContext = CertGetSubjectCertificateFromStore(
-          hStore,
-          PKCS_7_ASN_ENCODING | X509_ASN_ENCODING,
-          pSignerCert);
+                         hStore,
+                         PKCS_7_ASN_ENCODING | X509_ASN_ENCODING,
+                         pSignerCert);
 
   if (!pSignerCertContext)
     {
@@ -241,11 +243,11 @@
   int ret = -1;
   const size_t sig_b64_size = TRUSTBRIDGE_RSA_KEY_SIZE / 8 * 4 / 3;
   char *data = NULL,
-       signature_b64[sig_b64_size + 1];
+        signature_b64[sig_b64_size + 1];
   size_t data_size = 0,
          sig_size = TRUSTBRIDGE_RSA_KEY_SIZE / 8;
   unsigned char signature[sig_size],
-                hash[32];
+           hash[32];
 
   bin_verify_result retval = VerifyUnknownError;
   x509_crt codesign_cert;
--- a/common/listutil.c	Wed Aug 13 15:44:35 2014 +0200
+++ b/common/listutil.c	Wed Aug 13 15:49:47 2014 +0200
@@ -41,181 +41,205 @@
 #define READ_FILE_INVALID_CALL -5
 int
 read_file(const char *file_name, char **data, size_t *size,
-                     const size_t max_size)
+          const size_t max_size)
 {
-    FILE *f;
-    long file_size;
-
-    if (!file_name || !data || !size || !max_size) {
-        return READ_FILE_INVALID_CALL;
-    }
+  FILE *f;
+  long file_size;
 
-    f = fopen(file_name, "rb");
-    if (f == NULL)
-        return READ_FILE_UNREADABLE;
-
-    fseek(f, 0, SEEK_END);
-    file_size = ftell(f);
-    if (file_size <= 0){
-        fclose(f);
-        return READ_FILE_UNREADABLE;
+  if (!file_name || !data || !size || !max_size)
+    {
+      return READ_FILE_INVALID_CALL;
     }
 
-    fseek(f, 0, SEEK_SET);
+  f = fopen(file_name, "rb");
+  if (f == NULL)
+    return READ_FILE_UNREADABLE;
 
-    if (file_size + 1 == 0) {
-        fclose(f);
-        return READ_FILE_TOO_LARGE;
-    }
-    *size = (size_t) file_size;
-
-    if (*size > max_size) {
-        fclose(f);
-        return READ_FILE_TOO_LARGE;
+  fseek(f, 0, SEEK_END);
+  file_size = ftell(f);
+  if (file_size <= 0)
+    {
+      fclose(f);
+      return READ_FILE_UNREADABLE;
     }
 
-    *data = (char *) malloc( *size + 1 );
-    if (*data == NULL) {
-        fclose(f);
-        return READ_FILE_NO_MEMORY;
+  fseek(f, 0, SEEK_SET);
+
+  if (file_size + 1 == 0)
+    {
+      fclose(f);
+      return READ_FILE_TOO_LARGE;
+    }
+  *size = (size_t) file_size;
+
+  if (*size > max_size)
+    {
+      fclose(f);
+      return READ_FILE_TOO_LARGE;
     }
 
-    if (fread(*data, 1, *size, f) != *size) {
-        free(*data);
-        fclose(f);
-        return READ_FILE_READ_FAILED;
+  *data = (char *) malloc( *size + 1 );
+  if (*data == NULL)
+    {
+      fclose(f);
+      return READ_FILE_NO_MEMORY;
     }
 
-    fclose(f);
+  if (fread(*data, 1, *size, f) != *size)
+    {
+      free(*data);
+      fclose(f);
+      return READ_FILE_READ_FAILED;
+    }
 
-    (*data)[*size] = '\0';
+  fclose(f);
 
-    return 0;
+  (*data)[*size] = '\0';
+
+  return 0;
 }
 
 int verify_list(const char *data, const size_t size)
 {
-    int ret = -1;
-    pk_context pub_key_ctx;
-    char *p;
+  int ret = -1;
+  pk_context pub_key_ctx;
+  char *p;
 
-    /* Modulus / 8 are the necessary bytes. */
+  /* Modulus / 8 are the necessary bytes. */
 #ifndef TRUSTBRIDGE_RSA_KEY_SIZE
 # error "Key size undefined"
 #endif
-    const size_t sig_b64_size = TRUSTBRIDGE_RSA_KEY_SIZE / 8 * 4 / 3;
-    size_t sig_size = TRUSTBRIDGE_RSA_KEY_SIZE / 8;
+  const size_t sig_b64_size = TRUSTBRIDGE_RSA_KEY_SIZE / 8 * 4 / 3;
+  size_t sig_size = TRUSTBRIDGE_RSA_KEY_SIZE / 8;
 
-    char signature_b64[sig_b64_size + 1];
-    unsigned char signature[sig_size];
-    /* Hash algroithm is sha256 */
-    unsigned char hash[32];
+  char signature_b64[sig_b64_size + 1];
+  unsigned char signature[sig_size];
+  /* Hash algroithm is sha256 */
+  unsigned char hash[32];
 
-    if (!data || !size) {
-        return -1;
+  if (!data || !size)
+    {
+      return -1;
     }
 
-    /* Fetch the signature from the first line od data */
-    p = strchr(data, '\r');
-    if (p == 0 || (unsigned int)(p - (data + 2)) != sig_b64_size) {
-/*        printf("Invalid data. Signature might be too long.\n"); */
-        return -1;
+  /* Fetch the signature from the first line od data */
+  p = strchr(data, '\r');
+  if (p == 0 || (unsigned int)(p - (data + 2)) != sig_b64_size)
+    {
+      /*        printf("Invalid data. Signature might be too long.\n"); */
+      return -1;
     }
-    strncpy(signature_b64, data + 2, sig_b64_size);
-    signature_b64[sig_b64_size] = '\0';
+  strncpy(signature_b64, data + 2, sig_b64_size);
+  signature_b64[sig_b64_size] = '\0';
 
-    ret = base64_decode(signature, &sig_size,
-                        (unsigned char *)signature_b64, sig_b64_size);
+  ret = base64_decode(signature, &sig_size,
+                      (unsigned char *)signature_b64, sig_b64_size);
 
-    if (ret != 0 || sig_size != TRUSTBRIDGE_RSA_KEY_SIZE / 8) {
-/*        printf("failed to decode signature\n"); */
-        return -1;
+  if (ret != 0 || sig_size != TRUSTBRIDGE_RSA_KEY_SIZE / 8)
+    {
+      /*        printf("failed to decode signature\n"); */
+      return -1;
     }
 
-    /* Hash is calculated over the data without the first line.
-     * linebreaks are \r\n so the first char of the new line is
-     * p+2 */
-    p += 2;
-    /* Size of the data to hash is the size - signature line
-     * signature line is sig_b64_size - "S:" and - "\r\n" so -4*/
-    sha256((unsigned char *)p, size - sig_b64_size - 4, hash, 0);
+  /* Hash is calculated over the data without the first line.
+   * linebreaks are \r\n so the first char of the new line is
+   * p+2 */
+  p += 2;
+  /* Size of the data to hash is the size - signature line
+   * signature line is sig_b64_size - "S:" and - "\r\n" so -4*/
+  sha256((unsigned char *)p, size - sig_b64_size - 4, hash, 0);
 
-    pk_init(&pub_key_ctx);
+  pk_init(&pub_key_ctx);
 
-    ret = pk_parse_public_key(&pub_key_ctx, public_key_pem,
-                              public_key_pem_size);
-    if (ret != 0) {
-        ERRORPRINTF ("pk_parse_public_key failed with -0x%04x\n\n", -ret);
-        pk_free(&pub_key_ctx);
-        return ret;
+  ret = pk_parse_public_key(&pub_key_ctx, public_key_pem,
+                            public_key_pem_size);
+  if (ret != 0)
+    {
+      ERRORPRINTF ("pk_parse_public_key failed with -0x%04x\n\n", -ret);
+      pk_free(&pub_key_ctx);
+      return ret;
     }
 
-    ret = pk_verify(&pub_key_ctx, POLARSSL_MD_SHA256, hash, 0,
-                    signature, sig_size);
+  ret = pk_verify(&pub_key_ctx, POLARSSL_MD_SHA256, hash, 0,
+                  signature, sig_size);
 
-    if (ret != 0) {
-        ERRORPRINTF ("pk_verify failed with -0x%04x\n\n", -ret);
+  if (ret != 0)
+    {
+      ERRORPRINTF ("pk_verify failed with -0x%04x\n\n", -ret);
     }
-    pk_free(&pub_key_ctx);
+  pk_free(&pub_key_ctx);
 
-    return ret;
+  return ret;
 }
 
 list_status_t read_and_verify_list(const char *file_name, char **data,
                                    size_t *size)
 {
-    list_status_t retval = UnknownError;
-    *data = NULL;
-    *size = 0;
-    int ret = 0;
-
-    ret = read_file(file_name, data, size, MAX_FILESIZE);
+  list_status_t retval = UnknownError;
+  *data = NULL;
+  *size = 0;
+  int ret = 0;
 
-    /* printf ("Ret: %i \n", ret); */
-    if (ret != 0) {
-        if (ret == READ_FILE_TOO_LARGE) {
-            return TooLarge;
+  ret = read_file(file_name, data, size, MAX_FILESIZE);
+
+  /* printf ("Ret: %i \n", ret); */
+  if (ret != 0)
+    {
+      if (ret == READ_FILE_TOO_LARGE)
+        {
+          return TooLarge;
         }
-        if (ret == READ_FILE_UNREADABLE) {
-            /* TODO: work with errno ? */
-	    /* errsv = errno; */
-	    /* perror("read_and_verify_list(), READ_FILE_UNREADABLE:");  */
-            return SeekFailed;
+      if (ret == READ_FILE_UNREADABLE)
+        {
+          /* TODO: work with errno ? */
+          /* errsv = errno; */
+          /* perror("read_and_verify_list(), READ_FILE_UNREADABLE:");  */
+          return SeekFailed;
         }
-        if (ret == READ_FILE_READ_FAILED) {
-            /* TODO: work with ferror() or feof() ? */
-            return ReadFailed;
+      if (ret == READ_FILE_READ_FAILED)
+        {
+          /* TODO: work with ferror() or feof() ? */
+          return ReadFailed;
         }
-        return UnknownError;
+      return UnknownError;
     }
 
-    if (!*data || !*size) {
-        /* File is probably empty */
-        return UnknownError;
+  if (!*data || !*size)
+    {
+      /* File is probably empty */
+      return UnknownError;
     }
 
-    if (**data != 'S') {
-        retval = InvalidFormat;
-    } else {
-        ret = verify_list (*data, *size);
-        if (ret == 0) {
-            /* Hooray */
-            return Valid;
+  if (**data != 'S')
+    {
+      retval = InvalidFormat;
+    }
+  else
+    {
+      ret = verify_list (*data, *size);
+      if (ret == 0)
+        {
+          /* Hooray */
+          return Valid;
         }
-        if (ret == -1) {
-            /* our error */
-            retval = InvalidFormat;
-        } else {
-            retval = InvalidSignature;
+      if (ret == -1)
+        {
+          /* our error */
+          retval = InvalidFormat;
+        }
+      else
+        {
+          retval = InvalidSignature;
         }
     }
 
-    if (retval != Valid && *data) {
-        free(*data);
-        *data = NULL;
-        *size = 0;
+  if (retval != Valid && *data)
+    {
+      free(*data);
+      *data = NULL;
+      *size = 0;
     }
-    return retval;
+  return retval;
 }
 
 char **
--- a/common/logging.c	Wed Aug 13 15:44:35 2014 +0200
+++ b/common/logging.c	Wed Aug 13 15:49:47 2014 +0200
@@ -137,10 +137,11 @@
                           (LPWSTR) &bufPtr, 0, NULL);
         }
     }
-  if (!bufPtr) {
-    fprintf (stderr, "Error getting last error for code: %lx \n", err);
-    return NULL;
-  }
+  if (!bufPtr)
+    {
+      fprintf (stderr, "Error getting last error for code: %lx \n", err);
+      return NULL;
+    }
 
   retval = wchar_to_utf8(bufPtr, wcslen(bufPtr));
   LocalFree (bufPtr);
@@ -217,22 +218,22 @@
   fingerprint[32*3] = '\0';
 
 #ifdef WIN32
-    {
-      wchar_t *wstrings[3];
-
-      wstrings[0] = utf8_to_wchar (subject, strnlen (subject, MAX_LOG));
-      wstrings[1] = utf8_to_wchar (fingerprint, strnlen (fingerprint, MAX_LOG));
-      wstrings[2] = utf8_to_wchar (store, strnlen (store, MAX_LOG));
+  {
+    wchar_t *wstrings[3];
 
-      win_do_log (EVENTLOG_INFORMATION_TYPE,
-                  EVENT_CAT_CINST,
-                  install ? MSG_CERT_INSTALL : MSG_CERT_REMOVE,
-                  3,
-                  (const WCHAR**) wstrings);
-      xfree (wstrings[0]);
-      xfree (wstrings[1]);
-      xfree (wstrings[2]);
-    }
+    wstrings[0] = utf8_to_wchar (subject, strnlen (subject, MAX_LOG));
+    wstrings[1] = utf8_to_wchar (fingerprint, strnlen (fingerprint, MAX_LOG));
+    wstrings[2] = utf8_to_wchar (store, strnlen (store, MAX_LOG));
+
+    win_do_log (EVENTLOG_INFORMATION_TYPE,
+                EVENT_CAT_CINST,
+                install ? MSG_CERT_INSTALL : MSG_CERT_REMOVE,
+                3,
+                (const WCHAR**) wstrings);
+    xfree (wstrings[0]);
+    xfree (wstrings[1]);
+    xfree (wstrings[2]);
+  }
 #else
   /* Please keep the following line in line with message from events.mc */
   syslog_info_printf ("%s of root certificate: %s Sha256 thumbprint:<%s>. Certificate store \"%s\"",
--- a/common/strhelp.c	Wed Aug 13 15:44:35 2014 +0200
+++ b/common/strhelp.c	Wed Aug 13 15:49:47 2014 +0200
@@ -36,85 +36,89 @@
 static void
 out_of_core(void)
 {
-    fputs("\nfatal: out of memory\n", stderr);
-    exit(2);
+  fputs("\nfatal: out of memory\n", stderr);
+  exit(2);
 }
 void *
 xmalloc( size_t n )
 {
-    void *p = malloc( n );
-    if( !p )
-        out_of_core();
-    return p;
+  void *p = malloc( n );
+  if( !p )
+    out_of_core();
+  return p;
 }
 
 void *
 xrealloc( void *a, size_t n )
 {
-    void *p = realloc( a, n );
-    if( !p )
-        out_of_core();
-    return p;
+  void *p = realloc( a, n );
+  if( !p )
+    out_of_core();
+  return p;
 }
 
 char *
 xstrndup( const char *string, const size_t len )
 {
-    char *p = xmalloc( len + 1 );
-    memcpy( p, string, len );
-    p[len] = '\0';
-    return p;
+  char *p = xmalloc( len + 1 );
+  memcpy( p, string, len );
+  p[len] = '\0';
+  return p;
 }
 
 unsigned int
 strv_length (char **str_array)
 {
-    unsigned int i = 0;
+  unsigned int i = 0;
 
-    if (!str_array)
-        return 0;
+  if (!str_array)
+    return 0;
 
-    while (str_array[i])
-        ++i;
+  while (str_array[i])
+    ++i;
 
-    return i;
+  return i;
 }
 
 void strv_append (char ***pArray, const char *string, const size_t len)
 {
-    unsigned int old_len = 0;
+  unsigned int old_len = 0;
 
-    if (!*pArray) {
-        *pArray = xmalloc(2 * sizeof(char*));
-        (*pArray)[0] = xstrndup(string, len);
-        (*pArray)[1] = NULL;
-        return;
+  if (!*pArray)
+    {
+      *pArray = xmalloc(2 * sizeof(char*));
+      (*pArray)[0] = xstrndup(string, len);
+      (*pArray)[1] = NULL;
+      return;
     }
-    old_len = strv_length(*pArray);
-    *pArray = xrealloc(*pArray, sizeof(char**) * (old_len + 2));
+  old_len = strv_length(*pArray);
+  *pArray = xrealloc(*pArray, sizeof(char**) * (old_len + 2));
 
-    (*pArray)[old_len] = xstrndup(string, len);
-    (*pArray)[old_len + 1] = NULL;
+  (*pArray)[old_len] = xstrndup(string, len);
+  (*pArray)[old_len + 1] = NULL;
 }
 
 void
 str_append_str(char **pDst, size_t *dst_len, const char *appendage, const size_t len)
 {
-    if (!appendage)
-        return;
+  if (!appendage)
+    return;
 
-    if (!(*pDst)) {
-        *pDst = xstrndup(appendage, len);
-        *dst_len = len;
-    } else {
-        size_t new_size = (*dst_len) + len + 1;
-        char *p_old = *pDst;
-        *pDst = xmalloc(new_size);
-        strncpy(*pDst, p_old, *dst_len);
-        strncpy(*pDst + *dst_len, appendage, len);
-        *dst_len = new_size - 1;
-        (*pDst)[*dst_len] = '\0';
-        free (p_old);
+  if (!(*pDst))
+    {
+      *pDst = xstrndup(appendage, len);
+      *dst_len = len;
+    }
+  else
+    {
+      size_t new_size = (*dst_len) + len + 1;
+      char *p_old = *pDst;
+      *pDst = xmalloc(new_size);
+      strncpy(*pDst, p_old, *dst_len);
+      strncpy(*pDst + *dst_len, appendage, len);
+      *dst_len = new_size - 1;
+      (*pDst)[*dst_len] = '\0';
+      free (p_old);
     }
 }
 
@@ -171,31 +175,34 @@
 int str_base64_decode(char **dst, size_t *dst_size, char *src,
                       size_t src_size)
 {
-    int ret = -1;
+  int ret = -1;
 
-    if (!dst || *dst) {
-        return -1;
+  if (!dst || *dst)
+    {
+      return -1;
     }
 
-    /* Check the needed size for the buffer */
-    ret = base64_decode(NULL, dst_size,
-                        (unsigned char *)src, src_size);
+  /* Check the needed size for the buffer */
+  ret = base64_decode(NULL, dst_size,
+                      (unsigned char *)src, src_size);
 
-    if (ret != 0 && ret != POLARSSL_ERR_BASE64_BUFFER_TOO_SMALL) {
-        return ret;
+  if (ret != 0 && ret != POLARSSL_ERR_BASE64_BUFFER_TOO_SMALL)
+    {
+      return ret;
     }
 
-    *dst = xmalloc(*dst_size);
-    memset (*dst, 0, *dst_size);
+  *dst = xmalloc(*dst_size);
+  memset (*dst, 0, *dst_size);
 
-    ret = base64_decode((unsigned char *)*dst, dst_size,
-                        (unsigned char *)src, src_size);
-    if (ret) {
-        free (*dst);
-        *dst = NULL;
-        *dst_size = 0;
+  ret = base64_decode((unsigned char *)*dst, dst_size,
+                      (unsigned char *)src, src_size);
+  if (ret)
+    {
+      free (*dst);
+      *dst = NULL;
+      *dst_size = 0;
     }
-    return ret;
+  return ret;
 }
 
 void
--- a/common/util.c	Wed Aug 13 15:44:35 2014 +0200
+++ b/common/util.c	Wed Aug 13 15:49:47 2014 +0200
@@ -36,7 +36,7 @@
   LONG ret = 0;
   char *retval = NULL;
   wchar_t *buf = NULL,
-          *ex_buf = NULL;
+           *ex_buf = NULL;
   if (root == NULL || key == NULL || name == NULL)
     {
       ERRORPRINTF ("Invalid call to read_registry_string");
@@ -139,57 +139,57 @@
 bool
 paths_equal (const char *path1, const char *path2)
 {
-    bool ret = false;
-    wchar_t buf1[MAX_PATH],
-            buf2[MAX_PATH];
-    wchar_t *wpath1 = NULL,
-            *wpath2 = NULL;
-    DWORD retval = 0;
-
-    if (!path1 || !path2)
-      {
-        return false;
-      }
-
-    wpath1 = utf8_to_wchar(path1, strnlen(path1, MAX_PATH));
-    wpath2 = utf8_to_wchar(path2, strnlen(path2, MAX_PATH));
-
-    if (wpath1 == NULL || wpath2 == NULL)
-      {
-        ERRORPRINTF ("Failed to convert paths to wchar.");
-        goto done;
-      }
+  bool ret = false;
+  wchar_t buf1[MAX_PATH],
+          buf2[MAX_PATH];
+  wchar_t *wpath1 = NULL,
+           *wpath2 = NULL;
+  DWORD retval = 0;
 
-    retval = GetFullPathNameW (wpath1, MAX_PATH, buf1, NULL);
-    if (retval >= MAX_PATH || retval != wcsnlen (buf1, MAX_PATH))
-      {
-        ERRORPRINTF ("Path1 too long.");
-        goto done;
-      }
-    if (retval == 0)
-      {
-        PRINTLASTERROR ("Failed to get Full Path name.");
-        goto done;
-      }
+  if (!path1 || !path2)
+    {
+      return false;
+    }
 
-    retval = GetFullPathNameW (wpath2, MAX_PATH, buf2, NULL);
-    if (retval >= MAX_PATH || retval != wcsnlen (buf2, MAX_PATH))
-      {
-        ERRORPRINTF ("Path2 too long.");
-        goto done;
-      }
-    if (retval == 0)
-      {
-        PRINTLASTERROR ("Failed to get Full Path name.");
-        goto done;
-      }
+  wpath1 = utf8_to_wchar(path1, strnlen(path1, MAX_PATH));
+  wpath2 = utf8_to_wchar(path2, strnlen(path2, MAX_PATH));
 
-      ret = wcscmp (buf1, buf2) == 0;
+  if (wpath1 == NULL || wpath2 == NULL)
+    {
+      ERRORPRINTF ("Failed to convert paths to wchar.");
+      goto done;
+    }
+
+  retval = GetFullPathNameW (wpath1, MAX_PATH, buf1, NULL);
+  if (retval >= MAX_PATH || retval != wcsnlen (buf1, MAX_PATH))
+    {
+      ERRORPRINTF ("Path1 too long.");
+      goto done;
+    }
+  if (retval == 0)
+    {
+      PRINTLASTERROR ("Failed to get Full Path name.");
+      goto done;
+    }
+
+  retval = GetFullPathNameW (wpath2, MAX_PATH, buf2, NULL);
+  if (retval >= MAX_PATH || retval != wcsnlen (buf2, MAX_PATH))
+    {
+      ERRORPRINTF ("Path2 too long.");
+      goto done;
+    }
+  if (retval == 0)
+    {
+      PRINTLASTERROR ("Failed to get Full Path name.");
+      goto done;
+    }
+
+  ret = wcscmp (buf1, buf2) == 0;
 done:
-    xfree (wpath1);
-    xfree (wpath2);
+  xfree (wpath1);
+  xfree (wpath2);
 
-    return ret;
+  return ret;
 }
 
 char *
@@ -244,42 +244,42 @@
 PSID
 get_process_owner(HANDLE hProcess)
 {
-    HANDLE hToken = NULL;
-    PSID sid;
-
-    if (hProcess == NULL)
-      {
-        ERRORPRINTF ("invalid call to get_process_owner");
-        return NULL;
-      }
+  HANDLE hToken = NULL;
+  PSID sid;
 
-    OpenProcessToken(hProcess, TOKEN_READ, &hToken);
-    if (hToken)
-      {
-        DWORD size = 0;
-        PTOKEN_USER userStruct;
+  if (hProcess == NULL)
+    {
+      ERRORPRINTF ("invalid call to get_process_owner");
+      return NULL;
+    }
 
-        // check how much space is needed
-        GetTokenInformation(hToken, TokenUser, NULL, 0, &size);
-        if (ERROR_INSUFFICIENT_BUFFER == GetLastError())
-          {
-            userStruct = (PTOKEN_USER) xmalloc (size);
-            GetTokenInformation(hToken, TokenUser, userStruct, size, &size);
+  OpenProcessToken(hProcess, TOKEN_READ, &hToken);
+  if (hToken)
+    {
+      DWORD size = 0;
+      PTOKEN_USER userStruct;
 
-            sid = copy_sid(userStruct->User.Sid);
-            CloseHandle(hToken);
-            xfree (userStruct);
-            return sid;
-          }
-      }
-    return NULL;
+      // check how much space is needed
+      GetTokenInformation(hToken, TokenUser, NULL, 0, &size);
+      if (ERROR_INSUFFICIENT_BUFFER == GetLastError())
+        {
+          userStruct = (PTOKEN_USER) xmalloc (size);
+          GetTokenInformation(hToken, TokenUser, userStruct, size, &size);
+
+          sid = copy_sid(userStruct->User.Sid);
+          CloseHandle(hToken);
+          xfree (userStruct);
+          return sid;
+        }
+    }
+  return NULL;
 }
 
 bool
 is_system_install()
 {
   char *reg_inst_dir = NULL,
-       *real_prefix = NULL;
+        *real_prefix = NULL;
   bool ret = false;
 
   reg_inst_dir = read_registry_string (HKEY_LOCAL_MACHINE,
@@ -313,8 +313,8 @@
 get_install_dir()
 {
   char *retval = NULL,
-       *p = NULL,
-       buf[MAX_PATH_LINUX];
+        *p = NULL,
+         buf[MAX_PATH_LINUX];
   ssize_t ret;
   size_t path_len = 0;
 

http://wald.intevation.org/projects/trustbridge/