openidec

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit d024ff3b0cfa40e07a66c57b24a1d84ba225b986
parent f6ece1443332959a0d114cfd4db7bbd19dbee5e0
Author: Peter Kosyh <p.kosyh@gmail.com>
Date:   Sun, 31 Jan 2021 00:30:25 +0300

do not save msg with wrong repto

Diffstat:
Mii/db.go | 8++++++++
1 file changed, 8 insertions(+), 0 deletions(-)

diff --git a/ii/db.go b/ii/db.go @@ -683,6 +683,9 @@ func (db *DB) GetTopics(mi []*MsgInfo) map[string][]string { } var l []*MsgInfo for p := m; p != nil; p = db.LookupFast(p.Repto, false) { + if p.Repto == p.Id { // self answer? + break + } if m.Echo != p.Echo { continue } @@ -765,6 +768,11 @@ func (db *DB) _Store(m *Msg, edit bool) error { if _, ok := db.Idx.Hash[m.MsgId]; ok && !edit { // exist and not edit return errors.New("Already exists") } + if repto != "" { + if _, ok := db.Idx.Hash[repto]; !ok { // repto is absent, we should avoid loops! + return errors.New("Wrong repto") + } + } fi, err := os.Stat(db.BundlePath()) var off int64 if err == nil {