git: c0358afd5bbc - main - pw: exit with an error in case of using an illegal option

From: Baptiste Daroussin <bapt_at_FreeBSD.org>
Date: Wed, 12 Oct 2022 10:08:09 UTC
The branch main has been updated by bapt:

URL: https://cgit.FreeBSD.org/src/commit/?id=c0358afd5bbc2c675941fed2905479ad109770bb

commit c0358afd5bbc2c675941fed2905479ad109770bb
Author:     Baptiste Daroussin <bapt@FreeBSD.org>
AuthorDate: 2022-10-12 10:06:32 +0000
Commit:     Baptiste Daroussin <bapt@FreeBSD.org>
CommitDate: 2022-10-12 10:06:32 +0000

    pw: exit with an error in case of using an illegal option
    
    PR:             263188
    Reported by:    Dennis Clarke <dclarke@blastwave.org>
    MFC After:      1 week
---
 usr.sbin/pw/pw_group.c | 10 ++++++++++
 usr.sbin/pw/pw_user.c  | 14 ++++++++++++++
 2 files changed, 24 insertions(+)

diff --git a/usr.sbin/pw/pw_group.c b/usr.sbin/pw/pw_group.c
index a294d4ecbb5c..1f5979a5dd03 100644
--- a/usr.sbin/pw/pw_group.c
+++ b/usr.sbin/pw/pw_group.c
@@ -276,6 +276,8 @@ pw_group_next(int argc, char **argv, char *arg1 __unused)
 		case 'q':
 			quiet = true;
 			break;
+		default:
+			exit(EX_USAGE);
 		}
 	}
 
@@ -333,6 +335,8 @@ pw_group_show(int argc, char **argv, char *arg1)
 		case 'a':
 			all = true;
 			break;
+		default:
+			exit(EX_USAGE);
 		}
 	}
 
@@ -390,6 +394,8 @@ pw_group_del(int argc, char **argv, char *arg1)
 		case 'Y':
 			nis = true;
 			break;
+		default:
+			exit(EX_USAGE);
 		}
 	}
 
@@ -548,6 +554,8 @@ pw_group_add(int argc, char **argv, char *arg1)
 		case 'Y':
 			nis = true;
 			break;
+		default:
+			exit(EX_USAGE);
 		}
 	}
 
@@ -640,6 +648,8 @@ pw_group_mod(int argc, char **argv, char *arg1)
 		case 'Y':
 			nis = true;
 			break;
+		default:
+			exit(EX_USAGE);
 		}
 	}
 	if (quiet)
diff --git a/usr.sbin/pw/pw_user.c b/usr.sbin/pw/pw_user.c
index 653fb1cb0dfb..7dd84d468f1f 100644
--- a/usr.sbin/pw/pw_user.c
+++ b/usr.sbin/pw/pw_user.c
@@ -723,6 +723,8 @@ pw_user_next(int argc, char **argv, char *name __unused)
 		case 'q':
 			quiet = true;
 			break;
+		default:
+			exit(EX_USAGE);
 		}
 	}
 
@@ -785,6 +787,8 @@ pw_user_show(int argc, char **argv, char *arg1)
 		case '7':
 			v7 = true;
 			break;
+		default:
+			exit(EX_USAGE);
 		}
 	}
 
@@ -866,6 +870,8 @@ pw_user_del(int argc, char **argv, char *arg1)
 		case 'Y':
 			nis = true;
 			break;
+		default:
+			exit(EX_USAGE);
 		}
 	}
 
@@ -1003,6 +1009,8 @@ pw_user_lock(int argc, char **argv, char *arg1)
 		case 'q':
 			/* compatibility */
 			break;
+		default:
+			exit(EX_USAGE);
 		}
 	}
 
@@ -1020,6 +1028,8 @@ pw_user_unlock(int argc, char **argv, char *arg1)
 		case 'q':
 			/* compatibility */
 			break;
+		default:
+			exit(EX_USAGE);
 		}
 	}
 
@@ -1287,6 +1297,8 @@ pw_user_add(int argc, char **argv, char *arg1)
 		case 'Y':
 			nis = true;
 			break;
+		default:
+			exit(EX_USAGE);
 		}
 	}
 
@@ -1595,6 +1607,8 @@ pw_user_mod(int argc, char **argv, char *arg1)
 		case 'Y':
 			nis = true;
 			break;
+		default:
+			exit(EX_USAGE);
 		}
 	}