Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
libnice
libnice
Commits
fabb0ad0
Commit
fabb0ad0
authored
Jan 30, 2007
by
Dafydd Harries
Browse files
fix code for calculating STUN attribute padding
darcs-hash:20070130112429-c9803-cf50942c820cda76e81b5ccb8ddb1a724be02599.gz
parent
ba801290
Changes
1
Show whitespace changes
Inline
Side-by-side
stun/stun.c
View file @
fabb0ad0
...
@@ -4,6 +4,17 @@
...
@@ -4,6 +4,17 @@
#include
<arpa/inet.h>
#include
<arpa/inet.h>
#include
<string.h>
#include
<string.h>
/* round up to multiple of 4 */
G_GNUC_CONST
static
guint
ceil4
(
guint
n
)
{
if
(
n
%
4
==
0
)
return
n
;
else
return
n
+
4
-
(
n
%
4
);
}
G_GNUC_WARN_UNUSED_RESULT
G_GNUC_WARN_UNUSED_RESULT
static
StunAttribute
*
static
StunAttribute
*
stun_attribute_new
(
guint
type
)
stun_attribute_new
(
guint
type
)
...
@@ -200,9 +211,7 @@ stun_message_unpack (guint length, gchar *s)
...
@@ -200,9 +211,7 @@ stun_message_unpack (guint length, gchar *s)
for
(
offset
=
20
;
offset
<
length
;
offset
+=
attr_length
)
for
(
offset
=
20
;
offset
<
length
;
offset
+=
attr_length
)
{
{
attr_length
=
4
+
ntohs
(
*
(
guint16
*
)(
s
+
offset
+
2
));
attr_length
=
ceil4
(
4
+
ntohs
(
*
(
guint16
*
)(
s
+
offset
+
2
)));
/* pad to multiple of 4 bytes */
attr_length
+=
4
-
(
attr_length
%
4
);
n_attributes
++
;
n_attributes
++
;
}
}
...
@@ -218,8 +227,7 @@ stun_message_unpack (guint length, gchar *s)
...
@@ -218,8 +227,7 @@ stun_message_unpack (guint length, gchar *s)
attr_length
=
4
+
ntohs
(
*
(
guint16
*
)(
s
+
offset
+
2
));
attr_length
=
4
+
ntohs
(
*
(
guint16
*
)(
s
+
offset
+
2
));
attr
=
msg
->
attributes
[
i
]
=
stun_attribute_unpack
(
attr_length
,
attr
=
msg
->
attributes
[
i
]
=
stun_attribute_unpack
(
attr_length
,
s
+
offset
);
s
+
offset
);
/* pad to multiple of 4 bytes */
attr_length
=
ceil4
(
attr_length
);
attr_length
+=
4
-
(
attr_length
%
4
);
}
}
return
msg
;
return
msg
;
...
...
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