Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
Nodemcu Firmware
Commits
118acb80
Commit
118acb80
authored
Dec 24, 2016
by
kicer
Committed by
Philip Gladstone
Dec 23, 2016
Browse files
Fix crypto.mask() to encode with correct mask (#1677) (#1678)
Thank you.
parent
1452fbfd
Changes
1
Hide whitespace changes
Inline
Side-by-side
app/modules/crypto.c
View file @
118acb80
...
...
@@ -124,13 +124,19 @@ static int crypto_mask( lua_State* L )
int
len
,
mask_len
;
const
char
*
msg
=
luaL_checklstring
(
L
,
1
,
&
len
);
const
char
*
mask
=
luaL_checklstring
(
L
,
2
,
&
mask_len
);
if
(
mask_len
<=
0
)
return
luaL_error
(
L
,
"invalid argument: mask"
);
int
i
;
char
*
copy
=
(
char
*
)
c_malloc
(
len
);
for
(
i
=
0
;
i
<
len
;
i
++
)
{
copy
[
i
]
=
msg
[
i
]
^
mask
[
i
%
4
];
copy
[
i
]
=
msg
[
i
]
^
mask
[
i
%
mask_len
];
}
lua_pushlstring
(
L
,
copy
,
len
);
c_free
(
copy
);
return
1
;
}
...
...
Write
Preview
Markdown
is supported
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