From 9aff2eeb938757d5aa04716a842270ccb1c45f31 Mon Sep 17 00:00:00 2001 From: Assar Westerlund Date: Wed, 19 Feb 1997 14:23:35 +0000 Subject: [PATCH] fix for signed char overflow. git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@1246 ec53bebd-3082-4978-b11e-865c3cabbd6b --- lib/otp/otp_db.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/lib/otp/otp_db.c b/lib/otp/otp_db.c index 65cd7fc0e..7ab673ade 100644 --- a/lib/otp/otp_db.c +++ b/lib/otp/otp_db.c @@ -135,7 +135,10 @@ otp_get_internal (void *v, OtpContext *ctx, int lockp) return -1; } p += strlen(p) + 1; - ctx->n = (p[0] << 24) | (p[1] << 16) | (p[2] << 8) | p[3]; + { + unsigned char *up = (unsigned char *)p; + ctx->n = (up[0] << 24) | (up[1] << 16) | (up[2] << 8) | up[3]; + } p += 4; memcpy (ctx->key, p, OTPKEYSIZE); p += OTPKEYSIZE; @@ -187,10 +190,14 @@ otp_put (void *v, OtpContext *ctx) p += sizeof(zero); strcpy (p, ctx->alg->name); p += strlen(p) + 1; - *p++ = (ctx->n >> 24) & 0xFF; - *p++ = (ctx->n >> 16) & 0xFF; - *p++ = (ctx->n >> 8) & 0xFF; - *p++ = (ctx->n >> 0) & 0xFF; + { + unsigned char *up = (unsigned char *)p; + *up++ = (ctx->n >> 24) & 0xFF; + *up++ = (ctx->n >> 16) & 0xFF; + *up++ = (ctx->n >> 8) & 0xFF; + *up++ = (ctx->n >> 0) & 0xFF; + } + p += 4; memcpy (p, ctx->key, OTPKEYSIZE); p += OTPKEYSIZE; strcpy (p, ctx->seed);