]> www.average.org Git - pam_pcsc_cr.git/blobdiff - authfile.c
path= and injectauth params
[pam_pcsc_cr.git] / authfile.c
index 8c023d1e8e3a8a0ddd422082d96c5288e69dabec..f6a7fea4057d7df1fc90a2f847762d2981c4c7bd 100644 (file)
@@ -27,9 +27,9 @@
  * string.
  */
 
-static char *template = "~/.pam_cr/auth";
+static const char *template = "~/.pam_cr/auth";
 
-void authfile_template(char *str)
+void authfile_template(const char *str)
 {
        template = str;
 }
@@ -37,7 +37,7 @@ void authfile_template(char *str)
 static int path_size(const char *tokenid, const char *userid)
 {
        const char *usub;
-       char *p, *q;
+       const char *p, *q;
        struct passwd *pw;
 
        if ((p = strchr(template, '~')) != strrchr(template, '~')) return 0;
@@ -58,7 +58,8 @@ static void
 make_path(char * const path, const char *tokenid, const char *userid)
 {
        const char *usub;
-       char *p, *q;
+       const char *p;
+       char *q;
        struct passwd *pw;
 
        path[0] = '\0';
@@ -215,7 +216,7 @@ struct _auth_obj authfile(const char *tokenid,
        }
 
        if (!ret.err) {
-               int bufsize = (w.userid?strlen(w.userid)+1:0) + ao.paylsize;
+               int bufsize = (w.userid?strlen(w.userid)+1:0) + ao.paylsize + 1;
                if (bufsize) {
                        if ((ret.buffer = malloc(bufsize)) == NULL) {
                                ret.err = "authfile malloc failed";
@@ -229,8 +230,9 @@ struct _auth_obj authfile(const char *tokenid,
                                }
                                if (ao.payload) {
                                        memcpy(p, ao.payload, ao.paylsize);
+                                       p[ao.paylsize] = '\0';
                                        ret.payload = p;
-                                       ret.paylsize = ao.paylsize;
+                                       ret.paylsize = ao.paylsize+1;
                                }
                        }
                }