Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
L
libnice
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
cpp-libs
libnice
Commits
4f6e3fff
Commit
4f6e3fff
authored
Nov 15, 2007
by
Kai Vehmanen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove broken UTF8 validation.
darcs-hash:20071115165409-77cd4-1534f47241d0f3f016a52ce07906b9bc0d48a1b0.gz
parent
6198b3cd
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
73 deletions
+5
-73
stun/stunrecv.c
stun/stunrecv.c
+5
-73
No files found.
stun/stunrecv.c
View file @
4f6e3fff
...
...
@@ -219,7 +219,7 @@ int stun_find64 (const uint8_t *msg, stun_attr_type_t type, uint64_t *pval)
int
stun_find_string
(
const
uint8_t
*
restrict
msg
,
stun_attr_type_t
type
,
char
*
buf
,
size_t
maxcp
)
char
*
buf
,
size_t
buflen
)
{
const
unsigned
char
*
ptr
;
uint16_t
len
;
...
...
@@ -228,79 +228,11 @@ int stun_find_string (const uint8_t *restrict msg, stun_attr_type_t type,
if
(
ptr
==
NULL
)
return
ENOENT
;
/* UTF-8 validation */
while
(
len
>
0
)
{
unsigned
i
;
unsigned
char
c
=
*
ptr
++
;
if
(
maxcp
==
0
)
return
ENOBUFS
;
maxcp
--
;
if
(
c
==
0
)
return
EINVAL
;
/* unexpected nul byte */
else
if
(
c
<
0x80
)
i
=
0
;
/* 0x01-0x7F: ASCII code point */
else
if
(
c
<
0xC2
)
/* 0x80-0xBF: continuation byte */
/* 0xC0-0xC1: overlongs */
return
EINVAL
;
else
if
(
c
<
0xE0
)
i
=
1
;
/* 0xC2-0xDF: two bytes code point */
else
if
(
c
<
0xF0
)
{
if
(
*
ptr
<
0xA0
)
return
EINVAL
;
/* overlong */
i
=
2
;
/* 0xE0-0xEF: three bytes code point */
}
else
if
(
c
<
0xF8
)
{
if
(
*
ptr
<
0x90
)
return
EINVAL
;
/* overlong */
i
=
3
;
/* 0xF0-0xF7: four bytes code point */
}
else
if
(
c
<
0xFC
)
{
if
(
*
ptr
<
0x88
)
return
EINVAL
;
/* overlong */
i
=
4
;
/* 0xF8-0xFB: five bytes code point */
}
else
if
(
c
<
0xFE
)
{
if
(
*
ptr
<
0x84
)
return
EINVAL
;
/* overlong */
i
=
5
;
}
else
return
EINVAL
;
/* 0xFE-0xFF: Byte-Order-Mark */
*
buf
++
=
c
;
len
--
;
if
(
i
>
len
)
return
EINVAL
;
/* too short */
while
(
i
>
0
)
{
c
=
*
ptr
++
;
len
--
;
if
((
c
&
0xC0
)
!=
0x80
)
return
EINVAL
;
*
buf
++
=
c
;
}
}
if
(
len
>=
buflen
)
return
ENOBUFS
;
*
buf
=
'\0'
;
memcpy
(
buf
,
ptr
,
len
);
buf
[
len
]
=
'\0'
;
return
0
;
}
...
...
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