Skip to content

Commit 3a37101

Browse files
committed
Null-check for WebSocket handlers
1 parent f605ab6 commit 3a37101

File tree

14 files changed

+15
-0
lines changed

14 files changed

+15
-0
lines changed

Protest/Http/KeepAlive.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ public static async void WebSocketHandler(HttpListenerContext ctx) {
3636
try {
3737
WebSocketContext wsc = await ctx.AcceptWebSocketAsync(null);
3838
ws = wsc.WebSocket;
39+
if (ws is null) return;
3940
}
4041
catch (WebSocketException ex) {
4142
ctx.Response.Close();

Protest/Protocols/Dhcp.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ public static async void WebSocketHandler(HttpListenerContext ctx) {
1616
try {
1717
WebSocketContext wsc = await ctx.AcceptWebSocketAsync(null);
1818
ws = wsc.WebSocket;
19+
if (ws is null) return;
1920
}
2021
catch (WebSocketException ex) {
2122
ctx.Response.Close();

Protest/Protocols/Icmp.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ public static async void WebSocketHandler(HttpListenerContext ctx) {
5858
try {
5959
WebSocketContext wsc = await ctx.AcceptWebSocketAsync(null);
6060
ws = wsc.WebSocket;
61+
if (ws is null) return;
6162
}
6263
catch (WebSocketException ex) {
6364
ctx.Response.Close();

Protest/Protocols/Ssh.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ public static async void WebSocketHandler(HttpListenerContext ctx) {
2828
try {
2929
WebSocketContext wsc = await ctx.AcceptWebSocketAsync(null);
3030
ws = wsc.WebSocket;
31+
if (ws is null) return;
3132
}
3233
catch (WebSocketException ex) {
3334
ctx.Response.Close();

Protest/Protocols/Telnet.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ public static async void WebSocketHandler(HttpListenerContext ctx) {
2626
try {
2727
WebSocketContext wsc = await ctx.AcceptWebSocketAsync(null);
2828
ws = wsc.WebSocket;
29+
if (ws is null) return;
2930
}
3031
catch (WebSocketException ex) {
3132
ctx.Response.Close();

Protest/Proxy/ReverseProxy.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ public static async void WebSocketHandler(HttpListenerContext ctx) {
8686
try {
8787
WebSocketContext wsc = await ctx.AcceptWebSocketAsync(null);
8888
ws = wsc.WebSocket;
89+
if (ws is null) return;
8990
}
9091
catch (WebSocketException ex) {
9192
ctx.Response.Close();

Protest/Tasks/Issues.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ public static async void WebSocketHandler(HttpListenerContext ctx) {
108108
try {
109109
WebSocketContext wsc = await ctx.AcceptWebSocketAsync(null);
110110
ws = wsc.WebSocket;
111+
if (ws is null) return;
111112
}
112113
catch (WebSocketException ex) {
113114
ctx.Response.Close();

Protest/Tools/IpDiscovery.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ public static async void WebSocketHandler(HttpListenerContext ctx) {
106106
try {
107107
WebSocketContext wsc = await ctx.AcceptWebSocketAsync(null);
108108
ws = wsc.WebSocket;
109+
if (ws is null) return;
109110
}
110111
catch (WebSocketException ex) {
111112
ctx.Response.Close();

Protest/Tools/LiveStats.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ public static async void UserStats(HttpListenerContext ctx) {
4040
try {
4141
WebSocketContext wsc = await ctx.AcceptWebSocketAsync(null);
4242
ws = wsc.WebSocket;
43+
if (ws is null) return;
4344
}
4445
catch (WebSocketException ex) {
4546
ctx.Response.Close();
@@ -100,6 +101,7 @@ public static async void DeviceStats(HttpListenerContext ctx) {
100101
try {
101102
WebSocketContext wsc = await ctx.AcceptWebSocketAsync(null);
102103
ws = wsc.WebSocket;
104+
if (ws is null) return;
103105
}
104106
catch (WebSocketException ex) {
105107
ctx.Response.Close();

Protest/Tools/Monitor.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ public static async void WebSocketHandler(HttpListenerContext ctx) {
7676
try {
7777
WebSocketContext wsc = await ctx.AcceptWebSocketAsync(null);
7878
ws = wsc.WebSocket;
79+
if (ws is null) return;
7980
}
8081
catch (WebSocketException ex) {
8182
ctx.Response.Close();

0 commit comments

Comments
 (0)