git: 06a079c69e84 - stable/13 - pw: exit with an error in case of using an illegal option

From: Baptiste Daroussin <bapt_at_FreeBSD.org>
Date: Wed, 19 Oct 2022 08:01:21 UTC
The branch stable/13 has been updated by bapt:

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

commit 06a079c69e843a796c5956b8e9a79a35d3401f38
Author:     Baptiste Daroussin <bapt@FreeBSD.org>
AuthorDate: 2022-10-12 10:06:32 +0000
Commit:     Baptiste Daroussin <bapt@FreeBSD.org>
CommitDate: 2022-10-19 07:55:48 +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
    
    (cherry picked from commit c0358afd5bbc2c675941fed2905479ad109770bb)
---
 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 2eec317b5e5b..f218ebdf8c13 100644
--- a/usr.sbin/pw/pw_user.c
+++ b/usr.sbin/pw/pw_user.c
@@ -754,6 +754,8 @@ pw_user_next(int argc, char **argv, char *name __unused)
 		case 'q':
 			quiet = true;
 			break;
+		default:
+			exit(EX_USAGE);
 		}
 	}
 
@@ -816,6 +818,8 @@ pw_user_show(int argc, char **argv, char *arg1)
 		case '7':
 			v7 = true;
 			break;
+		default:
+			exit(EX_USAGE);
 		}
 	}
 
@@ -897,6 +901,8 @@ pw_user_del(int argc, char **argv, char *arg1)
 		case 'Y':
 			nis = true;
 			break;
+		default:
+			exit(EX_USAGE);
 		}
 	}
 
@@ -1038,6 +1044,8 @@ pw_user_lock(int argc, char **argv, char *arg1)
 		case 'q':
 			/* compatibility */
 			break;
+		default:
+			exit(EX_USAGE);
 		}
 	}
 
@@ -1055,6 +1063,8 @@ pw_user_unlock(int argc, char **argv, char *arg1)
 		case 'q':
 			/* compatibility */
 			break;
+		default:
+			exit(EX_USAGE);
 		}
 	}
 
@@ -1322,6 +1332,8 @@ pw_user_add(int argc, char **argv, char *arg1)
 		case 'Y':
 			nis = true;
 			break;
+		default:
+			exit(EX_USAGE);
 		}
 	}
 
@@ -1630,6 +1642,8 @@ pw_user_mod(int argc, char **argv, char *arg1)
 		case 'Y':
 			nis = true;
 			break;
+		default:
+			exit(EX_USAGE);
 		}
 	}