diff --git a/hyptop/dg_debugfs_lpar.c b/hyptop/dg_debugfs_lpar.c index b63b9ec5..a675bf9d 100644 --- a/hyptop/dg_debugfs_lpar.c +++ b/hyptop/dg_debugfs_lpar.c @@ -55,8 +55,7 @@ struct l_x_sys_hdr { static inline void l_sys_hdr__sys_name(struct l_x_sys_hdr *hdr, char *name) { - memcpy(name, hdr->sys_name, LPAR_NAME_LEN); - ht_ebcdic_to_ascii(name, LPAR_NAME_LEN); + ht_ebcdic_to_ascii(hdr->sys_name, name, LPAR_NAME_LEN); name[LPAR_NAME_LEN] = 0; ht_strstrip(name); } diff --git a/hyptop/dg_debugfs_vm.c b/hyptop/dg_debugfs_vm.c index 669ddc9f..67235c3c 100644 --- a/hyptop/dg_debugfs_vm.c +++ b/hyptop/dg_debugfs_vm.c @@ -245,8 +245,7 @@ static void l_sd_sys_root_fill(struct sd_sys *sys) struct sd_sys *guest; guest_name[NAME_LEN] = 0; - memcpy(guest_name, data->guest_name, NAME_LEN); - ht_ebcdic_to_ascii(guest_name, NAME_LEN); + ht_ebcdic_to_ascii(data->guest_name, guest_name, NAME_LEN); ht_strstrip(guest_name); guest = sd_sys_get(sys, guest_name); diff --git a/hyptop/helper.c b/hyptop/helper.c index 9d5f7eda..7fb70ffe 100644 --- a/hyptop/helper.c +++ b/hyptop/helper.c @@ -98,9 +98,15 @@ void *ht_realloc(void *old_ptr, size_t size) /* * Convert EBCDIC string to ASCII */ -void ht_ebcdic_to_ascii(char *inout, size_t len) +void ht_ebcdic_to_ascii(char *in, char *out, size_t size) { - iconv(l_iconv_ebcdic_ascii, &inout, &len, &inout, &len); + size_t size_out = size; + size_t size_in = size; + size_t rc; + + rc = iconv(l_iconv_ebcdic_ascii, &in, &size_in, &out, &size_out); + if (rc == (size_t) -1) + ERR_EXIT_ERRNO("Code page translation EBCDIC-ASCII failed"); } /* diff --git a/hyptop/helper.h b/hyptop/helper.h index 2d304789..205b48f2 100644 --- a/hyptop/helper.h +++ b/hyptop/helper.h @@ -30,7 +30,7 @@ extern char *ht_strstrip(char *str); extern char *ht_strdup(const char *str); extern void ht_print_head(const char *sys); extern void ht_print_help_icon(void); -extern void ht_ebcdic_to_ascii(char *inout, size_t len); +extern void ht_ebcdic_to_ascii(char *in, char *out, size_t len); extern char *ht_mount_point_get(const char *fs_type); extern u64 ht_ext_tod_2_us(void *tod_ext); extern void ht_print_time(void);