kha7iq / pingme

PingMe is a CLI which provides the ability to send messages or alerts to multiple messaging platforms & email.
https://pingme.lmno.pk
MIT License
771 stars 43 forks source link

strconv.Atoi: parsing "-1234567890123": value out of range #47

Closed brenkem closed 3 years ago

brenkem commented 3 years ago

Describe the bug Chat ID is producing error on ARM7L platform.

On x86 the function strconv.Atoi is working fine, but on a ARM platform with armv7l (Odroid XU4) the command pingme fails.

To Reproduce Steps to reproduce the behavior:

$ pingme telegram --token "124:abcd" --title "Message title" --msg "My message" --channel="-1234567890123"

Expected behavior

The expected behavior is that the chat id is used to ping a telegram channel.

Desktop (please complete the following information):

Additional context

The conversion of the string to an integer is working fine on a x86 desktop PC. It seems that the 32 bit ARM Platform can not handle such big numbers, while a 64 bit architecture can handle it.

Source: service/telegram/telegram.go chn := strings.Split(telegramOpts.Channel, ",") for _, v := range chn { if len(v) <= 0 { return helpers.ErrChannel } k, errStr := strconv.Atoi(v) if errStr != nil { return errStr } telegramSvc.AddReceivers(int64(k)) } [ Zeile 81/102 (79%)]

brenkem commented 3 years ago

This issue seems to be related to this: https://github.com/influxdata/telegraf/issues/1258

And the previous issue seems to solved by this: https://github.com/influxdata/telegraf/pull/1266

I implemented the recommended fix: see attached patch

I recompiled the code and tested it successfully. I will create a pull request.

0001-fix-string-convert.patch.zip

kha7iq commented 3 years ago

Thank you @brenkem for looking into this issue and opening a PR.