IRCaBot 2.1.0
GPLv3 © acetone, 2021-2022
#i2p-dev
/2024/11/17
@eyedeekay
&kytv
&zzz
+R4SAS
+RN
+StormyCloud
+T3s|4
+acetone
+dr|z3d
+hagen
+hk
+lbt
+postman
+weko
Arch
Danny
DeltaOreo
FreefallHeavens_
Irc2PGuest12249
Irc2PGuest25220
Irc2PGuest54664
Irc2PGuest59134
Irc2PGuest90091
Irc2PGuest90883
Irc2PGuest92478
Leopold_
Nausicaa
Onn4l7h
Onn4|7h
Sleepy
Soni
T3s|4_
Teeed
aeiou
aisle1
ardu
b3t4f4c3___
bak83_
boonst
defaultnick
dickless
dr4wd3_
enoxa
eyedeekay_bnc
foobar_
not_bob_afk
orignal_
phil
poriori
profetikla
qend-irc2p
radakayot_
rapidash
shiver_
solidx66
u5657
uop23ip
w8rabbit
wodencafe2
x74a6
hk If a length or data call is issued for an integer, should it attempt to recover by correcting it or return an error?
hk thank you
zzz huh?
orignal I assume he is asking what we do with messages with invalid lenght
orignal like too long or too short
hk zzz: sorry I mispoke, it's in regards to I2PStrings, not integers my bad
dr|z3d if go's anything like java, you may need null checks.
hk but the same principle applies, not messages sorry. If you create an i2p string programatically and the length is invalid, should it attempt to trim the data in attempt to recover and/or return an error
hk hm
dr|z3d if (string.length() > 10) {string = string.substring(0,7) + "...";}
hk nuyeah I see what you mean, whether to do that or return an error essentially
hk yeah*
dr|z3d depends on context, what you're doing.
dr|z3d maybe > 10 is invalid, then you'd want to drop it and print an error.
hk func (str I2PString) Data() (data string, err error) {
hk length, err := str.Length()
hk if err != nil {
hk switch err {
hk case ErrDataTooLong:
hk log.WithError(err).Warn("I2PString contains data beyond specified length")
hk data = string(str[1:])
hk //data = string(str[1 : length+1]) // Should we recover and trim?
hk return
zzz how would you know if what comes after is 'extra' or just the next field in the data structure?
zzz a: you don't
zzz the string tells you how long it is, it can't be "wrong"
hk understood
orignal really? first byte says 255 while length of remianing buffer is 100
orignal you must alway check this
zzz well you can never tell if 'too short' unless last item in the structure.
zzz sure it could be too long but presumably you have protection for that, that's not unique to strings, any field could be longer than what's remaining
zzz but no, you never try to "recover" by correcting something invalid
hk got it got it
zzz but doesn't Go do bounds checks on byte arrays so you can't overrun them, just like Java? eyedeekay?
zzz if so, I assume the best practice is to NOT explicitly check for overrun, let the panic equivalent of AIOOBE get thrown, and catch it higher up
zzz but that's up to you guys to come up with and adhere to a coding style
hk AIOOBE?