summaryrefslogtreecommitdiffstats
path: root/src/net
diff options
context:
space:
mode:
authorMichael Brown2008-06-10 11:03:31 +0200
committerMichael Brown2008-06-10 11:04:02 +0200
commit81d92d51813f5ae2d5389d76fd114dd255d32038 (patch)
tree2c167c5b9173886202f8e4eea03c5a1bf039abf2 /src/net
parent[undi] Ask for promiscuous packet reception when using UNDI driver (diff)
downloadipxe-81d92d51813f5ae2d5389d76fd114dd255d32038.tar.gz
ipxe-81d92d51813f5ae2d5389d76fd114dd255d32038.tar.xz
ipxe-81d92d51813f5ae2d5389d76fd114dd255d32038.zip
[slam] Fix multicast address parsing
slam_parse_multicast_address() was failing to strip the initial "/" from the URI path.
Diffstat (limited to 'src/net')
-rw-r--r--src/net/udp/slam.c19
1 files changed, 11 insertions, 8 deletions
diff --git a/src/net/udp/slam.c b/src/net/udp/slam.c
index 67af8cba..160a5d97 100644
--- a/src/net/udp/slam.c
+++ b/src/net/udp/slam.c
@@ -632,27 +632,30 @@ static struct xfer_interface_operations slam_xfer_operations = {
static int slam_parse_multicast_address ( struct slam_request *slam,
const char *path,
struct sockaddr_in *address ) {
- char path_dup[ strlen ( path ) + 1 ];
+ char path_dup[ strlen ( path ) /* no +1 */ ];
char *sep;
+ char *end;
- /* Create temporary copy of path */
- memcpy ( path_dup, path, sizeof ( path_dup ) );
+ /* Create temporary copy of path, minus the leading '/' */
+ assert ( *path == '/' );
+ memcpy ( path_dup, ( path + 1 ) , sizeof ( path_dup ) );
/* Parse port, if present */
sep = strchr ( path_dup, ':' );
if ( sep ) {
*(sep++) = '\0';
- address->sin_port = htons ( strtoul ( sep, &sep, 0 ) );
- if ( *sep != '\0' ) {
- DBGC ( slam, "SLAM %p invalid multicast port\n",
- slam );
+ address->sin_port = htons ( strtoul ( sep, &end, 0 ) );
+ if ( *end != '\0' ) {
+ DBGC ( slam, "SLAM %p invalid multicast port "
+ "\"%s\"\n", slam, sep );
return -EINVAL;
}
}
/* Parse address */
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;
}