Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not enough byte to read from buffer #112

Closed
solaim opened this issue Sep 15, 2023 · 5 comments
Closed

Not enough byte to read from buffer #112

solaim opened this issue Sep 15, 2023 · 5 comments

Comments

@solaim
Copy link

solaim commented Sep 15, 2023

If CommandStatus not ESME_ROK, error: Not enough byte to read from buffer. And at server error occurred on connection[::1]:62893, connection reset by peer\n

same issue list

https://github.com/linxGnu/gosmpp/issues/106
https://github.com/linxGnu/gosmpp/pull/78
@linxGnu
Copy link
Owner

linxGnu commented Sep 15, 2023

@solaim please try to enable enquire_link. This way, connection are kept alive.

@solaim
Copy link
Author

solaim commented Sep 15, 2023

I try to dig code:

type SubmitSMResp struct {
	base
	MessageID string
}
// Marshal implements PDU interface.
func (c *SubmitSMResp) Marshal(b *ByteBuffer) {
	c.base.marshal(b, func(b *ByteBuffer) {
		b.Grow(len(c.MessageID) + 1)

		_ = b.WriteCString(c.MessageID)
	})
}
// Unmarshal implements PDU interface.
func (c *SubmitSMResp) Unmarshal(b *ByteBuffer) error {
	return c.base.unmarshal(b, func(b *ByteBuffer) (err error) {
		if c.CommandStatus == data.ESME_ROK {
			c.MessageID, err = b.ReadCString()
		}
		return
	})
}

what will happen when CommandStatus not ESME_ROK, MessageID is empty string, but In Marshal function, just

b.Grow(len(c.MessageID) + 1)

_ = b.WriteCString(c.MessageID)

maybe this is more better:

if len(c.MessageID) > 0 {
      b.Grow(len(c.MessageID) + 1)

      _ = b.WriteCString(c.MessageID)
}

@linxGnu
Copy link
Owner

linxGnu commented Sep 15, 2023

@solaim good finding, I am making a fix here: #113
PTAL

@solaim
Copy link
Author

solaim commented Sep 18, 2023

LGTM

@linxGnu
Copy link
Owner

linxGnu commented Sep 18, 2023

@solaim Thank you so much. I released a new version which includes above PR.

Please feel free to close this issue.

@solaim solaim closed this as completed Sep 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants