summaryrefslogtreecommitdiffstats
path: root/source/libsmb/smb_signing.c
diff options
context:
space:
mode:
authorVolker Lendecke <vl@samba.org>2008-05-13 15:19:46 +0200
committerVolker Lendecke <vl@samba.org>2008-05-13 16:29:47 +0200
commite402e6508ca0806deef4c4044cfa6461b682850a (patch)
tree6abcfd055fa925dac05342bdfa197d6e4a98eab5 /source/libsmb/smb_signing.c
parent443691eb2614919043406f94e9c71b49230612d5 (diff)
downloadsamba-e402e6508ca0806deef4c4044cfa6461b682850a.tar.gz
samba-e402e6508ca0806deef4c4044cfa6461b682850a.tar.xz
samba-e402e6508ca0806deef4c4044cfa6461b682850a.zip
Revert "Fix signing bug found by Volker. That one was *subtle*."
This reverts commit 816aea6c1a426eb2450061b847729e22bdac33a0.
Diffstat (limited to 'source/libsmb/smb_signing.c')
-rw-r--r--source/libsmb/smb_signing.c79
1 files changed, 74 insertions, 5 deletions
diff --git a/source/libsmb/smb_signing.c b/source/libsmb/smb_signing.c
index bd6d97123d6..ea1eb05cfb1 100644
--- a/source/libsmb/smb_signing.c
+++ b/source/libsmb/smb_signing.c
@@ -25,6 +25,7 @@ struct outstanding_packet_lookup {
struct outstanding_packet_lookup *prev, *next;
uint16 mid;
uint32 reply_seq_num;
+ bool can_delete; /* Set to False in trans state. */
};
struct smb_basic_signing_context {
@@ -41,9 +42,7 @@ static bool store_sequence_for_reply(struct outstanding_packet_lookup **list,
/* Ensure we only add a mid once. */
for (t = *list; t; t = t->next) {
if (t->mid == mid) {
- DLIST_REMOVE(*list, t);
- SAFE_FREE(t);
- break;
+ return False;
}
}
@@ -52,6 +51,7 @@ static bool store_sequence_for_reply(struct outstanding_packet_lookup **list,
t->mid = mid;
t->reply_seq_num = reply_seq_num;
+ t->can_delete = True;
/*
* Add to the *start* of the list not the end of the list.
@@ -78,8 +78,23 @@ static bool get_sequence_for_reply(struct outstanding_packet_lookup **list,
*reply_seq_num = t->reply_seq_num;
DEBUG(10,("get_sequence_for_reply: found seq = %u mid = %u\n",
(unsigned int)t->reply_seq_num, (unsigned int)t->mid ));
- DLIST_REMOVE(*list, t);
- SAFE_FREE(t);
+ if (t->can_delete) {
+ DLIST_REMOVE(*list, t);
+ SAFE_FREE(t);
+ }
+ return True;
+ }
+ }
+ return False;
+}
+
+static bool set_sequence_can_delete_flag(struct outstanding_packet_lookup **list, uint16 mid, bool can_delete_entry)
+{
+ struct outstanding_packet_lookup *t;
+
+ for (t = *list; t; t = t->next) {
+ if (t->mid == mid) {
+ t->can_delete = can_delete_entry;
return True;
}
}
@@ -594,6 +609,60 @@ bool cli_check_sign_mac(struct cli_state *cli, char *buf)
}
/***********************************************************
+ Enter trans/trans2/nttrans state.
+************************************************************/
+
+bool client_set_trans_sign_state_on(struct cli_state *cli, uint16 mid)
+{
+ struct smb_sign_info *si = &cli->sign_info;
+ struct smb_basic_signing_context *data = (struct smb_basic_signing_context *)si->signing_context;
+
+ if (!si->doing_signing) {
+ return True;
+ }
+
+ if (!data) {
+ return False;
+ }
+
+ if (!set_sequence_can_delete_flag(&data->outstanding_packet_list, mid, False)) {
+ return False;
+ }
+
+ return True;
+}
+
+/***********************************************************
+ Leave trans/trans2/nttrans state.
+************************************************************/
+
+bool client_set_trans_sign_state_off(struct cli_state *cli, uint16 mid)
+{
+ uint32 reply_seq_num;
+ struct smb_sign_info *si = &cli->sign_info;
+ struct smb_basic_signing_context *data = (struct smb_basic_signing_context *)si->signing_context;
+
+ if (!si->doing_signing) {
+ return True;
+ }
+
+ if (!data) {
+ return False;
+ }
+
+ if (!set_sequence_can_delete_flag(&data->outstanding_packet_list, mid, True)) {
+ return False;
+ }
+
+ /* Now delete the stored mid entry. */
+ if (!get_sequence_for_reply(&data->outstanding_packet_list, mid, &reply_seq_num)) {
+ return False;
+ }
+
+ return True;
+}
+
+/***********************************************************
Is client signing on ?
************************************************************/