X-Git-Url: http://www.average.org/gitweb/?p=pam_pcsc_cr.git;a=blobdiff_plain;f=authfile.c;h=f6a7fea4057d7df1fc90a2f847762d2981c4c7bd;hp=8c023d1e8e3a8a0ddd422082d96c5288e69dabec;hb=0262298f8fc324fb4a1577f0c205bdf339ded782;hpb=d428f25cb05d2def10d08cd0e34fe5fe4d4b45fc diff --git a/authfile.c b/authfile.c index 8c023d1..f6a7fea 100644 --- a/authfile.c +++ b/authfile.c @@ -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; } } }