From: Paul Park Date: Fri, 1 Sep 1995 15:18:02 +0000 (+0000) Subject: Serialize new time offset fields in the os_context X-Git-Tag: krb5-1.0-beta6~1207 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=7187f6c65cc651904cf60f9bfc61d826c39423c7;p=krb5.git Serialize new time offset fields in the os_context git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@6649 dc483132-0cff-0310-8789-dd5450dbe970 --- diff --git a/src/lib/krb5/krb/ChangeLog b/src/lib/krb5/krb/ChangeLog index b65b024c6..751962b1f 100644 --- a/src/lib/krb5/krb/ChangeLog +++ b/src/lib/krb5/krb/ChangeLog @@ -1,4 +1,8 @@ +Fri Sep 1 11:16:43 EDT 1995 Paul Park (pjpark@mit.edu) + * ser_ctx.c - Add handling of new time offset fields in the os_context. + + Tue Aug 29 14:14:26 EDT 1995 Paul Park (pjpark@mit.edu) * Makefile.in, .Sanitize, ser_{actx,adata,addr,auth,cksum,ctx,eblk,key, princ}.c, serialize.c, t_ser.c - Add serialization operations diff --git a/src/lib/krb5/krb/ser_ctx.c b/src/lib/krb5/krb/ser_ctx.c index f317a519d..d1c296be4 100644 --- a/src/lib/krb5/krb/ser_ctx.c +++ b/src/lib/krb5/krb/ser_ctx.c @@ -367,7 +367,12 @@ krb5_oscontext_size(kcontext, arg, sizep) krb5_pointer arg; size_t *sizep; { - *sizep += sizeof(krb5_int32); + /* + * We need five 32-bit integers: + * two for header and trailer + * one each for time_offset, usec_offset and os_flags + */ + *sizep += (5*sizeof(krb5_int32)); return(0); } @@ -396,6 +401,10 @@ krb5_oscontext_externalize(kcontext, arg, buffer, lenremain) if (!krb5_oscontext_size(kcontext, arg, &required) && (required <= remain)) { (void) krb5_ser_pack_int32(KV5M_OS_CONTEXT, &bp, &remain); + (void) krb5_ser_pack_int32(os_ctx->time_offset, &bp, &remain); + (void) krb5_ser_pack_int32(os_ctx->usec_offset, &bp, &remain); + (void) krb5_ser_pack_int32(os_ctx->os_flags, &bp, &remain); + (void) krb5_ser_pack_int32(KV5M_OS_CONTEXT, &bp, &remain); /* Handle any other OS context here */ kret = 0; @@ -427,6 +436,7 @@ krb5_oscontext_internalize(kcontext, argp, buffer, lenremain) bp = *buffer; remain = *lenremain; kret = EINVAL; + os_ctx = (krb5_os_context) NULL; /* Read our magic number */ if (krb5_ser_unpack_int32(&ibuf, &bp, &remain)) ibuf = 0; @@ -435,19 +445,33 @@ krb5_oscontext_internalize(kcontext, argp, buffer, lenremain) /* Get memory for the context */ if ((os_ctx = (krb5_os_context) - malloc(sizeof(struct _krb5_os_context)))) { + malloc(sizeof(struct _krb5_os_context))) && + (remain >= 4*sizeof(krb5_int32))) { memset(os_ctx, 0, sizeof(struct _krb5_os_context)); - os_ctx->magic = KV5M_OS_CONTEXT; - /* Handle any more OS context here */ + /* Read out our context */ + (void) krb5_ser_unpack_int32(&os_ctx->time_offset, &bp, &remain); + (void) krb5_ser_unpack_int32(&os_ctx->usec_offset, &bp, &remain); + (void) krb5_ser_unpack_int32(&os_ctx->os_flags, &bp, &remain); + (void) krb5_ser_unpack_int32(&ibuf, &bp, &remain); - kret = 0; - *buffer = bp; - *lenremain = remain; + if (ibuf == KV5M_OS_CONTEXT) { + os_ctx->magic = KV5M_OS_CONTEXT; + kret = 0; + *buffer = bp; + *lenremain = remain; + } + else + kret = EINVAL; } } - if (!kret) + if (!kret) { *argp = (krb5_pointer) os_ctx; + } + else { + if (os_ctx) + free(os_ctx); + } return(kret); }