src/message_api.c
changeset 975 f89b6db91780
parent 974 c9a5b9b58f2c
child 992 949450dab40d
     1.1 --- a/src/message_api.c	Thu Aug 04 20:27:40 2016 +0200
     1.2 +++ b/src/message_api.c	Fri Aug 05 10:31:08 2016 +0200
     1.3 @@ -532,12 +532,13 @@
     1.4  
     1.5                      if (_s->filename) {
     1.6                          size_t len = strlen(_s->filename);
     1.7 -                        filename = calloc(1, len + 5);
     1.8 +                        size_t bufsize = len + 5; // length of .pgp extension + NUL
     1.9 +                        filename = calloc(1, bufsize);
    1.10                          if (filename == NULL)
    1.11                              goto enomem;
    1.12  
    1.13 -                        strlcpy(filename, _s->filename, len + 5);
    1.14 -                        strlcpy(filename + len, ".pgp", len + 5);
    1.15 +                        strlcpy(filename, _s->filename, bufsize);
    1.16 +                        strlcat(filename, ".pgp", bufsize);
    1.17                      }
    1.18                      else {
    1.19                          filename = calloc(1, 20);