diff options
author | Alan Coopersmith <alan.coopersmith@oracle.com> | 2012-07-14 22:35:18 -0700 |
---|---|---|
committer | Alan Coopersmith <alan.coopersmith@oracle.com> | 2012-10-02 22:14:45 -0700 |
commit | e1e857744290f0a09d60435e8d5997efb0a436ba (patch) | |
tree | e33c8d9a38465d9bff4693f1d2c9bbe9c58b6f69 /x11.h | |
parent | 4ba266b7b08cf5914b5ec6912763d319f57f00bc (diff) | |
download | xscope-e1e857744290f0a09d60435e8d5997efb0a436ba.tar.gz |
Handle big-requests when calculating request contents from length field
Adds a getreqlen inline function to handle the big requests check.
As noted in the comment, it must be called *before* the printreqlen
macro does its own check, since printreqlen "fixes" the buf pointer
when it's done to align all the remaining fields with their correct
positions after skipping over the extra big requests 32-bit length
field after the normal 16-bit length field.
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Diffstat (limited to 'x11.h')
-rw-r--r-- | x11.h | 14 |
1 files changed, 14 insertions, 0 deletions
@@ -629,6 +629,20 @@ extern const char *REQUESTHEADER, *EVENTHEADER, *ERRORHEADER, *REPLYHEADER; #define GC_dashes 0x00200000L #define GC_arc_mode 0x00400000L +/* must be called BEFORE printreqlen increments buf */ +static inline +uint32_t getreqlen(FD fd, const unsigned char *buf) { + uint32_t reqlen = IShort(&buf[2]); + + /* Check for big request */ + if (reqlen == 0 && CS[(fd)].bigreqEnabled) + reqlen = ILong(&buf[4]); + + return reqlen; +} + +/* prints request length, and if the request is a big request, adjusts + the buf pointer to skip over the extra large size field */ #define printreqlen(buf, fd, dvalue) \ do { \ if (IShort(&(buf)[2]) == 0 && CS[(fd)].bigreqEnabled) { \ |