merge strcpy_truncate branch
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@5027 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
@@ -10,6 +10,10 @@ Sun Apr 19 09:59:46 1998 Assar Westerlund <assar@sics.se>
|
||||
|
||||
* Makefile.in: add symlink magic for linux
|
||||
|
||||
Sat Feb 7 07:27:18 1998 Assar Westerlund <assar@sics.se>
|
||||
|
||||
* otp_db.c (otp_put): make sure we don't overrun `buf'
|
||||
|
||||
Sun Nov 9 07:14:59 1997 Assar Westerlund <assar@sics.se>
|
||||
|
||||
* otp_locl.h: use xdbm.h
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1995, 1996, 1997 Kungliga Tekniska H<>gskolan
|
||||
* Copyright (c) 1995, 1996, 1997, 1998 Kungliga Tekniska H<>gskolan
|
||||
* (Royal Institute of Technology, Stockholm, Sweden).
|
||||
* All rights reserved.
|
||||
*
|
||||
@@ -145,8 +145,7 @@ otp_get_internal (void *v, OtpContext *ctx, int lockp)
|
||||
p += 4;
|
||||
memcpy (ctx->key, p, OTPKEYSIZE);
|
||||
p += OTPKEYSIZE;
|
||||
strncpy (ctx->seed, p, sizeof(ctx->seed));
|
||||
ctx->seed[sizeof(ctx->seed) - 1] = '\0';
|
||||
strcpy_truncate (ctx->seed, p, sizeof(ctx->seed));
|
||||
if (lockp)
|
||||
return dbm_store (dbm, key, dat, DBM_REPLACE);
|
||||
else
|
||||
@@ -184,15 +183,29 @@ otp_put (void *v, OtpContext *ctx)
|
||||
datum dat, key;
|
||||
char buf[1024], *p;
|
||||
time_t zero = 0;
|
||||
size_t len, rem;
|
||||
|
||||
key.dsize = strlen(ctx->user);
|
||||
key.dptr = ctx->user;
|
||||
|
||||
p = buf;
|
||||
rem = sizeof(buf);
|
||||
|
||||
if (rem < sizeof(zero))
|
||||
return -1;
|
||||
memcpy (p, &zero, sizeof(zero));
|
||||
p += sizeof(zero);
|
||||
rem -= sizeof(zero);
|
||||
len = strlen(ctx->alg->name) + 1;
|
||||
|
||||
if (rem < len)
|
||||
return -1;
|
||||
strcpy (p, ctx->alg->name);
|
||||
p += strlen(p) + 1;
|
||||
p += len;
|
||||
rem -= len;
|
||||
|
||||
if (rem < 4)
|
||||
return -1;
|
||||
{
|
||||
unsigned char *up = (unsigned char *)p;
|
||||
*up++ = (ctx->n >> 24) & 0xFF;
|
||||
@@ -201,10 +214,20 @@ otp_put (void *v, OtpContext *ctx)
|
||||
*up++ = (ctx->n >> 0) & 0xFF;
|
||||
}
|
||||
p += 4;
|
||||
rem -= 4;
|
||||
|
||||
if (rem < OTPKEYSIZE)
|
||||
return -1;
|
||||
memcpy (p, ctx->key, OTPKEYSIZE);
|
||||
p += OTPKEYSIZE;
|
||||
rem -= OTPKEYSIZE;
|
||||
|
||||
len = strlen(ctx->seed) + 1;
|
||||
if (rem < len)
|
||||
return -1;
|
||||
strcpy (p, ctx->seed);
|
||||
p += strlen(p) + 1;
|
||||
p += len;
|
||||
rem -= len;
|
||||
dat.dptr = buf;
|
||||
dat.dsize = p - buf;
|
||||
return dbm_store (dbm, key, dat, DBM_REPLACE);
|
||||
|
@@ -88,15 +88,17 @@ otp_print_hex (OtpKey key, char *str, size_t sz)
|
||||
void
|
||||
otp_print_hex_extended (OtpKey key, char *str, size_t sz)
|
||||
{
|
||||
strncpy (str, OTP_HEXPREFIX, sz);
|
||||
str[sz-1] = '\0';
|
||||
otp_print_hex (key, str + strlen(OTP_HEXPREFIX), sz - strlen(OTP_HEXPREFIX));
|
||||
strcpy_truncate (str, OTP_HEXPREFIX, sz);
|
||||
otp_print_hex (key,
|
||||
str + strlen(OTP_HEXPREFIX),
|
||||
sz - strlen(OTP_HEXPREFIX));
|
||||
}
|
||||
|
||||
void
|
||||
otp_print_stddict_extended (OtpKey key, char *str, size_t sz)
|
||||
{
|
||||
strncpy (str, OTP_WORDPREFIX, sz);
|
||||
str[sz-1] = '\0';
|
||||
otp_print_stddict (key, str + strlen(OTP_WORDPREFIX), sz - strlen(OTP_WORDPREFIX));
|
||||
strcpy_truncate (str, OTP_WORDPREFIX, sz);
|
||||
otp_print_stddict (key,
|
||||
str + strlen(OTP_WORDPREFIX),
|
||||
sz - strlen(OTP_WORDPREFIX));
|
||||
}
|
||||
|
Reference in New Issue
Block a user