From: Ken Raeburn Date: Sat, 2 Aug 2008 06:47:33 +0000 (+0000) Subject: Use load/store_32/16_be/le functions X-Git-Tag: krb5-1.7-alpha1~541 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=133712b8f054d5bd3e0ed903114ff1d6f3ab89b8;p=krb5.git Use load/store_32/16_be/le functions git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@20603 dc483132-0cff-0310-8789-dd5450dbe970 --- diff --git a/src/lib/krb5/krb/serialize.c b/src/lib/krb5/krb/serialize.c index d3f525812..fc20fb192 100644 --- a/src/lib/krb5/krb/serialize.c +++ b/src/lib/krb5/krb/serialize.c @@ -181,10 +181,7 @@ krb5_error_code KRB5_CALLCONV krb5_ser_pack_int32(krb5_int32 iarg, krb5_octet **bufp, size_t *remainp) { if (*remainp >= sizeof(krb5_int32)) { - (*bufp)[0] = (krb5_octet) ((iarg >> 24) & 0xff); - (*bufp)[1] = (krb5_octet) ((iarg >> 16) & 0xff); - (*bufp)[2] = (krb5_octet) ((iarg >> 8) & 0xff); - (*bufp)[3] = (krb5_octet) (iarg & 0xff); + store_32_be(iarg, *bufp); *bufp += sizeof(krb5_int32); *remainp -= sizeof(krb5_int32); return(0); @@ -233,10 +230,7 @@ krb5_error_code KRB5_CALLCONV krb5_ser_unpack_int32(krb5_int32 *intp, krb5_octet **bufp, size_t *remainp) { if (*remainp >= sizeof(krb5_int32)) { - *intp = (((krb5_int32) ((unsigned char) (*bufp)[0]) << 24) | - ((krb5_int32) ((unsigned char) (*bufp)[1]) << 16) | - ((krb5_int32) ((unsigned char) (*bufp)[2]) << 8) | - ((krb5_int32) ((unsigned char) (*bufp)[3]))); + *intp = load_32_be(*bufp); *bufp += sizeof(krb5_int32); *remainp -= sizeof(krb5_int32); return(0); diff --git a/src/lib/krb5/os/mk_faddr.c b/src/lib/krb5/os/mk_faddr.c index 2184f7220..cd243c022 100644 --- a/src/lib/krb5/os/mk_faddr.c +++ b/src/lib/krb5/os/mk_faddr.c @@ -61,10 +61,8 @@ krb5_make_fulladdr(krb5_context context, krb5_address *kaddr, krb5_address *kpor *marshal++ = (krb5_octet) ((tmp16 >> 8) & 0xff); tmp32 = kaddr->length; - *marshal++ = (krb5_octet) (tmp32 & 0xff); - *marshal++ = (krb5_octet) ((tmp32 >> 8) & 0xff); - *marshal++ = (krb5_octet) ((tmp32 >> 16) & 0xff); - *marshal++ = (krb5_octet) ((tmp32 >> 24) & 0xff); + store_32_le(tmp32, marshal); + marshal += 4; (void) memcpy((char *)marshal, (char *)(kaddr->contents), kaddr->length); marshal += kaddr->length; @@ -72,14 +70,12 @@ krb5_make_fulladdr(krb5_context context, krb5_address *kaddr, krb5_address *kpor tmp16 = kport->addrtype; *marshal++ = 0x00; *marshal++ = 0x00; - *marshal++ = (krb5_octet) (tmp16 & 0xff); - *marshal++ = (krb5_octet) ((tmp16 >> 8) & 0xff); + store_16_le(tmp16, marshal); + marshal += 2; tmp32 = kport->length; - *marshal++ = (krb5_octet) (tmp32 & 0xff); - *marshal++ = (krb5_octet) ((tmp32 >> 8) & 0xff); - *marshal++ = (krb5_octet) ((tmp32 >> 16) & 0xff); - *marshal++ = (krb5_octet) ((tmp32 >> 24) & 0xff); + store_32_le(tmp32, marshal); + marshal += 4; (void) memcpy((char *)marshal, (char *)(kport->contents), kport->length); marshal += kport->length; diff --git a/src/lib/krb5/os/sendto_kdc.c b/src/lib/krb5/os/sendto_kdc.c index 2063b302f..48937fd99 100644 --- a/src/lib/krb5/os/sendto_kdc.c +++ b/src/lib/krb5/os/sendto_kdc.c @@ -587,11 +587,7 @@ set_conn_state_msg_length (struct conn_state *state, const krb5_data *message) if (!state->is_udp) { - state->x.out.msg_len_buf[0] = (message->length >> 24) & 0xff; - state->x.out.msg_len_buf[1] = (message->length >> 16) & 0xff; - state->x.out.msg_len_buf[2] = (message->length >> 8) & 0xff; - state->x.out.msg_len_buf[3] = message->length & 0xff; - + store_32_be(message->length, state->x.out.msg_len_buf); SG_SET(&state->x.out.sgbuf[0], state->x.out.msg_len_buf, 4); SG_SET(&state->x.out.sgbuf[1], message->data, message->length); state->x.out.sg_count = 2;