* kt_file.c (krb5_ktf_keytab_externalize, krb5_ktf_keytab_internalize): Read
authorKen Raeburn <raeburn@mit.edu>
Fri, 31 Mar 2006 20:08:46 +0000 (20:08 +0000)
committerKen Raeburn <raeburn@mit.edu>
Fri, 31 Mar 2006 20:08:46 +0000 (20:08 +0000)
and write file position as 64 bits rather than trying to figure out size of
long.

git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@17817 dc483132-0cff-0310-8789-dd5450dbe970

src/lib/krb5/keytab/ChangeLog
src/lib/krb5/keytab/kt_file.c

index 943aad139bb29304184d057c51cf05af890e2bea..0dcd340249692f1116b61a7d5e1658f2283d72bc 100644 (file)
@@ -1,3 +1,9 @@
+2006-03-31  Ken Raeburn  <raeburn@mit.edu>
+
+       * kt_file.c (krb5_ktf_keytab_externalize,
+       krb5_ktf_keytab_internalize): Read and write file position as 64
+       bits rather than trying to figure out size of long.
+
 2005-04-13  Ken Raeburn  <raeburn@mit.edu>
 
        * kt_file.c (NEED_SOCKETS): Don't define.
index c53c2b64454a425e83b09a89fd0158ed63adb1d3..c0358bfcbb01f97106251b0811e93a8b00a6c452 100644 (file)
@@ -577,7 +577,7 @@ krb5_ktf_keytab_externalize(krb5_context kcontext, krb5_pointer arg, krb5_octet
     size_t             remain;
     krb5_ktfile_data   *ktdata;
     krb5_int32         file_is_open;
-    krb5_int32         file_pos[2];
+    krb5_int64         file_pos;
     char               *ktname;
     size_t             namelen;
     const char         *fnamep;
@@ -595,8 +595,7 @@ krb5_ktf_keytab_externalize(krb5_context kcontext, krb5_pointer arg, krb5_octet
 
            ktdata = (krb5_ktfile_data *) keytab->data;
            file_is_open = 0;
-           file_pos[0] = 0;
-           file_pos[1] = 0;
+           file_pos = 0;
 
            /* Calculate the length of the name */
            namelen = (keytab->ops && keytab->ops->prefix) ?
@@ -630,12 +629,7 @@ krb5_ktf_keytab_externalize(krb5_context kcontext, krb5_pointer arg, krb5_octet
                        file_is_open = 0;
 #endif
                        fpos = ftell(ktdata->openf);
-#if    SIZEOF_LONG == 4
-                       file_pos[0] = fpos;
-#else  /* SIZEOF_LONG == 4 */
-                       file_pos[0] = fpos & 0xffffffff;
-                       file_pos[1] = (fpos >> 32) & 0xffffffff;
-#endif /* SIZEOF_LONG == 4 */
+                       file_pos = fpos; /* XX range check? */
                    }
                }
 
@@ -652,8 +646,7 @@ krb5_ktf_keytab_externalize(krb5_context kcontext, krb5_pointer arg, krb5_octet
                (void) krb5_ser_pack_int32(file_is_open, &bp, &remain);
 
                /* Put the file position */
-               (void) krb5_ser_pack_int32(file_pos[0], &bp, &remain);
-               (void) krb5_ser_pack_int32(file_pos[1], &bp, &remain);
+               (void) krb5_ser_pack_int64(file_pos, &bp, &remain);
 
                /* Put the version */
                (void) krb5_ser_pack_int32((krb5_int32) ((ktdata) ?
@@ -686,7 +679,7 @@ krb5_ktf_keytab_internalize(krb5_context kcontext, krb5_pointer *argp, krb5_octe
     char               *ktname;
     krb5_ktfile_data   *ktdata;
     krb5_int32         file_is_open;
-    krb5_int32         foffbuf[2];
+    krb5_int64         foff;
 
     bp = *buffer;
     remain = *lenremain;
@@ -724,10 +717,7 @@ krb5_ktf_keytab_internalize(krb5_context kcontext, krb5_pointer *argp, krb5_octe
                    if (remain >= (sizeof(krb5_int32)*5)) {
                        (void) krb5_ser_unpack_int32(&file_is_open,
                                                     &bp, &remain);
-                       (void) krb5_ser_unpack_int32(&foffbuf[0],
-                                                    &bp, &remain);
-                       (void) krb5_ser_unpack_int32(&foffbuf[1],
-                                                    &bp, &remain);
+                       (void) krb5_ser_unpack_int64(&foff, &bp, &remain);
                        (void) krb5_ser_unpack_int32(&ibuf, &bp, &remain);
                        ktdata->version = (int) ibuf;
 
@@ -749,11 +739,7 @@ krb5_ktf_keytab_internalize(krb5_context kcontext, krb5_pointer *argp, krb5_octe
                                    kret = krb5_ktfileint_openr(kcontext,
                                                                keytab);
                                if (!kret) {
-#if    SIZEOF_LONG == 4
-                                   fpos = foffbuf[0];
-#else  /* SIZEOF_LONG == 4 */
-                                   fpos = foffbuf[0] | ((long) foffbuf[1] << 32);
-#endif /* SIZEOF_LONG == 4 */
+                                   fpos = foff; /* XX range check? */
                                    fseek(KTFILEP(keytab), fpos, SEEK_SET);
                                }
                            }