Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Matt Johnston
dropbear
Commits
c0f63ee1
Commit
c0f63ee1
authored
Jul 11, 2016
by
Matt Johnston
Browse files
additional length checks
parent
8fd720c3
Changes
1
Show whitespace changes
Inline
Side-by-side
buffer.c
View file @
c0f63ee1
...
...
@@ -141,8 +141,9 @@ void buf_incrwritepos(buffer* buf, unsigned int incr) {
/* increment the position by incr, negative values are allowed, to
* decrement the pos*/
void
buf_incrpos
(
buffer
*
buf
,
int
incr
)
{
if
(
incr
>
BUF_MAX_INCR
||
(
unsigned
int
)((
int
)
buf
->
pos
+
incr
)
>
buf
->
len
if
(
incr
>
BUF_MAX_INCR
||
incr
<
-
BUF_MAX_INCR
||
(
unsigned
int
)((
int
)
buf
->
pos
+
incr
)
>
buf
->
len
||
((
int
)
buf
->
pos
+
incr
)
<
0
)
{
dropbear_exit
(
"Bad buf_incrpos"
);
}
...
...
@@ -184,7 +185,7 @@ void buf_putbyte(buffer* buf, unsigned char val) {
* the next len bytes from that position can be used */
unsigned
char
*
buf_getptr
(
buffer
*
buf
,
unsigned
int
len
)
{
if
(
buf
->
pos
+
len
>
buf
->
len
)
{
if
(
len
>
BUF_MAX_INCR
||
buf
->
pos
+
len
>
buf
->
len
)
{
dropbear_exit
(
"Bad buf_getptr"
);
}
return
&
buf
->
data
[
buf
->
pos
];
...
...
@@ -194,7 +195,7 @@ unsigned char* buf_getptr(buffer* buf, unsigned int len) {
* This allows writing past the used length, but not past the size */
unsigned
char
*
buf_getwriteptr
(
buffer
*
buf
,
unsigned
int
len
)
{
if
(
buf
->
pos
+
len
>
buf
->
size
)
{
if
(
len
>
BUF_MAX_INCR
||
buf
->
pos
+
len
>
buf
->
size
)
{
dropbear_exit
(
"Bad buf_getwriteptr"
);
}
return
&
buf
->
data
[
buf
->
pos
];
...
...
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