Serialize new time offset fields in the os_context
authorPaul Park <pjpark@mit.edu>
Fri, 1 Sep 1995 15:18:02 +0000 (15:18 +0000)
committerPaul Park <pjpark@mit.edu>
Fri, 1 Sep 1995 15:18:02 +0000 (15:18 +0000)
git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@6649 dc483132-0cff-0310-8789-dd5450dbe970

src/lib/krb5/krb/ChangeLog
src/lib/krb5/krb/ser_ctx.c

index b65b024c62dbd454fc6d056077a146cb337da1dd..751962b1ffaf333b196cfe36c23c1d417520e944 100644 (file)
@@ -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
index f317a519d34fee30aad676865002d9b79ea2a07b..d1c296be45f56d5163bec68fbb44831e402358b5 100644 (file)
@@ -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);
 }
 \f
@@ -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);
 }
 \f