Commit 788d4a19ed0ddf9df069f9a6d5a8ecd9ebf932ee

Stefan Sperling 2021-09-14T14:18:59

validate status codes given to 'got status -S'

diff --git a/got/got.c b/got/got.c
index 66d66fa..5b6177b 100644
--- a/got/got.c
+++ b/got/got.c
@@ -5323,6 +5323,11 @@ cmd_status(int argc, char *argv[])
 		case 'I':
 			no_ignores = 1;
 			break;
+		case 'S':
+			if (st.status_codes != NULL && st.suppress == 0)
+				option_conflict('S', 's');
+			st.suppress = 1;
+			/* fallthrough */
 		case 's':
 			for (i = 0; i < strlen(optarg); i++) {
 				switch (optarg[i]) {
@@ -5341,16 +5346,10 @@ cmd_status(int argc, char *argv[])
 					    optarg[i]);
 				}
 			}
-			if (st.suppress)
+			if (ch == 's' && st.suppress)
 				option_conflict('s', 'S');
 			st.status_codes = optarg;
 			break;
-		case 'S':
-			if (st.status_codes != NULL && st.suppress == 0)
-				option_conflict('S', 's');
-			st.status_codes = optarg;
-			st.suppress = 1;
-			break;
 		default:
 			usage_status();
 			/* NOTREACHED */