More CodeQL fixes

This commit is contained in:
Kovid Goyal
2025-04-20 22:13:45 +05:30
parent 237bb35ee9
commit 341df0dccb
7 changed files with 20 additions and 22 deletions

View File

@@ -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...) {

View File

@@ -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 {

View File

@@ -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
}