Skip to content

Commit

Permalink
fix: code integer parsing bit size (#1178)
Browse files Browse the repository at this point in the history
In some cases we had a wrong bitsize of `64`, while the var was later cast to `int`. Replaced with a bitsize of `0`, which is the value to cast to `int`.
  • Loading branch information
zepatrik authored Mar 29, 2021
1 parent 15ade1c commit 31e9632
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion courier/courier.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ type (
func NewSMTP(d smtpDependencies, c *config.Config) *Courier {
uri := c.CourierSMTPURL()
password, _ := uri.User.Password()
port, _ := strconv.ParseInt(uri.Port(), 10, 64)
port, _ := strconv.ParseInt(uri.Port(), 10, 0)

var ssl bool
var tlsConfig *tls.Config
Expand Down
8 changes: 4 additions & 4 deletions x/pagination.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,20 @@ func ParsePagination(r *http.Request) (page, itemsPerPage int) {
if offsetParam := r.URL.Query().Get("page"); offsetParam == "" {
page = 0
} else {
if offset64, err := strconv.ParseInt(offsetParam, 10, 64); err != nil {
if offset, err := strconv.ParseInt(offsetParam, 10, 0); err != nil {
page = 0
} else {
page = int(offset64)
page = int(offset)
}
}

if limitParam := r.URL.Query().Get("per_page"); limitParam == "" {
itemsPerPage = paginationDefaultItems
} else {
if limit64, err := strconv.ParseInt(limitParam, 10, 64); err != nil {
if limit, err := strconv.ParseInt(limitParam, 10, 0); err != nil {
itemsPerPage = paginationDefaultItems
} else {
itemsPerPage = int(limit64)
itemsPerPage = int(limit)
}
}

Expand Down

0 comments on commit 31e9632

Please sign in to comment.