]> Cypherpunks.ru repositories - nncp.git/blobdiff - src/cmd/nncp-xfer/main.go
Fix encrypted packet magic number check
[nncp.git] / src / cmd / nncp-xfer / main.go
index b65686c8d14b6caa7d271d00053a13574075674d..41e8c61c8e157f087d9fa5096990d92231bf316d 100644 (file)
@@ -1,6 +1,6 @@
 /*
 NNCP -- Node to Node copy, utilities for store-and-forward data exchange
-Copyright (C) 2016-2021 Sergey Matveev <stargrave@stargrave.org>
+Copyright (C) 2016-2022 Sergey Matveev <stargrave@stargrave.org>
 
 This program is free software: you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
@@ -218,7 +218,7 @@ func main() {
                                continue
                        }
                        pktEnc, pktEncRaw, err := ctx.HdrRead(fd)
-                       if err != nil {
+                       if err == nil {
                                switch pktEnc.Magic {
                                case nncp.MagicNNCPEv1.B:
                                        err = nncp.MagicNNCPEv1.TooOld()
@@ -229,6 +229,8 @@ func main() {
                                case nncp.MagicNNCPEv4.B:
                                        err = nncp.MagicNNCPEv4.TooOld()
                                case nncp.MagicNNCPEv5.B:
+                                       err = nncp.MagicNNCPEv5.TooOld()
+                               case nncp.MagicNNCPEv6.B:
                                default:
                                        err = errors.New("is not an encrypted packet")
                                }