summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlon Levy <alevy@redhat.com>2011-07-20 16:36:36 +0300
committerChristophe Fergeau <cfergeau@redhat.com>2011-09-20 16:08:30 +0200
commit506f03568297298eb7da1d904526bab373cceaca (patch)
tree832078e19f0b5b1a4d7d351e04081868f3cbd81a
parent11fe46f1390adbaa67d83e4ec9cc20913b6519b3 (diff)
downloadspice-506f03568297298eb7da1d904526bab373cceaca.tar.gz
spice-506f03568297298eb7da1d904526bab373cceaca.tar.xz
spice-506f03568297298eb7da1d904526bab373cceaca.zip
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.c30
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);
}