Skip to content

Commit f1ea91e

Browse files
committed
🐞 fix: Check when public key is omitted
1 parent 92fc0aa commit f1ea91e

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

caesar/pubkeylib/pubkey.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ func ParseAuthKey(authKey string) (caesar.PublicKey, error) {
4343
}
4444

4545
func GetPubKeys(target string) ([]caesar.PublicKey, error) {
46+
if target == "" {
47+
return nil, nil
48+
}
4649

4750
bytes, err := readTarget(target)
4851
if err != nil {

main.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ func main() {
3939
}
4040

4141
} else {
42+
if oppoPubKeys == nil {
43+
fmt.Fprintf(os.Stderr, "git-caesar: `-u` option missing\n")
44+
os.Exit(1)
45+
}
4246
outBytes, err = encrypt(oppoPubKeys, prvKey, inBytes)
4347
if err != nil {
4448
panic(err)

0 commit comments

Comments
 (0)