mirror of
https://github.com/ipxe/ipxe
synced 2025-12-21 20:40:25 +03:00
[slam] Fix multicast address parsing
slam_parse_multicast_address() was failing to strip the initial "/" from the URI path.
This commit is contained in:
@@ -632,27 +632,30 @@ static struct xfer_interface_operations slam_xfer_operations = {
|
|||||||
static int slam_parse_multicast_address ( struct slam_request *slam,
|
static int slam_parse_multicast_address ( struct slam_request *slam,
|
||||||
const char *path,
|
const char *path,
|
||||||
struct sockaddr_in *address ) {
|
struct sockaddr_in *address ) {
|
||||||
char path_dup[ strlen ( path ) + 1 ];
|
char path_dup[ strlen ( path ) /* no +1 */ ];
|
||||||
char *sep;
|
char *sep;
|
||||||
|
char *end;
|
||||||
|
|
||||||
/* Create temporary copy of path */
|
/* Create temporary copy of path, minus the leading '/' */
|
||||||
memcpy ( path_dup, path, sizeof ( path_dup ) );
|
assert ( *path == '/' );
|
||||||
|
memcpy ( path_dup, ( path + 1 ) , sizeof ( path_dup ) );
|
||||||
|
|
||||||
/* Parse port, if present */
|
/* Parse port, if present */
|
||||||
sep = strchr ( path_dup, ':' );
|
sep = strchr ( path_dup, ':' );
|
||||||
if ( sep ) {
|
if ( sep ) {
|
||||||
*(sep++) = '\0';
|
*(sep++) = '\0';
|
||||||
address->sin_port = htons ( strtoul ( sep, &sep, 0 ) );
|
address->sin_port = htons ( strtoul ( sep, &end, 0 ) );
|
||||||
if ( *sep != '\0' ) {
|
if ( *end != '\0' ) {
|
||||||
DBGC ( slam, "SLAM %p invalid multicast port\n",
|
DBGC ( slam, "SLAM %p invalid multicast port "
|
||||||
slam );
|
"\"%s\"\n", slam, sep );
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Parse address */
|
/* Parse address */
|
||||||
if ( inet_aton ( path_dup, &address->sin_addr ) == 0 ) {
|
if ( inet_aton ( path_dup, &address->sin_addr ) == 0 ) {
|
||||||
DBGC ( slam, "SLAM %p invalid multicast address\n", slam );
|
DBGC ( slam, "SLAM %p invalid multicast address \"%s\"\n",
|
||||||
|
slam, path_dup );
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user