No more space in fingerprints
authorEdouard Tisserant
Wed, 02 Mar 2016 13:20:48 +0100
changeset 489d544f700d26c
parent 488 1ad4da7caa88
child 490 a0cd914fb619
No more space in fingerprints
src/pgp_netpgp.c
     1.1 --- a/src/pgp_netpgp.c	Wed Mar 02 13:11:13 2016 +0100
     1.2 +++ b/src/pgp_netpgp.c	Wed Mar 02 13:20:48 2016 +0100
     1.3 @@ -243,16 +243,15 @@
     1.4      unsigned i;
     1.5      int	n;
     1.6      
     1.7 -    /* 5 char per byte (hexes + space) tuple -1 space at the end + null */
     1.8 -    *str = malloc((length / 2) * 5 - 1 + 1);
     1.9 +    /* 4 char per short (hexes + space) + null */
    1.10 +    *str = malloc((length / 2) + 1);
    1.11      
    1.12      if(*str == NULL)
    1.13          return 0;
    1.14      
    1.15 -    for (n = 0, i = 0 ; i < length - 2; i += 2) {
    1.16 -        n += snprintf(&((*str)[n]), 6, "%02x%02x ", fpr[i], fpr[i+1]);
    1.17 +    for (n = 0, i = 0 ; i < length; i += 2) {
    1.18 +        n += snprintf(&((*str)[n]), 5, "%02x%02x", fpr[i], fpr[i+1]);
    1.19      }
    1.20 -    snprintf(&((*str)[n]), 5, "%02x%02x", fpr[i], fpr[i+1]);
    1.21      
    1.22      return 1;
    1.23  }