diff options
author | Ken Raeburn <raeburn@mit.edu> | 2002-12-30 19:46:21 +0000 |
---|---|---|
committer | Ken Raeburn <raeburn@mit.edu> | 2002-12-30 19:46:21 +0000 |
commit | 4aa56f2b15e29b6f429c563c61e30771852b22f1 (patch) | |
tree | 1244f824edc238defa88dcbb7fdb2a2965dc6fc8 | |
parent | 6a5688b2335d46bb0e8cc70ce4604b41a9f6d8d8 (diff) | |
download | krb5-4aa56f2b15e29b6f429c563c61e30771852b22f1.zip krb5-4aa56f2b15e29b6f429c563c61e30771852b22f1.tar.gz krb5-4aa56f2b15e29b6f429c563c61e30771852b22f1.tar.bz2 |
* gss-misc.c (send_token, recv_token): Open-code the math to send and receive
the length as four bytes in network order, rather than using the first four
bytes of a size_t.
git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@15071 dc483132-0cff-0310-8789-dd5450dbe970
-rw-r--r-- | src/appl/gss-sample/ChangeLog | 6 | ||||
-rw-r--r-- | src/appl/gss-sample/gss-misc.c | 20 |
2 files changed, 21 insertions, 5 deletions
diff --git a/src/appl/gss-sample/ChangeLog b/src/appl/gss-sample/ChangeLog index eb8135f..08e8491 100644 --- a/src/appl/gss-sample/ChangeLog +++ b/src/appl/gss-sample/ChangeLog @@ -1,3 +1,9 @@ +2002-12-30 Ken Raeburn <raeburn@mit.edu> + + * gss-misc.c (send_token, recv_token): Open-code the math to send + and receive the length as four bytes in network order, rather than + using the first four bytes of a size_t. + 2002-08-29 Ken Raeburn <raeburn@mit.edu> * Makefile.in: Revert $(S)=>/ change, for Windows support. diff --git a/src/appl/gss-sample/gss-misc.c b/src/appl/gss-sample/gss-misc.c index a9417c2..9a2dd0b 100644 --- a/src/appl/gss-sample/gss-misc.c +++ b/src/appl/gss-sample/gss-misc.c @@ -122,6 +122,7 @@ int send_token(s, flags, tok) { int len, ret; unsigned char char_flags = (unsigned char) flags; + unsigned char lenbuf[4]; ret = write_all(s, (char *)&char_flags, 1); if (ret != 1) { @@ -129,9 +130,14 @@ int send_token(s, flags, tok) return -1; } - len = htonl(tok->length); + if (tok->length > 0xffffffffUL) + abort(); + lenbuf[0] = (tok->length >> 24) & 0xff; + lenbuf[1] = (tok->length >> 16) & 0xff; + lenbuf[2] = (tok->length >> 8) & 0xff; + lenbuf[3] = tok->length & 0xff; - ret = write_all(s, (char *) &len, 4); + ret = write_all(s, lenbuf, 4); if (ret < 0) { perror("sending token length"); return -1; @@ -188,6 +194,7 @@ int recv_token(s, flags, tok) { int ret; unsigned char char_flags; + unsigned char lenbuf[4]; ret = read_all(s, (char *) &char_flags, 1); if (ret < 0) { @@ -201,7 +208,7 @@ int recv_token(s, flags, tok) *flags = (int) char_flags; } - ret = read_all(s, (char *) &tok->length, 4); + ret = read_all(s, lenbuf, 4); if (ret < 0) { perror("reading token length"); return -1; @@ -212,8 +219,11 @@ int recv_token(s, flags, tok) ret, 4); return -1; } - - tok->length = ntohl(tok->length); + + tok->length = ((lenbuf[0] << 24) + | (lenbuf[1] << 16) + | (lenbuf[2] << 8) + | lenbuf[3]); tok->value = (char *) malloc(tok->length ? tok->length : 1); if (tok->length && tok->value == NULL) { if (display_file) |