2003-02-10 Tom Yu <tlyu@mit.edu>
+ * password_to_key.c (krb5_passwd_to_key): Replace snprintf() call
+ with explicit length checking.
+
+ * memcache.c (krb4int_save_credentials_addr): Renamed from
+ krb_save_credentials().
+ (krb_save_credentials): Implement in terms of
+ krb4int_save_credentials_addr().
+
* password_to_key.c (mit_passwd_to_key, krb5_passwd_to_key)
(afs_passwd_to_key): Fix to have KRB5_CALLCONV.
*/
#include "krb.h"
+#include "krb4int.h"
#ifdef _WIN32
#include <errno.h>
* Returns KSUCCESS if all goes well, otherwise KFAILURE.
*/
-int KRB5_CALLCONV
-krb_save_credentials(sname, sinst, srealm, session,
- lifetime, kvno, ticket, issue_date)
+int
+krb4int_save_credentials_addr(sname, sinst, srealm, session,
+ lifetime, kvno, ticket, issue_date, laddr)
char* sname; /* Service name */
char* sinst; /* Instance */
int kvno; /* Key version number */
KTEXT ticket; /* The ticket itself */
long issue_date; /* The issue time */
+ KRB_UINT32 laddr;
{
CREDENTIALS cr;
return KSUCCESS;
}
+int KRB5_CALLCONV
+krb_save_credentials(
+ char *name,
+ char *inst,
+ char *realm,
+ C_Block session,
+ int lifetime,
+ int kvno,
+ KTEXT ticket,
+ long issue_date)
+{
+ return krb4int_save_credentials_addr(name, inst, realm, session,
+ lifetime, kvno, ticket,
+ issue_date, 0);
+}
+
+
int
krb_delete_cred (sname, sinstance, srealm)
char *sname;
char *passwd,
C_Block key)
{
+ size_t len, tlen;
+ char *p;
+
if (user && instance && realm && passwd) {
- unsigned int len = MAX_K_NAME_SZ + strlen(passwd) + 1;
- char *p = malloc (len);
+ len = MAX_K_NAME_SZ + strlen(passwd) + 1;
+ tlen = strlen(passwd) + strlen(realm) + strlen(user) + strlen(instance) + 1;
+ if (tlen > len)
+ return 0;
+ p = malloc (tlen);
if (p != NULL) {
- snprintf (p, len, "%s%s%s%s", passwd, realm, user, instance);
- p[len - 1] = '\0';
+ sprintf (p, "%s%s%s%s", passwd, realm, user, instance);
des_string_to_key (p, key);
free (p);
return 0;