mirror of
https://github.com/kovidgoyal/kitty
synced 2026-06-06 01:05:48 +02:00
More CodeQL fixes
This commit is contained in:
@@ -81,8 +81,7 @@ func (self *if_panel) on_click(id string) (err error) {
|
||||
if scheme != "fval" {
|
||||
return
|
||||
}
|
||||
v, _ := strconv.ParseUint(val, 10, 64)
|
||||
|
||||
v, _ := strconv.ParseUint(val, 10, 0)
|
||||
if err = self.handler.face_pane.change_feature_value(self.feat_tag, uint(v), false); err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -143,7 +142,7 @@ func (self *if_panel) on_enter(family, which string, settings faces_settings, fe
|
||||
self.current_val = current_val
|
||||
self.rl.ResetText()
|
||||
if self.current_val > 0 {
|
||||
self.rl.SetText(strconv.Itoa(int(self.current_val)))
|
||||
self.rl.SetText(strconv.FormatUint(uint64(self.current_val), 10))
|
||||
}
|
||||
return self.handler.draw_screen()
|
||||
}
|
||||
|
||||
@@ -165,20 +165,20 @@ func main(cmd *cli.Command, o *Options, args []string) (rc int, err error) {
|
||||
return 1, fmt.Errorf("Invalid size specification: " + opts.UseWindowSize)
|
||||
}
|
||||
screen_size = &unix.Winsize{}
|
||||
t := 0
|
||||
if t, err = strconv.Atoi(parts[0]); err != nil || t < 1 {
|
||||
var t uint64
|
||||
if t, err = strconv.ParseUint(parts[0], 10, 16); err != nil || t < 1 {
|
||||
return 1, fmt.Errorf("Invalid size specification: %s with error: %w", opts.UseWindowSize, err)
|
||||
}
|
||||
screen_size.Col = uint16(t)
|
||||
if t, err = strconv.Atoi(parts[1]); err != nil || t < 1 {
|
||||
if t, err = strconv.ParseUint(parts[1], 10, 16); err != nil || t < 1 {
|
||||
return 1, fmt.Errorf("Invalid size specification: %s with error: %w", opts.UseWindowSize, err)
|
||||
}
|
||||
screen_size.Row = uint16(t)
|
||||
if t, err = strconv.Atoi(parts[2]); err != nil || t < 1 {
|
||||
if t, err = strconv.ParseUint(parts[2], 10, 16); err != nil || t < 1 {
|
||||
return 1, fmt.Errorf("Invalid size specification: %s with error: %w", opts.UseWindowSize, err)
|
||||
}
|
||||
screen_size.Xpixel = uint16(t)
|
||||
if t, err = strconv.Atoi(parts[3]); err != nil || t < 1 {
|
||||
if t, err = strconv.ParseUint(parts[3], 10, 16); err != nil || t < 1 {
|
||||
return 1, fmt.Errorf("Invalid size specification: %s with error: %w", opts.UseWindowSize, err)
|
||||
}
|
||||
screen_size.Ypixel = uint16(t)
|
||||
|
||||
@@ -14,6 +14,7 @@ import (
|
||||
"strconv"
|
||||
"strings"
|
||||
"unicode"
|
||||
"unicode/utf8"
|
||||
|
||||
"kitty/tools/cli"
|
||||
"kitty/tools/tty"
|
||||
@@ -71,8 +72,8 @@ func parse_favorites(raw string) (ans []rune) {
|
||||
line = line[:idx]
|
||||
}
|
||||
code_text, _, _ := strings.Cut(line, " ")
|
||||
code, err := strconv.ParseUint(code_text, 16, 32)
|
||||
if err == nil && codepoint_ok(rune(code)) {
|
||||
code, err := strconv.ParseInt(code_text, 16, 32)
|
||||
if err == nil && code <= utf8.MaxRune && codepoint_ok(rune(code)) {
|
||||
ans = append(ans, rune(code))
|
||||
}
|
||||
}
|
||||
@@ -209,7 +210,6 @@ func is_index(word string) bool {
|
||||
}
|
||||
|
||||
func (self *handler) update_codepoints() {
|
||||
var index_word uint64
|
||||
var q checkpoints_key
|
||||
q.mode = self.mode
|
||||
q.index_word = -1
|
||||
@@ -233,8 +233,9 @@ func (self *handler) update_codepoints() {
|
||||
if i > 0 && is_index(w) {
|
||||
iw := words[i]
|
||||
words = words[:i]
|
||||
index_word, _ = strconv.ParseUint(strings.TrimLeft(iw, INDEX_CHAR), INDEX_BASE, 32)
|
||||
q.index_word = int(index_word)
|
||||
if index_word, perr := strconv.ParseInt(strings.TrimLeft(iw, INDEX_CHAR), INDEX_BASE, 0); perr == nil {
|
||||
q.index_word = int(index_word)
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,8 +31,8 @@ func resolved_char(ch rune, emoji_variation string) string {
|
||||
}
|
||||
|
||||
func decode_hint(text string) int {
|
||||
x, err := strconv.ParseUint(text, INDEX_BASE, 32)
|
||||
if err != nil {
|
||||
x, err := strconv.ParseInt(text, INDEX_BASE, 0)
|
||||
if err != nil || x < 0 {
|
||||
return -1
|
||||
}
|
||||
return int(x)
|
||||
|
||||
@@ -432,7 +432,7 @@ func (self Patcher) Patch(path, sentinel, content string, settings_to_comment_ou
|
||||
|
||||
func ReloadConfigInKitty(in_parent_only bool) error {
|
||||
if in_parent_only {
|
||||
if pid, err := strconv.Atoi(os.Getenv("KITTY_PID")); err == nil {
|
||||
if pid, err := strconv.ParseInt(os.Getenv("KITTY_PID"), 10, 32); err == nil {
|
||||
if p, err := process.NewProcess(int32(pid)); err == nil {
|
||||
if exe, eerr := p.Exe(); eerr == nil {
|
||||
if c, err := p.CmdlineSlice(); err == nil && is_kitty_gui_cmdline(exe, c...) {
|
||||
@@ -451,7 +451,7 @@ func ReloadConfigInKitty(in_parent_only bool) error {
|
||||
for _, line := range utils.Splitlines(utils.UnsafeBytesToString(ps_out)) {
|
||||
line = strings.TrimSpace(line)
|
||||
if pid_string, argv0, found := strings.Cut(line, " "); found {
|
||||
if pid, err := strconv.Atoi(strings.TrimSpace(pid_string)); err == nil && strings.Contains(argv0, "kitty") {
|
||||
if pid, err := strconv.ParseInt(strings.TrimSpace(pid_string), 10, 32); err == nil && strings.Contains(argv0, "kitty") {
|
||||
if p, err := process.NewProcess(int32(pid)); err == nil {
|
||||
if cmdline, err := p.CmdlineSlice(); err == nil {
|
||||
if exe, err := p.Exe(); err == nil && is_kitty_gui_cmdline(exe, cmdline...) {
|
||||
|
||||
@@ -131,8 +131,8 @@ func Encrypt_cmd(cmd *utils.RemoteControlCmd, password string, other_pubkey []by
|
||||
}
|
||||
|
||||
func Encrypt_data(data []byte, other_pubkey []byte, encryption_protocol string) (ans []byte, err error) {
|
||||
d := make([]byte, 0, len(data)+32)
|
||||
d = append(d, []byte(fmt.Sprintf("%s:", strconv.FormatInt(time.Now().UnixNano(), 10)))...)
|
||||
d := make([]byte, 0, uint64(len(data))+32)
|
||||
d = fmt.Appendf(d, "%s:", strconv.FormatInt(time.Now().UnixNano(), 10))
|
||||
d = append(d, data...)
|
||||
iv, tag, ciphertext, pubkey, err := encrypt(d, other_pubkey, encryption_protocol)
|
||||
if err != nil {
|
||||
|
||||
@@ -115,11 +115,9 @@ func ISO8601Parse(raw string) (time.Time, error) {
|
||||
text = text[:9]
|
||||
}
|
||||
if text != "" {
|
||||
n, err := strconv.ParseUint(text, 10, 64)
|
||||
if err != nil {
|
||||
if nsec, err = strconv.ParseInt(text, 10, 64); err != nil {
|
||||
return errf("timestamp does not have a valid nanosecond field")
|
||||
}
|
||||
nsec = int64(n)
|
||||
for ; extra > 0; extra-- {
|
||||
nsec *= 10
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user