Skip to content

Commit edf3c15

Browse files
committed
rework
1 parent 6013acb commit edf3c15

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

dash-spv-ffi/src/config.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,12 @@ pub unsafe extern "C" fn dash_spv_ffi_config_add_peer(
176176
return FFIErrorCode::Success as i32;
177177
}
178178

179-
// 3) Must be a hostname - reject empty, append default port if not specified
179+
// 3) Must be a hostname - reject empty or missing hostname
180+
if addr_str.is_empty() {
181+
set_last_error("Empty or missing hostname");
182+
return FFIErrorCode::InvalidArgument as i32;
183+
}
184+
180185
let addr_with_port = if addr_str.contains(':') {
181186
addr_str.to_string()
182187
} else {

dash-spv-ffi/tests/unit/test_configuration.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ mod tests {
5959
"127.0.0.1:99999", // port too high
6060
"127.0.0.1:-1", // negative port
6161
":9999", // missing hostname
62+
":", // missing hostname and port
6263
":::", // invalid IPv6
6364
"localhost:abc", // non-numeric port
6465
"localhost:", // empty port

0 commit comments

Comments
 (0)