sunrpc: make token header values less confusing
authorKevin Coffman <kwc@citi.umich.edu>
Mon, 31 Mar 2008 14:31:44 +0000 (10:31 -0400)
committerJ. Bruce Fields <bfields@citi.umich.edu>
Wed, 23 Apr 2008 20:13:41 +0000 (16:13 -0400)
g_make_token_header() and g_token_size() add two too many, and
therefore their callers pass in "(logical_value - 2)" rather
than "logical_value" as hard-coded values which causes confusion.

This dates back to the original g_make_token_header which took an
optional token type (token_id) value and added it to the token.
This was removed, but the routine always adds room for the token_id
rather than not.

Signed-off-by: Kevin Coffman <kwc@citi.umich.edu>
Signed-off-by: J. Bruce Fields <bfields@citi.umich.edu>
net/sunrpc/auth_gss/gss_generic_token.c
net/sunrpc/auth_gss/gss_krb5_seal.c
net/sunrpc/auth_gss/gss_krb5_wrap.c
net/sunrpc/auth_gss/gss_spkm3_seal.c

index ea8c92e..d83b881 100644 (file)
@@ -148,7 +148,7 @@ int
 g_token_size(struct xdr_netobj *mech, unsigned int body_size)
 {
        /* set body_size to sequence contents size */
-       body_size += 4 + (int) mech->len;         /* NEED overflow check */
+       body_size += 2 + (int) mech->len;         /* NEED overflow check */
        return(1 + der_length_size(body_size) + body_size);
 }
 
@@ -161,7 +161,7 @@ void
 g_make_token_header(struct xdr_netobj *mech, int body_size, unsigned char **buf)
 {
        *(*buf)++ = 0x60;
-       der_write_length(buf, 4 + mech->len + body_size);
+       der_write_length(buf, 2 + mech->len + body_size);
        *(*buf)++ = 0x06;
        *(*buf)++ = (unsigned char) mech->len;
        TWRITE_STR(*buf, mech->data, ((int) mech->len));
index 8e3c87d..5f1d36d 100644 (file)
@@ -87,10 +87,10 @@ gss_get_mic_kerberos(struct gss_ctx *gss_ctx, struct xdr_buf *text,
 
        now = get_seconds();
 
-       token->len = g_token_size(&ctx->mech_used, 22);
+       token->len = g_token_size(&ctx->mech_used, 24);
 
        ptr = token->data;
-       g_make_token_header(&ctx->mech_used, 22, &ptr);
+       g_make_token_header(&ctx->mech_used, 24, &ptr);
 
        *ptr++ = (unsigned char) ((KG_TOK_MIC_MSG>>8)&0xff);
        *ptr++ = (unsigned char) (KG_TOK_MIC_MSG&0xff);
index 3cd99a7..b00b1b4 100644 (file)
@@ -137,7 +137,7 @@ gss_wrap_kerberos(struct gss_ctx *ctx, int offset,
        BUG_ON((buf->len - offset) % blocksize);
        plainlen = blocksize + buf->len - offset;
 
-       headlen = g_token_size(&kctx->mech_used, 22 + plainlen) -
+       headlen = g_token_size(&kctx->mech_used, 24 + plainlen) -
                                                (buf->len - offset);
 
        ptr = buf->head[0].iov_base + offset;
@@ -149,7 +149,7 @@ gss_wrap_kerberos(struct gss_ctx *ctx, int offset,
        buf->len += headlen;
        BUG_ON((buf->len - offset - headlen) % blocksize);
 
-       g_make_token_header(&kctx->mech_used, 22 + plainlen, &ptr);
+       g_make_token_header(&kctx->mech_used, 24 + plainlen, &ptr);
 
 
        *ptr++ = (unsigned char) ((KG_TOK_WRAP_MSG>>8)&0xff);
index abf17ce..c832712 100644 (file)
@@ -107,10 +107,10 @@ spkm3_make_token(struct spkm3_ctx *ctx,
                tokenlen = 10 + ctxelen + 1 + md5elen + 1;
 
                /* Create token header using generic routines */
-               token->len = g_token_size(&ctx->mech_used, tokenlen);
+               token->len = g_token_size(&ctx->mech_used, tokenlen + 2);
 
                ptr = token->data;
-               g_make_token_header(&ctx->mech_used, tokenlen, &ptr);
+               g_make_token_header(&ctx->mech_used, tokenlen + 2, &ptr);
 
                spkm3_make_mic_token(&ptr, tokenlen, &mic_hdr, &md5cksum, md5elen, md5zbit);
        } else if (toktype == SPKM_WRAP_TOK) { /* Not Supported */