From 5a9d101f16367c4f2fafb9378d407ed9b60f2450 Mon Sep 17 00:00:00 2001 From: fduncanh Date: Thu, 5 Aug 2021 12:15:31 -0400 Subject: [PATCH] fix bug in network port input --- uxplay.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/uxplay.cpp b/uxplay.cpp index b47e3b0..7ec4425 100755 --- a/uxplay.cpp +++ b/uxplay.cpp @@ -147,9 +147,10 @@ static bool get_display_size (char *str, unsigned short *w, unsigned short *h) { static bool get_lowest_port (char *str, unsigned short *n) { if (strlen(str) > 5) return false; char *end; - *n = (unsigned short) strtoul(str, &end, 10); // first character of str is never '-' + unsigned long l; + *n = (unsigned short) (l = strtoul(str, &end, 10)); // first character of str is never '-' if (*end) return false; - if (*n < LOWEST_ALLOWED_PORT || *n > HIGHEST_PORT - 2 ) return false; + if (l < LOWEST_ALLOWED_PORT || l > HIGHEST_PORT - 2 ) return false; return true; }