3 Commits

3 changed files with 17 additions and 23 deletions
+1 -3
View File
@@ -16,9 +16,7 @@
8. Add tests for untested commands. 8. Add tests for untested commands.
9. Consider getting rid of color global. 9. Audit ssh.odin for places where `#no_bounds_check` would be appropriate.
10. `write_flags_table` should never return false.
## Double-check AI output ## Double-check AI output
+6 -10
View File
@@ -206,10 +206,9 @@ write_command_help :: proc(name: string, w: io.Writer) -> bool {
tbl: table.Table tbl: table.Table
table.init(&tbl, context.temp_allocator, context.temp_allocator) table.init(&tbl, context.temp_allocator, context.temp_allocator)
table.padding(&tbl, 2, 0) table.padding(&tbl, 2, 0)
if write_flags_table(&tbl, info.flags) { write_flags_table(&tbl, info.flags)
fmt.wprintf(w, "\n", flush = false) fmt.wprintf(w, "\n", flush = false)
write_borderless_table(w, &tbl) write_borderless_table(w, &tbl)
}
table_reset(&tbl) table_reset(&tbl)
return true return true
} }
@@ -267,8 +266,7 @@ flag_field_info :: proc(
return return
} }
write_flags_table :: proc(tbl: ^table.Table, flags: bit_set[Flag_Type]) -> (has_rows: bool) { write_flags_table :: proc(tbl: ^table.Table, flags: bit_set[Flag_Type]) {
if flags == {} do return false
table.caption(tbl, "Flags:") table.caption(tbl, "Flags:")
for ft in Flag_Type { for ft in Flag_Type {
if ft not_in flags do continue if ft not_in flags do continue
@@ -285,7 +283,6 @@ write_flags_table :: proc(tbl: ^table.Table, flags: bit_set[Flag_Type]) -> (has_
table.row(tbl, colorize(.Flag, names, tbl.format_allocator), desc) table.row(tbl, colorize(.Flag, names, tbl.format_allocator), desc)
} }
} }
return true
} }
find_command :: proc(name: string) -> (CommandInfo, bool) { find_command :: proc(name: string) -> (CommandInfo, bool) {
@@ -365,9 +362,8 @@ at before, restore your backup with:
write_borderless_table(w, &tbl) write_borderless_table(w, &tbl)
table_reset(&tbl) table_reset(&tbl)
if write_flags_table(&tbl, GLOBAL_FLAGS) { write_flags_table(&tbl, GLOBAL_FLAGS)
write_borderless_table(w, &tbl) write_borderless_table(w, &tbl)
}
table_reset(&tbl) table_reset(&tbl)
fmt.wprintf( fmt.wprintf(
+10 -10
View File
@@ -35,13 +35,13 @@ parse_ssh_public_key :: proc(pub_path: string) -> (pub: [32]u8, ok: bool) {
return return
} }
buf := decoded rest := decoded
key_type, type_ok := read_wire_string(&buf) key_type, type_ok := read_wire_string(&rest)
if !type_ok || string(key_type) != SSH_ED25519 { if !type_ok || string(key_type) != SSH_ED25519 {
return return
} }
pk_data, pk_ok := read_wire_string(&buf) pk_data, pk_ok := read_wire_string(&rest)
if !pk_ok || len(pk_data) != 32 { if !pk_ok || len(pk_data) != 32 {
return return
} }
@@ -91,34 +91,34 @@ parse_ssh_private_key :: proc(priv_path: string) -> (kp: Ed25519Keypair, ok: boo
return return
} }
buf := decoded[len(magic):] rest := decoded[len(magic):]
ciphername, cipher_ok := read_wire_string(&buf) ciphername, cipher_ok := read_wire_string(&rest)
if !cipher_ok || string(ciphername) != "none" { if !cipher_ok || string(ciphername) != "none" {
return return
} }
kdfname, kdf_ok := read_wire_string(&buf) kdfname, kdf_ok := read_wire_string(&rest)
if !kdf_ok || string(kdfname) != "none" { if !kdf_ok || string(kdfname) != "none" {
return return
} }
_, opts_ok := read_wire_string(&buf) _, opts_ok := read_wire_string(&rest)
if !opts_ok { if !opts_ok {
return return
} }
num_keys, nkeys_ok := read_wire_u32(&buf) num_keys, nkeys_ok := read_wire_u32(&rest)
if !nkeys_ok || num_keys != 1 { if !nkeys_ok || num_keys != 1 {
return return
} }
_, pub_blob_ok := read_wire_string(&buf) _, pub_blob_ok := read_wire_string(&rest)
if !pub_blob_ok { if !pub_blob_ok {
return return
} }
priv_blob, priv_blob_ok := read_wire_string(&buf) priv_blob, priv_blob_ok := read_wire_string(&rest)
if !priv_blob_ok { if !priv_blob_ok {
return return
} }