Skip to content

Commit cade7b7

Browse files
committed
Added invalid ip/port handling to the json parsing
1 parent 5a9a2fc commit cade7b7

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/session_network.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,12 +184,18 @@ namespace {
184184
else
185185
ip = json["ip"].get<std::string>();
186186

187+
if (ip == "0.0.0.0")
188+
throw std::runtime_error{"Invalid IP address"};
189+
187190
uint16_t port;
188191
if (json.contains("storage_lmq_port"))
189192
port = json["storage_lmq_port"].get<uint16_t>();
190193
else
191194
port = json["port_omq"].get<uint16_t>();
192195

196+
if (port == 0)
197+
throw std::runtime_error{"Invalid lmq port"};
198+
193199
swarm_id_t swarm_id = INVALID_SWARM_ID;
194200
if (json.contains("swarm_id"))
195201
swarm_id = json["swarm_id"].get<swarm_id_t>();

0 commit comments

Comments
 (0)