Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Michal Zima
coincer
Commits
9549573d
Commit
9549573d
authored
Jan 11, 2019
by
xpetrak2
Browse files
Basic trade script originator selection made safe
parent
9f93adfd
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/trade_basic.c
View file @
9549573d
...
...
@@ -336,14 +336,13 @@ static int trade_script_generate(trade_t *trade, global_state_t *global_state)
static
int
trade_script_originator
(
const
trade_t
*
trade
)
{
char
cp_committed_hex
[
COMMITTED_HEX_LEN
+
1
];
unsigned
char
cp_hash
[
SHA3_256_SIZE
];
unsigned
char
cp_buff
[
ORDER_ID_HEX_LEN
+
COMMITTED_HEX_LEN
];
char
my_committed_hex
[
COMMITTED_HEX_LEN
+
1
];
char
order_id_hex
[
ORDER_ID_HEX_LEN
+
1
];
unsigned
char
cp_hash
[
SHA3_256_SIZE
];
unsigned
char
my_hash
[
SHA3_256_SIZE
];
unsigned
char
my_buff
[
ORDER_ID_HEX_LEN
+
COMMITTED_HEX_LEN
];
char
order_id_hex
[
ORDER_ID_HEX_LEN
+
1
];
unsigned
char
buf
[
ORDER_ID_HEX_LEN
+
2
*
COMMITTED_HEX_LEN
];
trade_basic_t
*
data
=
(
trade_basic_t
*
)
trade
->
data
;
...
...
@@ -361,19 +360,25 @@ static int trade_script_originator(const trade_t *trade)
data
->
my_committed
,
TRADE_BASIC_COMMITTED_SIZE
);
memcpy
(
cp_
buf
f
,
order_id_hex
,
ORDER_ID_HEX_LEN
);
memcpy
(
cp_
buf
f
+
ORDER_ID_HEX_LEN
,
memcpy
(
buf
,
order_id_hex
,
ORDER_ID_HEX_LEN
);
memcpy
(
buf
+
ORDER_ID_HEX_LEN
,
cp_committed_hex
,
TRADE_BASIC_COMMITTED_SIZE
);
COMMITTED_HEX_LEN
);
memcpy
(
buf
+
ORDER_ID_HEX_LEN
+
COMMITTED_HEX_LEN
,
my_committed_hex
,
COMMITTED_HEX_LEN
);
hash_message
(
HT_SHA3_256
,
cp_
buf
f
,
sizeof
(
cp_
buf
f
),
cp_hash
);
hash_message
(
HT_SHA3_256
,
buf
,
sizeof
(
buf
),
cp_hash
);
memcpy
(
my_
buf
f
,
order_id_hex
,
ORDER_ID_HEX_LEN
);
memcpy
(
my_
buf
f
+
ORDER_ID_HEX_LEN
,
memcpy
(
buf
,
order_id_hex
,
ORDER_ID_HEX_LEN
);
memcpy
(
buf
+
ORDER_ID_HEX_LEN
,
my_committed_hex
,
TRADE_BASIC_COMMITTED_SIZE
);
COMMITTED_HEX_LEN
);
memcpy
(
buf
+
ORDER_ID_HEX_LEN
+
COMMITTED_HEX_LEN
,
cp_committed_hex
,
COMMITTED_HEX_LEN
);
hash_message
(
HT_SHA3_256
,
my_
buf
f
,
sizeof
(
my_
buf
f
),
my_hash
);
hash_message
(
HT_SHA3_256
,
buf
,
sizeof
(
buf
),
my_hash
);
return
memcmp
(
my_hash
,
cp_hash
,
SHA3_256_SIZE
)
>
0
;
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment