File tree Expand file tree Collapse file tree 2 files changed +32
-12
lines changed Expand file tree Collapse file tree 2 files changed +32
-12
lines changed Original file line number Diff line number Diff line change 1010
1111 #define BTK_VERSION_MAJOR 2
1212 #define BTK_VERSION_MINOR 0
13- #define BTK_VERSION_REVISION 1
13+ #define BTK_VERSION_REVISION 2
1414
1515 #endif
Original file line number Diff line number Diff line change @@ -229,25 +229,45 @@ int input_get_str(char** dest, char *prompt)
229229
230230int input_get_from_pipe (unsigned char * * dest )
231231{
232- int r ;
232+ int r , size = 0 , prev_size = 0 ;
233+ unsigned char * tmp ;
233234
234235 if (isatty (STDIN_FILENO ))
235236 {
236237 error_log ("Input data from a piped or redirected source is required." );
237238 return -1 ;
238239 }
239240
240- r = input_get (dest , NULL , INPUT_GET_MODE_ALL );
241- if (r < 0 )
242- {
243- error_log ("Could not get input." );
244- return -1 ;
245- }
246- if (r == 0 )
241+ while (input_available ())
247242 {
248- error_log ("No input provided." );
249- return -1 ;
243+ r = input_get (& tmp , NULL , INPUT_GET_MODE_ALL );
244+ if (r < 0 )
245+ {
246+ error_log ("Could not get input." );
247+ return -1 ;
248+ }
249+ if (r == 0 )
250+ {
251+ error_log ("No input provided." );
252+ return -1 ;
253+ }
254+
255+ size += r ;
256+
257+ (* dest ) = realloc ((* dest ), size );
258+ if ((* dest ) == NULL )
259+ {
260+ error_log ("Memory allocation error." );
261+ return -1 ;
262+ }
263+
264+ memcpy ((* dest ) + prev_size , tmp , r );
265+
266+ prev_size = size ;
267+
268+ free (tmp );
269+ tmp = NULL ;
250270 }
251271
252- return r ;
272+ return size ;
253273}
You can’t perform that action at this time.
0 commit comments