From 4a8e79c63ceea6596ccfe3d173ad452389ded81e Mon Sep 17 00:00:00 2001 From: Sergey Matveev Date: Thu, 8 Apr 2021 15:50:53 +0300 Subject: [PATCH] Fixed invalid "Size" type, leading to panic during Progress --- doc/news.ru.texi | 10 ++++++++++ doc/news.texi | 9 +++++++++ ports/nncp/Makefile | 2 +- src/nncp.go | 2 +- src/sp.go | 48 ++++++++++++++++++++++++++------------------- 5 files changed, 49 insertions(+), 22 deletions(-) diff --git a/doc/news.ru.texi b/doc/news.ru.texi index 6ca08c7..ea1c700 100644 --- a/doc/news.ru.texi +++ b/doc/news.ru.texi @@ -1,6 +1,16 @@ @node Новости @section Новости +@node Релиз 6.3.0 +@subsection Релиз 6.3.0 +@itemize + +@item +Исправлено возможное падение программы во время показа прогресса online +протокола. + +@end itemize + @node Релиз 6.2.1 @subsection Релиз 6.2.1 @itemize diff --git a/doc/news.texi b/doc/news.texi index e128886..87be652 100644 --- a/doc/news.texi +++ b/doc/news.texi @@ -3,6 +3,15 @@ See also this page @ref{Новости, on russian}. +@node Release 6.3.0 +@section Release 6.3.0 +@itemize + +@item +Fixed possible panic while showing progress during online protocol. + +@end itemize + @node Release 6.2.1 @section Release 6.2.1 @itemize diff --git a/ports/nncp/Makefile b/ports/nncp/Makefile index cc666d8..e2a7e5d 100644 --- a/ports/nncp/Makefile +++ b/ports/nncp/Makefile @@ -1,7 +1,7 @@ # $FreeBSD: $ PORTNAME= nncp -DISTVERSION= 6.1.0 +DISTVERSION= 6.3.0 CATEGORIES= net MASTER_SITES= http://www.nncpgo.org/download/ diff --git a/src/nncp.go b/src/nncp.go index 1a933a0..12edaa4 100644 --- a/src/nncp.go +++ b/src/nncp.go @@ -40,7 +40,7 @@ along with this program. If not, see .` const Base32Encoded32Len = 52 var ( - Version string = "6.2.1" + Version string = "6.3.0" Base32Codec *base32.Encoding = base32.StdEncoding.WithPadding(base32.NoPadding) ) diff --git a/src/sp.go b/src/sp.go index f2c707f..e6e4900 100644 --- a/src/sp.go +++ b/src/sp.go @@ -729,7 +729,7 @@ func (state *SPState) StartWorkers( for _, payload := range infosPayloads[1:] { state.Ctx.LogD( "sp-queue-remaining", - append(les, LE{"Size", len(payload)}), + append(les, LE{"Size", int64(len(payload))}), func(les LEs) string { return fmt.Sprintf( "SP with %s (nice %s): queuing remaining payload (%s)", @@ -752,7 +752,7 @@ func (state *SPState) StartWorkers( humanize.IBytes(uint64(len(payload))), ) } - state.Ctx.LogD("sp-process", append(les, LE{"Size", len(payload)}), logMsg) + state.Ctx.LogD("sp-process", append(les, LE{"Size", int64(len(payload))}), logMsg) replies, err := state.ProcessSP(payload) if err != nil { state.Ctx.LogE("sp-process", les, err, logMsg) @@ -763,7 +763,7 @@ func (state *SPState) StartWorkers( for _, reply := range replies { state.Ctx.LogD( "sp-queue-reply", - append(les, LE{"Size", len(reply)}), + append(les, LE{"Size", int64(len(reply))}), func(les LEs) string { return fmt.Sprintf( "SP with %s (nice %s): queuing reply (%s)", @@ -828,7 +828,7 @@ func (state *SPState) StartWorkers( ) { state.Ctx.LogD( "sp-queue-info", - append(les, LE{"Size", len(payload)}), + append(les, LE{"Size", int64(len(payload))}), func(les LEs) string { return fmt.Sprintf( "SP with %s (nice %s): queuing new info (%s)", @@ -869,7 +869,7 @@ func (state *SPState) StartWorkers( case payload = <-state.payloads: state.Ctx.LogD( "sp-got-payload", - append(les, LE{"Size", len(payload)}), + append(les, LE{"Size", int64(len(payload))}), func(les LEs) string { return fmt.Sprintf( "SP with %s (nice %s): got payload (%s)", @@ -955,16 +955,18 @@ func (state *SPState) StartWorkers( return } buf = buf[:n] - state.Ctx.LogD( - "sp-file-read", - append(lesp, LE{"Size", n}), - func(les LEs) string { - return fmt.Sprintf( - "%s: read %s", - logMsg(les), humanize.IBytes(uint64(n)), - ) - }, + lesp = append( + les, + LE{"XX", string(TTx)}, + LE{"Pkt", pktName}, + LE{"Size", int64(n)}, ) + state.Ctx.LogD("sp-file-read", lesp, func(les LEs) string { + return fmt.Sprintf( + "%s: read %s", + logMsg(les), humanize.IBytes(uint64(n)), + ) + }) } state.closeFd(pth) payload = MarshalSP(SPTypeFile, SPFile{ @@ -973,7 +975,13 @@ func (state *SPState) StartWorkers( Payload: buf, }) ourSize := freq.Offset + uint64(len(buf)) - lesp = append(lesp, LE{"Size", int64(ourSize)}, LE{"FullSize", fullSize}) + lesp = append( + les, + LE{"XX", string(TTx)}, + LE{"Pkt", pktName}, + LE{"Size", int64(ourSize)}, + LE{"FullSize", fullSize}, + ) if state.Ctx.ShowPrgrs { Progress("Tx", lesp) } @@ -1005,7 +1013,7 @@ func (state *SPState) StartWorkers( humanize.IBytes(uint64(len(payload))), ) } - state.Ctx.LogD("sp-sending", append(les, LE{"Size", len(payload)}), logMsg) + state.Ctx.LogD("sp-sending", append(les, LE{"Size", int64(len(payload))}), logMsg) conn.SetWriteDeadline(time.Now().Add(DefaultDeadline)) // #nosec G104 if err := state.WriteSP(conn, state.csOur.Encrypt(nil, nil, payload), ping); err != nil { state.Ctx.LogE("sp-sending", les, err, logMsg) @@ -1053,7 +1061,7 @@ func (state *SPState) StartWorkers( } state.Ctx.LogD( "sp-recv-got", - append(les, LE{"Size", len(payload)}), + append(les, LE{"Size", int64(len(payload))}), func(les LEs) string { return logMsg(les) + ": got" }, ) payload, err = state.csTheir.Decrypt(nil, nil, payload) @@ -1065,7 +1073,7 @@ func (state *SPState) StartWorkers( } state.Ctx.LogD( "sp-recv-process", - append(les, LE{"Size", len(payload)}), + append(les, LE{"Size", int64(len(payload))}), func(les LEs) string { return logMsg(les) + ": processing" }, @@ -1082,7 +1090,7 @@ func (state *SPState) StartWorkers( for _, reply := range replies { state.Ctx.LogD( "sp-recv-reply", - append(les[:len(les)-1], LE{"Size", len(reply)}), + append(les[:len(les)-1], LE{"Size", int64(len(reply))}), func(les LEs) string { return fmt.Sprintf( "SP with %s (nice %s): queuing reply (%s)", @@ -1326,7 +1334,7 @@ func (state *SPState) ProcessSP(payload []byte) ([][]byte, error) { lesp, LE{"XX", string(TRx)}, LE{"Pkt", pktName}, - LE{"Size", len(file.Payload)}, + LE{"Size", int64(len(file.Payload))}, ) logMsg := func(les LEs) string { return fmt.Sprintf( -- 2.44.0