File tree Expand file tree Collapse file tree 1 file changed +5
-8
lines changed Expand file tree Collapse file tree 1 file changed +5
-8
lines changed Original file line number Diff line number Diff line change @@ -1345,25 +1345,22 @@ socket_sockaddr_to_address_unix(struct sockaddr_storage *sa,
1345
1345
SocketAddress * addr ;
1346
1346
struct sockaddr_un * su = (struct sockaddr_un * )sa ;
1347
1347
1348
- assert (salen >= sizeof (su -> sun_family ) + 1 &&
1349
- salen <= sizeof (struct sockaddr_un ));
1350
-
1351
1348
addr = g_new0 (SocketAddress , 1 );
1352
1349
addr -> type = SOCKET_ADDRESS_TYPE_UNIX ;
1350
+ salen -= offsetof(struct sockaddr_un , sun_path );
1353
1351
#ifdef CONFIG_LINUX
1354
- if (!su -> sun_path [0 ]) {
1352
+ if (salen > 0 && !su -> sun_path [0 ]) {
1355
1353
/* Linux abstract socket */
1356
- addr -> u .q_unix .path = g_strndup (su -> sun_path + 1 ,
1357
- salen - sizeof (su -> sun_family ) - 1 );
1354
+ addr -> u .q_unix .path = g_strndup (su -> sun_path + 1 , salen - 1 );
1358
1355
addr -> u .q_unix .has_abstract = true;
1359
1356
addr -> u .q_unix .abstract = true;
1360
1357
addr -> u .q_unix .has_tight = true;
1361
- addr -> u .q_unix .tight = salen < sizeof (* su );
1358
+ addr -> u .q_unix .tight = salen < sizeof (su -> sun_path );
1362
1359
return addr ;
1363
1360
}
1364
1361
#endif
1365
1362
1366
- addr -> u .q_unix .path = g_strndup (su -> sun_path , sizeof ( su -> sun_path ) );
1363
+ addr -> u .q_unix .path = g_strndup (su -> sun_path , salen );
1367
1364
return addr ;
1368
1365
}
1369
1366
#endif /* WIN32 */
You can’t perform that action at this time.
0 commit comments