moved chunk_skip_zero to chunk.h
authorAndreas Steffen <andreas.steffen@strongswan.org>
Tue, 3 Apr 2012 12:12:50 +0000 (14:12 +0200)
committerAndreas Steffen <andreas.steffen@strongswan.org>
Tue, 3 Apr 2012 12:12:50 +0000 (14:12 +0200)
src/libcharon/plugins/stroke/stroke_list.c
src/libstrongswan/chunk.h
src/pki/commands/print.c

index c056dce..1eaa0b8 100644 (file)
@@ -833,7 +833,7 @@ static void stroke_list_certs(linked_list_t *list, char *label,
 
                        fprintf(out, "  subject:  \"%Y\"\n", cert->get_subject(cert));
                        fprintf(out, "  issuer:   \"%Y\"\n", cert->get_issuer(cert));
-                       serial = x509->get_serial(x509);
+                       serial = chunk_skip_zero(x509->get_serial(x509));
                        fprintf(out, "  serial:    %#B\n", &serial);
 
                        /* list validity */
@@ -1015,13 +1015,14 @@ static void stroke_list_crls(linked_list_t *list, bool utc, FILE *out)
                fprintf(out, "  issuer:   \"%Y\"\n", cert->get_issuer(cert));
 
                /* list optional crlNumber */
-               chunk = crl->get_serial(crl);
+               chunk = chunk_skip_zero(crl->get_serial(crl));
                if (chunk.ptr)
                {
                        fprintf(out, "  serial:    %#B\n", &chunk);
                }
                if (crl->is_delta_crl(crl, &chunk))
                {
+                       chunk = chunk_skip_zero(chunk);         
                        fprintf(out, "  delta for: %#B\n", &chunk);
                }
 
index 6726648..4ff686f 100644 (file)
@@ -235,6 +235,24 @@ static inline chunk_t chunk_skip(chunk_t chunk, size_t bytes)
 }
 
 /**
+ * Skip a leading zero-valued byte
+ */
+static inline chunk_t chunk_skip_zero(chunk_t chunk)
+{
+       if (chunk.len && *chunk.ptr == 0x00)
+       {
+               if (chunk.len == 1)
+               {
+                       return chunk_empty;
+               }
+               chunk.ptr++;
+               chunk.len--;
+       }
+       return chunk;
+}
+
+
+/**
  *  Compare two chunks, returns zero if a equals b
  *  or negative/positive if a is small/greater than b
  */
index 02d0cec..a7f02bf 100644 (file)
 #include <time.h>
 
 /**
- * Print a chunk without leading zero byte
- */
-static chunk_t chunk_skip_zero(chunk_t chunk)
-{
-       if (chunk.len && *chunk.ptr == 0x00)
-       {
-               if (chunk.len == 1)
-               {
-                       return chunk_empty;
-               }
-               chunk.ptr++;
-               chunk.len--;
-       }
-       return chunk;
-}
-
-/**
  * Print public key information
  */
 static void print_pubkey(public_key_t *key)