diff options
author | Alon Levy <alevy@redhat.com> | 2011-07-20 16:36:36 +0300 |
---|---|---|
committer | Christophe Fergeau <cfergeau@redhat.com> | 2011-08-17 12:05:16 +0200 |
commit | e5d3408239e21848ddf4797b30ad2af576a1f78f (patch) | |
tree | 705822f24e2d20fed4e00285fa603ecbe742bbf0 | |
parent | 6862c810f311ecc5c6cc945cb8c0104415aac765 (diff) |
server/smartcard: fix smartcard_channel_send_error
It was sending the wrong data, the memory right after the VCSMsgHeader
which was actually not where the data was.
Fixed by having the header and data (VSCError, 4 bytes of the error code)
embedded in the ErrorItem pipe item.
-rw-r--r-- | server/smartcard.c | 30 |
1 files changed, 7 insertions, 23 deletions
diff --git a/server/smartcard.c b/server/smartcard.c index c75094d6..89194003 100644 --- a/server/smartcard.c +++ b/server/smartcard.c @@ -41,8 +41,8 @@ enum { typedef struct ErrorItem { PipeItem base; - uint32_t reader_id; - uint32_t error; + VSCMsgHeader vheader; + VSCMsgError error; } ErrorItem; typedef struct MsgItem { @@ -288,23 +288,6 @@ static void smartcard_channel_send_data(RedChannel *channel, PipeItem *item, VSC red_channel_begin_send_message(channel); } -static void smartcard_channel_send_message(RedChannel *channel, PipeItem *item, - uint32_t reader_id, VSCMsgType type, uint8_t* data, uint32_t len) -{ - VSCMsgHeader mhHeader; - //SpiceMarshaller* m = msg->marshaller(); - - mhHeader.type = type; - mhHeader.length = len; - mhHeader.reader_id = reader_id; - //_marshallers->msg_SpiceMsgData(m, &msgdata); - //spice_marshaller_add(m, (uint8_t*)&mhHeader, sizeof(mhHeader)); - //spice_marshaller_add(m, data, len); - //marshaller_outgoing_write(msg); - - smartcard_channel_send_data(channel, item, &mhHeader); -} - static void smartcard_channel_send_error( SmartCardChannel *smartcard_channel, PipeItem *item) { @@ -312,8 +295,7 @@ static void smartcard_channel_send_error( VSCMsgError error; error.code = error_item->error; - smartcard_channel_send_message(&smartcard_channel->base, item, error_item->reader_id, - VSC_Error, (uint8_t*)&error, sizeof(error)); + smartcard_channel_send_data(&smartcard_channel->base, item, &error_item->vheader); } static void smartcard_channel_send_msg( @@ -367,8 +349,10 @@ static void smartcard_push_error(SmartCardChannel* channel, uint32_t reader_id, ErrorItem *error_item = spice_new0(ErrorItem, 1); error_item->base.type = PIPE_ITEM_TYPE_ERROR; - error_item->reader_id = reader_id; - error_item->error = error; + error_item->vheader.reader_id = reader_id; + error_item->vheader.type = VSC_Error; + error_item->vheader.length = sizeof(error_item->error); + error_item->error.code = error; smartcard_channel_pipe_add(channel, &error_item->base); } |