Skip to content

Commit

Permalink
fix: int64 cast overflow on 32bit systems
Browse files Browse the repository at this point in the history
  • Loading branch information
Davincible committed Aug 14, 2022
1 parent d43e9d0 commit fbb6894
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 13 deletions.
2 changes: 1 addition & 1 deletion account.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ func (account *Account) Sync() error {
func (account *Account) ChangePassword(old, new_ string) error {
insta := account.insta

timestamp := strconv.Itoa(int(time.Now().Unix()))
timestamp := strconv.FormatInt(time.Now().Unix(), 10)
old, err := utilities.EncryptPassword(old, insta.pubKey, insta.pubKeyID, timestamp)
if err != nil {
return err
Expand Down
4 changes: 2 additions & 2 deletions broadcasts.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ func (br *Broadcast) GetComments() (*BroadcastComments, error) {
&reqOptions{
Endpoint: fmt.Sprintf(urlLiveComments, br.ID),
Query: map[string]string{
"last_comment_ts": strconv.Itoa(int(br.LastCommentTs)),
"last_comment_ts": strconv.FormatInt(br.LastCommentTs, 10),
"join_request_last_seen_ts": "0",
"join_request_last_fetch_ts": "0",
"join_request_last_total_count": "0",
Expand Down Expand Up @@ -228,7 +228,7 @@ func (br *Broadcast) GetLikes() (*BroadcastLikes, error) {
&reqOptions{
Endpoint: fmt.Sprintf(urlLiveLikeCount, br.ID),
Query: map[string]string{
"like_ts": strconv.Itoa(int(br.LastLikeTs)),
"like_ts": strconv.FormatInt(br.LastLikeTs, 10),
},
})
if err != nil {
Expand Down
8 changes: 4 additions & 4 deletions goinsta.go
Original file line number Diff line number Diff line change
Expand Up @@ -744,10 +744,10 @@ func (insta *Instagram) OpenApp() (err error) {
}

func (insta *Instagram) login() error {
timestamp := strconv.Itoa(int(time.Now().Unix()))
timestamp := strconv.FormatInt(time.Now().Unix(), 10)
if insta.pubKey == "" || insta.pubKeyID == -1 {
return errors.New(
"No public key or public key ID set. Please call Instagram.Sync() and verify that it works correctly",
"no public key or public key ID set. Please call Instagram.Sync() and verify that it works correctly",
)
}
encrypted, err := utilities.EncryptPassword(insta.pass, insta.pubKey, insta.pubKeyID, timestamp)
Expand Down Expand Up @@ -1025,7 +1025,7 @@ func (insta *Instagram) callNotifBadge() error {
IsPost: true,
Query: map[string]string{
"phone_id": insta.fID,
"user_ids": strconv.Itoa(int(insta.Account.ID)),
"user_ids": strconv.FormatInt(insta.Account.ID, 10),
"device_id": insta.uuid,
"_uuid": insta.uuid,
},
Expand All @@ -1037,7 +1037,7 @@ func (insta *Instagram) callNotifBadge() error {
func (insta *Instagram) callContPointSig() error {
query := map[string]string{
"phone_id": insta.fID,
"_uid": strconv.Itoa(int(insta.Account.ID)),
"_uid": strconv.FormatInt(insta.Account.ID, 10),
"device_id": insta.uuid,
"_uuid": insta.uuid,
"google_tokens": "[]",
Expand Down
2 changes: 1 addition & 1 deletion request.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ func (insta *Instagram) sendRequest(o *reqOptions) (body []byte, h http.Header,
}

if o.Timestamp == "" {
o.Timestamp = strconv.Itoa(int(time.Now().Unix()))
o.Timestamp = strconv.FormatInt(time.Now().Unix(), 10)
}

var nu string
Expand Down
10 changes: 7 additions & 3 deletions users.go
Original file line number Diff line number Diff line change
Expand Up @@ -378,8 +378,8 @@ func (user *User) Block(autoBlock bool) error {
data, err := json.Marshal(map[string]string{
"surface": "profile",
"is_autoblock_enabled": strconv.FormatBool(autoBlock),
"user_id": strconv.Itoa(int(user.ID)),
"_uid": strconv.Itoa(int(insta.Account.ID)),
"user_id": strconv.FormatInt(user.ID, 10),
"_uid": strconv.FormatInt(insta.Account.ID, 10),
"_uuid": insta.uuid,
})
if err != nil {
Expand Down Expand Up @@ -627,9 +627,13 @@ func (user *User) GetFeaturedAccounts() ([]*User, error) {
body, _, err := user.insta.sendRequest(&reqOptions{
Endpoint: urlFeaturedAccounts,
Query: map[string]string{
"target_user_id": strconv.Itoa(int(user.ID)),
"target_user_id": strconv.FormatInt(user.ID, 10),
},
})
if err != nil {
return nil, err
}

d := struct {
Accounts []*User `json:"accounts"`
Status string `json:"status"`
Expand Down
2 changes: 1 addition & 1 deletion utilities/encryption.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func RSAPublicKeyPKCS1Encrypt(publicKey *rsa.PublicKey, data []byte) ([]byte, er

func EncryptPassword(password, pubKeyEncoded string, pubKeyVersion int, t string) (string, error) {
if t == "" {
t = strconv.Itoa(int(time.Now().Unix()))
t = strconv.FormatInt(time.Now().Unix(), 10)
}

// Get the public key
Expand Down
2 changes: 1 addition & 1 deletion utilities/totp.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func genHOTP(secret string, interval int64) (string, error) {
// Ignore most significant bits as per RFC 4226, and crop to 6 digits.
h12 := (int(header) & 0x7fffffff) % 1000000

otp := strconv.Itoa(int(h12))
otp := strconv.Itoa(h12)
otp = prefix(otp)

return otp, nil
Expand Down

0 comments on commit fbb6894

Please sign in to comment.