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
3b935de9
Commit
3b935de9
authored
Mar 05, 2009
by
Youness Alaoui
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix the stupid wlm2009 crc32 typo without using a global variable
parent
d73a8654
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
12 additions
and
21 deletions
+12
-21
stun/stun5389.c
stun/stun5389.c
+3
-2
stun/stun5389.h
stun/stun5389.h
+2
-1
stun/stunagent.c
stun/stunagent.c
+4
-13
stun/stuncrc32.c
stun/stuncrc32.c
+1
-3
stun/stuncrc32.h
stun/stuncrc32.h
+2
-2
No files found.
stun/stun5389.c
View file @
3b935de9
...
@@ -52,7 +52,8 @@
...
@@ -52,7 +52,8 @@
#include "stuncrc32.h"
#include "stuncrc32.h"
#include "stunmessage.h"
#include "stunmessage.h"
uint32_t
stun_fingerprint
(
const
uint8_t
*
msg
,
size_t
len
)
uint32_t
stun_fingerprint
(
const
uint8_t
*
msg
,
size_t
len
,
bool
wlm2009_stupid_crc32_typo
)
{
{
crc_data
data
[
3
];
crc_data
data
[
3
];
uint16_t
fakelen
=
htons
(
len
-
20u
);
uint16_t
fakelen
=
htons
(
len
-
20u
);
...
@@ -67,7 +68,7 @@ uint32_t stun_fingerprint (const uint8_t *msg, size_t len)
...
@@ -67,7 +68,7 @@ uint32_t stun_fingerprint (const uint8_t *msg, size_t len)
/* first 4 bytes done, last 8 bytes not summed */
/* first 4 bytes done, last 8 bytes not summed */
data
[
2
].
len
=
len
-
12u
;
data
[
2
].
len
=
len
-
12u
;
return
htonl
(
crc32
(
data
,
3
)
^
0x5354554e
);
return
htonl
(
crc32
(
data
,
3
,
wlm2009_stupid_crc32_typo
)
^
0x5354554e
);
}
}
bool
stun_message_has_cookie
(
const
StunMessage
*
msg
)
bool
stun_message_has_cookie
(
const
StunMessage
*
msg
)
...
...
stun/stun5389.h
View file @
3b935de9
...
@@ -57,7 +57,8 @@
...
@@ -57,7 +57,8 @@
*
*
* @return fingerprint value in <b>host</b> byte order.
* @return fingerprint value in <b>host</b> byte order.
*/
*/
uint32_t
stun_fingerprint
(
const
uint8_t
*
msg
,
size_t
len
);
uint32_t
stun_fingerprint
(
const
uint8_t
*
msg
,
size_t
len
,
bool
wlm2009_stupid_crc32_typo
);
/**
/**
* stun_message_has_cookie:
* stun_message_has_cookie:
...
...
stun/stunagent.c
View file @
3b935de9
...
@@ -145,14 +145,9 @@ StunValidationStatus stun_agent_validate (StunAgent *agent, StunMessage *msg,
...
@@ -145,14 +145,9 @@ StunValidationStatus stun_agent_validate (StunAgent *agent, StunMessage *msg,
stun_debug
(
"STUN demux error: no FINGERPRINT attribute!
\n
"
);
stun_debug
(
"STUN demux error: no FINGERPRINT attribute!
\n
"
);
return
STUN_VALIDATION_BAD_REQUEST
;
return
STUN_VALIDATION_BAD_REQUEST
;
}
}
if
(
agent
->
compatibility
==
STUN_COMPATIBILITY_WLM2009
)
wlm2009_stupid_crc32_typo
=
1
;
else
wlm2009_stupid_crc32_typo
=
0
;
/* Checks FINGERPRINT */
/* Checks FINGERPRINT */
crc32
=
stun_fingerprint
(
msg
->
buffer
,
stun_message_length
(
msg
));
crc32
=
stun_fingerprint
(
msg
->
buffer
,
stun_message_length
(
msg
),
agent
->
compatibility
==
STUN_COMPATIBILITY_WLM2009
);
fpr
=
ntohl
(
fpr
);
fpr
=
ntohl
(
fpr
);
if
(
fpr
!=
crc32
)
{
if
(
fpr
!=
crc32
)
{
stun_debug
(
"STUN demux error: bad fingerprint: 0x%08x,"
stun_debug
(
"STUN demux error: bad fingerprint: 0x%08x,"
...
@@ -578,12 +573,8 @@ size_t stun_agent_finish_message (StunAgent *agent, StunMessage *msg,
...
@@ -578,12 +573,8 @@ size_t stun_agent_finish_message (StunAgent *agent, StunMessage *msg,
return
0
;
return
0
;
}
}
fpr
=
stun_fingerprint
(
msg
->
buffer
,
stun_message_length
(
msg
),
if
(
agent
->
compatibility
==
STUN_COMPATIBILITY_WLM2009
)
agent
->
compatibility
==
STUN_COMPATIBILITY_WLM2009
);
wlm2009_stupid_crc32_typo
=
1
;
else
wlm2009_stupid_crc32_typo
=
0
;
fpr
=
stun_fingerprint
(
msg
->
buffer
,
stun_message_length
(
msg
));
memcpy
(
ptr
,
&
fpr
,
sizeof
(
fpr
));
memcpy
(
ptr
,
&
fpr
,
sizeof
(
fpr
));
stun_debug
(
" Message HMAC-SHA1 fingerprint: "
);
stun_debug
(
" Message HMAC-SHA1 fingerprint: "
);
...
...
stun/stuncrc32.c
View file @
3b935de9
...
@@ -89,8 +89,6 @@
...
@@ -89,8 +89,6 @@
#include "stuncrc32.h"
#include "stuncrc32.h"
int
wlm2009_stupid_crc32_typo
=
0
;
static
const
uint32_t
crc32_tab
[]
=
{
static
const
uint32_t
crc32_tab
[]
=
{
0x00000000
,
0x77073096
,
0xee0e612c
,
0x990951ba
,
0x076dc419
,
0x706af48f
,
0x00000000
,
0x77073096
,
0xee0e612c
,
0x990951ba
,
0x076dc419
,
0x706af48f
,
0xe963a535
,
0x9e6495a3
,
0x0edb8832
,
0x79dcb8a4
,
0xe0d5e91e
,
0x97d2d988
,
0xe963a535
,
0x9e6495a3
,
0x0edb8832
,
0x79dcb8a4
,
0xe0d5e91e
,
0x97d2d988
,
...
@@ -138,7 +136,7 @@ static const uint32_t crc32_tab[] = {
...
@@ -138,7 +136,7 @@ static const uint32_t crc32_tab[] = {
};
};
uint32_t
crc32
(
const
crc_data
*
data
,
size_t
n
)
uint32_t
crc32
(
const
crc_data
*
data
,
size_t
n
,
bool
wlm2009_stupid_crc32_typo
)
{
{
size_t
i
;
size_t
i
;
uint32_t
crc
=
0xffffffff
;
uint32_t
crc
=
0xffffffff
;
...
...
stun/stuncrc32.h
View file @
3b935de9
...
@@ -43,6 +43,7 @@
...
@@ -43,6 +43,7 @@
#include "win32_common.h"
#include "win32_common.h"
#else
#else
#include <stdint.h>
#include <stdint.h>
#include <stdbool.h>
#endif
#endif
#include <stdlib.h>
#include <stdlib.h>
...
@@ -53,7 +54,6 @@ typedef struct {
...
@@ -53,7 +54,6 @@ typedef struct {
}
crc_data
;
}
crc_data
;
int
wlm2009_stupid_crc32_typo
;
uint32_t
crc32
(
const
crc_data
*
data
,
size_t
n
,
bool
wlm2009_stupid_crc32_typo
);
uint32_t
crc32
(
const
crc_data
*
data
,
size_t
n
);
#endif
/* _CRC32_H */
#endif
/* _CRC32_H */
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