]> www.average.org Git - pam_pcsc_cr.git/commitdiff
Initialize pad memory to pacify stack protectors
authorEugene Crosser <crosser@average.org>
Sun, 5 Nov 2017 19:25:20 +0000 (20:25 +0100)
committerEugene Crosser <crosser@average.org>
Sun, 5 Nov 2017 19:25:20 +0000 (20:25 +0100)
- Initialize memory area that is being encrypted, because it is allocated
  rounded up to CBLKSIZE, and the last bytes are not used. If stack
  protector is active, it detects access to uninitialized memory.
- Change default pamdir to /lib/${host_cpu}-${host_os}/security.
- Fix a couple of compilation warnings.

.gitignore
authobj.c
configure.ac
pcsc_cr.c
test_chalresp.c

index 0fb01935af17389b9409de6201805b3e4c45d655..9bad79ded70b9af772fd81cb44e2a4423a46c4b4 100644 (file)
@@ -12,6 +12,7 @@ Makefile
 Makefile.in
 aclocal.m4
 autom4te.cache/
+compile
 config.guess
 config.h
 config.h.in
index b402094df224cd13651227c15e47bb9184976343..deba02868152e70a575194b452ac828d1d1e903f 100644 (file)
--- a/authobj.c
+++ b/authobj.c
@@ -126,6 +126,15 @@ make_authobj(const char *userid, const char *password, const char *nonce,
        datasize = ((secsize + paylsize + HASHSIZE + 4 * sizeof(short) - 1) /
                        CBLKSIZE + 1) * CBLKSIZE;
        data = alloca(datasize);
+       /* 
+          We allocate memory rounded up to CBLKSIZE on the stack, but do not
+          use the last bytes. Stack protectors, if enabled, fill this memory
+          with `canary` value. Later, when encryption function is called,
+          stack protector detects that it tries to access "uninitialized
+          memory". Which, while technically true, is not an error. Still,
+          let us make stack protector happy by initializing the whole area:
+        */
+       memset(data, 0, datasize);
        serial_init(&srl, data, datasize);
        if (serial_put(&srl, secret, secsize) != secsize) {
                ao.err = "authobj: serialization of secret failed";
index 0fc618e9d42537aeec4630d9351131e958ff3d44..e6bd59a5aaf2cf37ac5fe29f608fa6cfd20011bf 100644 (file)
@@ -1,6 +1,6 @@
 dnl Process this file with autoconf to produce a configure script.
 
-AC_INIT([pam_pcsc_cr], 0.9.3)
+AC_INIT([pam_pcsc_cr], 0.9.4)
 AC_CONFIG_SRCDIR([pam_pcsc_cr.c])
 AC_CONFIG_MACRO_DIR([m4])
 AM_INIT_AUTOMAKE
@@ -28,13 +28,14 @@ AC_CHECK_HEADERS([security/pam_modules.h security/pam_ext.h], [], [], [
 ])
 AC_CHECK_LIB([pam], [pam_start])
 AC_CHECK_FUNCS([pam_get_authtok])
+pamdir=/lib/${host_cpu}-${host_os}/security
 AC_ARG_WITH(pam-dir,
-       [  --with-pam-dir=DIR      path to install the PAM module (/lib/security)],
+       [  --with-pam-dir=DIR      path to install the PAM module (${pamdir})],
        [PAMDIR="$withval"],
        [
 case $prefix in
-*/_inst) PAMDIR='${exec_prefix}/lib/security' ;;
-*)       PAMDIR=/lib/security ;;
+*/_inst) PAMDIR="${prefix}${pamdir}" ;;
+*)       PAMDIR=${pamdir} ;;
 esac
 ])
 AC_SUBST(PAMDIR)
index 984f73b2d4e9f7879fd933cbe8c0ec136c615339..7f2ccffb6bb2c863112c3aa3fe95ee610669411e 100644 (file)
--- a/pcsc_cr.c
+++ b/pcsc_cr.c
@@ -132,7 +132,7 @@ free_out:
        return rc;
 }
 
-char *pcsc_errstr(long err) {
+const char *pcsc_errstr(long err) {
        return pcsc_stringify_error(err);
 }
 
index 5fda704b5652f2e1ad2773cd7328baa6d3201b0a..4f0c3e0aae3de743263296a920f60d407e3bf0f7 100644 (file)
@@ -30,7 +30,7 @@ freely, subject to the following restrictions:
 #include <string.h>
 #include "pcsc_cr.h"
 
-static void usage(const char const *cmd)
+static void usage(const char *const cmd)
 {
        fprintf(stderr,
                "usage: %s [-o backend:name=value] ... \"challenge\"\n",