|
@@ -656,13 +656,18 @@ static struct interface_descriptor slam_xfer_desc =
|
656
|
656
|
static int slam_parse_multicast_address ( struct slam_request *slam,
|
657
|
657
|
const char *path,
|
658
|
658
|
struct sockaddr_in *address ) {
|
659
|
|
- char path_dup[ strlen ( path ) /* no +1 */ ];
|
|
659
|
+ char *path_dup;
|
660
|
660
|
char *sep;
|
661
|
661
|
char *end;
|
|
662
|
+ int rc;
|
662
|
663
|
|
663
|
664
|
/* Create temporary copy of path, minus the leading '/' */
|
664
|
665
|
assert ( *path == '/' );
|
665
|
|
- memcpy ( path_dup, ( path + 1 ) , sizeof ( path_dup ) );
|
|
666
|
+ path_dup = strdup ( path + 1 );
|
|
667
|
+ if ( ! path_dup ) {
|
|
668
|
+ rc = -ENOMEM;
|
|
669
|
+ goto err_strdup;
|
|
670
|
+ }
|
666
|
671
|
|
667
|
672
|
/* Parse port, if present */
|
668
|
673
|
sep = strchr ( path_dup, ':' );
|
|
@@ -672,7 +677,8 @@ static int slam_parse_multicast_address ( struct slam_request *slam,
|
672
|
677
|
if ( *end != '\0' ) {
|
673
|
678
|
DBGC ( slam, "SLAM %p invalid multicast port "
|
674
|
679
|
"\"%s\"\n", slam, sep );
|
675
|
|
- return -EINVAL;
|
|
680
|
+ rc = -EINVAL;
|
|
681
|
+ goto err_port;
|
676
|
682
|
}
|
677
|
683
|
}
|
678
|
684
|
|
|
@@ -680,10 +686,18 @@ static int slam_parse_multicast_address ( struct slam_request *slam,
|
680
|
686
|
if ( inet_aton ( path_dup, &address->sin_addr ) == 0 ) {
|
681
|
687
|
DBGC ( slam, "SLAM %p invalid multicast address \"%s\"\n",
|
682
|
688
|
slam, path_dup );
|
683
|
|
- return -EINVAL;
|
|
689
|
+ rc = -EINVAL;
|
|
690
|
+ goto err_addr;
|
684
|
691
|
}
|
685
|
692
|
|
686
|
|
- return 0;
|
|
693
|
+ /* Success */
|
|
694
|
+ rc = 0;
|
|
695
|
+
|
|
696
|
+ err_addr:
|
|
697
|
+ err_port:
|
|
698
|
+ free ( path_dup );
|
|
699
|
+ err_strdup:
|
|
700
|
+ return rc;
|
687
|
701
|
}
|
688
|
702
|
|
689
|
703
|
/**
|