You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
But how would one cleanly unmarshal it? You can't just unmarshal it into a slice or a struct so the only way I can think of is slicing the modelist into groups of the length of a single key value pair (5, but you'd have to know that before) and then individually marshalling each of those slices into their own structures. That's what I'm doing now and it works, but it's extremely janky because you need to know the length of a single key value pair preemptively.
Is there any better way to do it?
The text was updated successfully, but these errors were encountered:
dmitshur
changed the title
/x/crypto/ssh: how do you parse the modelist of a ptyRequestMsg?
x/crypto/ssh: how do you parse the modelist of a ptyRequestMsg?
Sep 6, 2017
// pretend modelist is the slice of bytes of the modelist.varmodelist []bytetypemodestruct {
KeybyteValuint32
}
varmmodevarlenMode=binary.Size(m)
// > and not >= because if it is equal, the modelist is malformed because there needs to be a null terminator.forlen(modelist) >lenMode {
err:=ssh.Unmarshal(modelist[:lenMode], &m)
iferr!=nil {
panic(err)
}
println(m.Key)
println(m.Val)
println("====")
modelist=modelist[lenMode:]
}
This is how the modelist is marshalled https://github.com/golang/crypto/blob/81e90905daefcd6fd217b62423c0908922eadb30/ssh/session.go#L192-L199
But how would one cleanly unmarshal it? You can't just unmarshal it into a slice or a struct so the only way I can think of is slicing the modelist into groups of the length of a single key value pair (5, but you'd have to know that before) and then individually marshalling each of those slices into their own structures. That's what I'm doing now and it works, but it's extremely janky because you need to know the length of a single key value pair preemptively.
Is there any better way to do it?
The text was updated successfully, but these errors were encountered: