[PATCH v2 7/8] Fix widespread off-by-one error dealing with port numbers