@@ -202,32 +202,21 @@ nc_read_chunk(struct nc_session *session, size_t len, uint32_t inact_timeout, st
202202}
203203
204204static ssize_t
205- nc_read_until (struct nc_session * session , const char * endtag , size_t limit , uint32_t inact_timeout ,
206- struct timespec * ts_act_timeout , char * * result )
205+ nc_read_until (struct nc_session * session , const char * endtag , uint32_t inact_timeout , struct timespec * ts_act_timeout ,
206+ char * * result )
207207{
208208 char * chunk = NULL ;
209209 size_t size , count = 0 , r , len , i , matched = 0 ;
210210
211211 assert (session );
212212 assert (endtag );
213213
214- if (limit && (limit < BUFFERSIZE )) {
215- size = limit ;
216- } else {
217- size = BUFFERSIZE ;
218- }
214+ size = BUFFERSIZE ;
219215 chunk = malloc ((size + 1 ) * sizeof * chunk );
220216 NC_CHECK_ERRMEM_RET (!chunk , -1 );
221217
222218 len = strlen (endtag );
223219 while (1 ) {
224- if (limit && (count == limit )) {
225- free (chunk );
226- WRN (session , "Reading limit (%d) reached." , limit );
227- ERR (session , "Invalid input data (missing \"%s\" sequence)." , endtag );
228- return -1 ;
229- }
230-
231220 /* resize buffer if needed */
232221 if ((count + (len - matched )) >= size ) {
233222 /* get more memory */
@@ -305,7 +294,7 @@ nc_read_msg_io(struct nc_session *session, int io_timeout, struct ly_in **msg, i
305294 /* read the message */
306295 switch (session -> version ) {
307296 case NC_VERSION_10 :
308- r = nc_read_until (session , NC_VERSION_10_ENDTAG , 0 , inact_timeout , & ts_act_timeout , & data );
297+ r = nc_read_until (session , NC_VERSION_10_ENDTAG , inact_timeout , & ts_act_timeout , & data );
309298 if (r == -1 ) {
310299 ret = r ;
311300 goto cleanup ;
@@ -316,12 +305,12 @@ nc_read_msg_io(struct nc_session *session, int io_timeout, struct ly_in **msg, i
316305 break ;
317306 case NC_VERSION_11 :
318307 while (1 ) {
319- r = nc_read_until (session , "\n#" , 0 , inact_timeout , & ts_act_timeout , NULL );
308+ r = nc_read_until (session , "\n#" , inact_timeout , & ts_act_timeout , NULL );
320309 if (r == -1 ) {
321310 ret = r ;
322311 goto cleanup ;
323312 }
324- r = nc_read_until (session , "\n" , 0 , inact_timeout , & ts_act_timeout , & chunk );
313+ r = nc_read_until (session , "\n" , inact_timeout , & ts_act_timeout , & chunk );
325314 if (r == -1 ) {
326315 ret = r ;
327316 goto cleanup ;
0 commit comments