@@ -102,6 +102,7 @@ struct tty3270 {
102
102
103
103
/* Input stuff. */
104
104
char * prompt ; /* Output string for input area. */
105
+ size_t prompt_sz ; /* Size of output string. */
105
106
char * input ; /* Input string for read request. */
106
107
struct raw3270_request * read ; /* Single read request. */
107
108
struct raw3270_request * kreset ; /* Single keyboard reset request. */
@@ -206,7 +207,7 @@ static int tty3270_input_size(int cols)
206
207
207
208
static void tty3270_update_prompt (struct tty3270 * tp , char * input )
208
209
{
209
- strcpy (tp -> prompt , input );
210
+ strscpy (tp -> prompt , input , tp -> prompt_sz );
210
211
tp -> update_flags |= TTY_UPDATE_INPUT ;
211
212
tty3270_set_timer (tp , 1 );
212
213
}
@@ -971,6 +972,7 @@ static void tty3270_resize(struct raw3270_view *view,
971
972
char * old_input , * new_input ;
972
973
struct tty_struct * tty ;
973
974
struct winsize ws ;
975
+ size_t prompt_sz ;
974
976
int new_allocated , old_allocated = tp -> allocated_lines ;
975
977
976
978
if (old_model == new_model &&
@@ -982,10 +984,11 @@ static void tty3270_resize(struct raw3270_view *view,
982
984
return ;
983
985
}
984
986
985
- new_input = kzalloc (tty3270_input_size (new_cols ), GFP_KERNEL | GFP_DMA );
987
+ prompt_sz = tty3270_input_size (new_cols );
988
+ new_input = kzalloc (prompt_sz , GFP_KERNEL | GFP_DMA );
986
989
if (!new_input )
987
990
return ;
988
- new_prompt = kzalloc (tty3270_input_size ( new_cols ) , GFP_KERNEL );
991
+ new_prompt = kzalloc (prompt_sz , GFP_KERNEL );
989
992
if (!new_prompt )
990
993
goto out_input ;
991
994
screen = tty3270_alloc_screen (tp , new_rows , new_cols , & new_allocated );
@@ -1010,6 +1013,7 @@ static void tty3270_resize(struct raw3270_view *view,
1010
1013
old_rcl_lines = tp -> rcl_lines ;
1011
1014
tp -> input = new_input ;
1012
1015
tp -> prompt = new_prompt ;
1016
+ tp -> prompt_sz = prompt_sz ;
1013
1017
tp -> rcl_lines = new_rcl_lines ;
1014
1018
tp -> rcl_read_index = 0 ;
1015
1019
tp -> rcl_write_index = 0 ;
@@ -1096,6 +1100,7 @@ static int
1096
1100
tty3270_create_view (int index , struct tty3270 * * newtp )
1097
1101
{
1098
1102
struct tty3270 * tp ;
1103
+ size_t prompt_sz ;
1099
1104
int rc ;
1100
1105
1101
1106
if (tty3270_max_index < index + 1 )
@@ -1125,17 +1130,19 @@ tty3270_create_view(int index, struct tty3270 **newtp)
1125
1130
goto out_free_screen ;
1126
1131
}
1127
1132
1128
- tp -> input = kzalloc (tty3270_input_size (tp -> view .cols ), GFP_KERNEL | GFP_DMA );
1133
+ prompt_sz = tty3270_input_size (tp -> view .cols );
1134
+ tp -> input = kzalloc (prompt_sz , GFP_KERNEL | GFP_DMA );
1129
1135
if (!tp -> input ) {
1130
1136
rc = - ENOMEM ;
1131
1137
goto out_free_converted_line ;
1132
1138
}
1133
1139
1134
- tp -> prompt = kzalloc (tty3270_input_size ( tp -> view . cols ) , GFP_KERNEL );
1140
+ tp -> prompt = kzalloc (prompt_sz , GFP_KERNEL );
1135
1141
if (!tp -> prompt ) {
1136
1142
rc = - ENOMEM ;
1137
1143
goto out_free_input ;
1138
1144
}
1145
+ tp -> prompt_sz = prompt_sz ;
1139
1146
1140
1147
tp -> rcl_lines = tty3270_alloc_recall (tp -> view .cols );
1141
1148
if (!tp -> rcl_lines ) {
0 commit comments