@@ -59,10 +59,16 @@ janus_sdp *janus_sdp_preparse(void *ice_handle, const char *jsep_sdp, char *erro
59
59
if (a -> name ) {
60
60
if (!strcasecmp (a -> name , "mid" )) {
61
61
/* Found mid attribute */
62
+ if (a -> value == NULL ) {
63
+ JANUS_LOG (LOG_ERR , "[%" SCNu64 "] Invalid mid attribute (no value)\n" , handle -> handle_id );
64
+ janus_sdp_destroy (parsed_sdp );
65
+ return NULL ;
66
+ }
62
67
if (m -> type == JANUS_SDP_AUDIO && m -> port > 0 ) {
63
68
JANUS_LOG (LOG_VERB , "[%" SCNu64 "] Audio mid: %s\n" , handle -> handle_id , a -> value );
64
69
if (strlen (a -> value ) > 16 ) {
65
70
JANUS_LOG (LOG_ERR , "[%" SCNu64 "] Audio mid too large: (%zu > 16)\n" , handle -> handle_id , strlen (a -> value ));
71
+ janus_sdp_destroy (parsed_sdp );
66
72
return NULL ;
67
73
}
68
74
if (handle -> audio_mid == NULL )
@@ -73,6 +79,7 @@ janus_sdp *janus_sdp_preparse(void *ice_handle, const char *jsep_sdp, char *erro
73
79
JANUS_LOG (LOG_VERB , "[%" SCNu64 "] Video mid: %s\n" , handle -> handle_id , a -> value );
74
80
if (strlen (a -> value ) > 16 ) {
75
81
JANUS_LOG (LOG_ERR , "[%" SCNu64 "] Video mid too large: (%zu > 16)\n" , handle -> handle_id , strlen (a -> value ));
82
+ janus_sdp_destroy (parsed_sdp );
76
83
return NULL ;
77
84
}
78
85
if (handle -> video_mid == NULL )
@@ -114,7 +121,7 @@ int janus_sdp_process(void *ice_handle, janus_sdp *remote_sdp, gboolean update)
114
121
GList * temp = remote_sdp -> attributes ;
115
122
while (temp ) {
116
123
janus_sdp_attribute * a = (janus_sdp_attribute * )temp -> data ;
117
- if (a && a -> name ) {
124
+ if (a && a -> name && a -> value ) {
118
125
if (!strcasecmp (a -> name , "fingerprint" )) {
119
126
JANUS_LOG (LOG_VERB , "[%" SCNu64 "] Fingerprint (global) : %s\n" , handle -> handle_id , a -> value );
120
127
if (strcasestr (a -> value , "sha-256 " ) == a -> value ) {
@@ -1229,14 +1236,14 @@ char *janus_sdp_merge(void *ice_handle, janus_sdp *anon, gboolean offer) {
1229
1236
if (audio == 1 ) {
1230
1237
g_snprintf (buffer_part , sizeof (buffer_part ),
1231
1238
" %s" , handle -> audio_mid ? handle -> audio_mid : "audio" );
1232
- g_strlcat (buffer , buffer_part , JANUS_BUFSIZE );
1239
+ g_strlcat (buffer , buffer_part , sizeof ( buffer ) );
1233
1240
}
1234
1241
} else if (m -> type == JANUS_SDP_VIDEO ) {
1235
1242
video ++ ;
1236
1243
if (video == 1 ) {
1237
1244
g_snprintf (buffer_part , sizeof (buffer_part ),
1238
1245
" %s" , handle -> video_mid ? handle -> video_mid : "video" );
1239
- g_strlcat (buffer , buffer_part , JANUS_BUFSIZE );
1246
+ g_strlcat (buffer , buffer_part , sizeof ( buffer ) );
1240
1247
}
1241
1248
#ifdef HAVE_SCTP
1242
1249
} else if (m -> type == JANUS_SDP_APPLICATION ) {
@@ -1245,7 +1252,7 @@ char *janus_sdp_merge(void *ice_handle, janus_sdp *anon, gboolean offer) {
1245
1252
if (data == 1 ) {
1246
1253
g_snprintf (buffer_part , sizeof (buffer_part ),
1247
1254
" %s" , handle -> data_mid ? handle -> data_mid : "data" );
1248
- g_strlcat (buffer , buffer_part , JANUS_BUFSIZE );
1255
+ g_strlcat (buffer , buffer_part , sizeof ( buffer ) );
1249
1256
}
1250
1257
#endif
1251
1258
}
0 commit comments