Annotation of pkgsrc/security/softhsm/patches/patch-src_bin_softhsm-keyconv.cpp, revision 1.1

1.1     ! he          1: $NetBSD$
        !             2: 
        !             3: Adapt fix for SA59651, similar to CVE-2014-3209, from
        !             4: https://github.com/bellgrim/SoftHSMv2/commit/492447cd4a2be449e99fb9ad2519ea3277aaad28
        !             5: Ensure created pkcs8 file is not group- or world-readable.
        !             6: 
        !             7: --- src/bin/softhsm-keyconv.cpp.orig   2014-05-28 05:59:14.000000000 +0000
        !             8: +++ src/bin/softhsm-keyconv.cpp
        !             9: @@ -48,6 +48,10 @@
        !            10:  #include <iostream>
        !            11:  #include <fstream>
        !            12:  #include <stdint.h>
        !            13: +#include <errno.h>
        !            14: +#include <sys/types.h>
        !            15: +#include <sys/stat.h>
        !            16: +#include <fcntl.h>
        !            17:  
        !            18:  void usage() {
        !            19:    printf("Converting between BIND .private-key format and PKCS#8 key file format.\n");
        !            20: @@ -391,6 +395,15 @@ int to_pkcs8(char *in_path, char *out_pa
        !            21:      return 1;
        !            22:    }
        !            23:  
        !            24: +  // Create and set file permissions if the file does not exist.
        !            25: +  int fd = open(out_path, O_CREAT, S_IRUSR | S_IWUSR);
        !            26: +  if (fd == -1) {
        !            27: +    fprintf(stderr, "ERROR: Could not open the output file: %s (errno %i)\n",
        !            28: +          out_path, errno);
        !            29: +    return 1;
        !            30: +  }
        !            31: +  ::close(fd);
        !            32: +
        !            33:    // Save the the key to the disk
        !            34:    switch(algorithm) {
        !            35:      case DNS_KEYALG_ERROR:

CVSweb <webmaster@jp.NetBSD.org>