Browse Source

Merge pull request #665 from libtom/pr/fix-anon-union

avoid using anonymous union (issue #662)
Steffen Jaeckel 1 year ago
parent
commit
fc6b42025b
4 changed files with 9 additions and 9 deletions
  1. 1 1
      src/headers/tomcrypt_private.h
  2. 2 2
      src/misc/pem/pem_pkcs.c
  3. 4 4
      src/misc/pem/pem_read.c
  4. 2 2
      src/misc/pem/pem_ssh.c

+ 1 - 1
src/headers/tomcrypt_private.h

@@ -347,7 +347,7 @@ struct get_char {
       FILE *f;
       FILE *f;
 #endif /* LTC_NO_FILE */
 #endif /* LTC_NO_FILE */
       struct bufp buf;
       struct bufp buf;
-   };
+   } data;
    struct str unget_buf;
    struct str unget_buf;
    char unget_buf_[LTC_PEM_DECODE_BUFSZ];
    char unget_buf_[LTC_PEM_DECODE_BUFSZ];
 };
 };

+ 2 - 2
src/misc/pem/pem_pkcs.c

@@ -272,7 +272,7 @@ int pem_decode_pkcs_filehandle(FILE *f, ltc_pka_key *k, const password_ctx *pw_c
    LTC_ARGCHK(f != NULL);
    LTC_ARGCHK(f != NULL);
    LTC_ARGCHK(k != NULL);
    LTC_ARGCHK(k != NULL);
    {
    {
-      struct get_char g = { .get = pem_get_char_from_file, .f = f };
+      struct get_char g = { .get = pem_get_char_from_file, .data.f = f };
       return s_decode(&g, k, pw_ctx);
       return s_decode(&g, k, pw_ctx);
    }
    }
 }
 }
@@ -284,7 +284,7 @@ int pem_decode_pkcs(const void *buf, unsigned long len, ltc_pka_key *k, const pa
    LTC_ARGCHK(len != 0);
    LTC_ARGCHK(len != 0);
    LTC_ARGCHK(k != NULL);
    LTC_ARGCHK(k != NULL);
    {
    {
-      struct get_char g = { .get = pem_get_char_from_buf, SET_BUFP(.buf, buf, len) };
+      struct get_char g = { .get = pem_get_char_from_buf, SET_BUFP(.data.buf, buf, len) };
       return s_decode(&g, k, pw_ctx);
       return s_decode(&g, k, pw_ctx);
    }
    }
 }
 }

+ 4 - 4
src/misc/pem/pem_read.c

@@ -20,18 +20,18 @@ extern const unsigned long pem_dek_infos_num;
 #ifndef LTC_NO_FILE
 #ifndef LTC_NO_FILE
 int pem_get_char_from_file(struct get_char *g)
 int pem_get_char_from_file(struct get_char *g)
 {
 {
-   return getc(g->f);
+   return getc(g->data.f);
 }
 }
 #endif /* LTC_NO_FILE */
 #endif /* LTC_NO_FILE */
 
 
 int pem_get_char_from_buf(struct get_char *g)
 int pem_get_char_from_buf(struct get_char *g)
 {
 {
    int ret;
    int ret;
-   if (g->buf.work == g->buf.end) {
+   if (g->data.buf.work == g->data.buf.end) {
       return -1;
       return -1;
    }
    }
-   ret = *g->buf.work;
-   g->buf.work++;
+   ret = *g->data.buf.work;
+   g->data.buf.work++;
    return ret;
    return ret;
 }
 }
 
 

+ 2 - 2
src/misc/pem/pem_ssh.c

@@ -801,7 +801,7 @@ int pem_decode_openssh_filehandle(FILE *f, ltc_pka_key *k, const password_ctx *p
    LTC_ARGCHK(f != NULL);
    LTC_ARGCHK(f != NULL);
    LTC_ARGCHK(k != NULL);
    LTC_ARGCHK(k != NULL);
    {
    {
-      struct get_char g = { .get = pem_get_char_from_file, .f = f };
+      struct get_char g = { .get = pem_get_char_from_file, .data.f = f };
       return s_decode_openssh(&g, k, pw_ctx);
       return s_decode_openssh(&g, k, pw_ctx);
    }
    }
 }
 }
@@ -839,7 +839,7 @@ int pem_decode_openssh(const void *buf, unsigned long len, ltc_pka_key *k, const
    LTC_ARGCHK(len != 0);
    LTC_ARGCHK(len != 0);
    LTC_ARGCHK(k != NULL);
    LTC_ARGCHK(k != NULL);
    {
    {
-      struct get_char g = { .get = pem_get_char_from_buf, SET_BUFP(.buf, buf, len) };
+      struct get_char g = { .get = pem_get_char_from_buf, SET_BUFP(.data.buf, buf, len) };
       return s_decode_openssh(&g, k, pw_ctx);
       return s_decode_openssh(&g, k, pw_ctx);
    }
    }
 }
 }