Project

General

Profile

Bug #5591

initialisation inversion of component order in cmd-crypto/elfsign.c

Added by Richard PALO almost 5 years ago. Updated over 4 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Category:
-
Start date:
2015-02-04
Due date:
% Done:

100%

Estimated time:
Difficulty:
Bite-size
Tags:
needs-triage

Description

KMF_DATA is defined thus:

typedef struct kmf_data
{
    size_t    Length; /* in bytes */
    uchar_t    *Data;
} KMF_DATA;

therefore, the following patch fixes the initialisation order of the components:

diff --git a/usr/src/cmd/cmd-crypto/elfsign/elfsign.c b/usr/src/cmd/cmd-crypto/e
index 45ae510..b11da36 100644
--- a/usr/src/cmd/cmd-crypto/elfsign/elfsign.c
+++ b/usr/src/cmd/cmd-crypto/elfsign/elfsign.c
@@ -736,7 +736,7 @@ create_csr(char *dn)
        KMF_X509_NAME csrSubject;
        KMF_CSR_DATA csr;
        KMF_ALGORITHM_INDEX sigAlg = KMF_ALGID_MD5WithRSA;
-       KMF_DATA signedCsr = { NULL, 0 };
+       KMF_DATA signedCsr = { 0, NULL };
        char *err;
        KMF_ATTRIBUTE   attrlist[16];
        KMF_ENCODE_FORMAT       format;

History

#1

Updated by Andrew Stormont almost 5 years ago

It should be possible to initialise with just a zero:

KMF_DATA signedCsr = { 0 };
#2

Updated by Richard PALO almost 5 years ago

Andrew Stormont wrote:

It should be possible to initialise with just a zero:

[...]

Hi Andrew, personally I am not fond of 'catch all' initialisers that
abuse the laxness of C.

I am would be more inclined to add, and consequently use, a constant such as:

#define KMF_DATA_ZERO { 0, NULL }

please see https://reviews.csiden.org/r/161/

#3

Updated by Gordon Ross almost 5 years ago

I'm with Andrew on that. Minimalist.

#4

Updated by Electric Monk over 4 years ago

  • Status changed from New to Closed
  • % Done changed from 90 to 100

git commit 6b35cb3cf158584a9408d44b9b6796564e8e1882

commit  6b35cb3cf158584a9408d44b9b6796564e8e1882
Author: Richard PALO <richard@NetBSD.org>
Date:   2015-02-17T01:33:42.000Z

    5591 initialisation inversion of component order in cmd-crypto/elfsign.c
    5620 cstyle updates for cmd/cmd-crypto and lib/libkmf
    Reviewed by: Dan McDonald <danmcd@omniti.com>
    Reviewed by: David Höppner <0xffea@gmail.com>
    Reviewed by: Josef "Jeff" Sipek <jeffpc@josefsipek.net>
    Approved by: Dan McDonald <danmcd@omniti.com>

Also available in: Atom PDF