File tree Expand file tree Collapse file tree 1 file changed +6
-14
lines changed
Expand file tree Collapse file tree 1 file changed +6
-14
lines changed Original file line number Diff line number Diff line change @@ -734,23 +734,15 @@ static int read_from_file(UTIL_CTX *ctx,
734734 return 0 ;
735735 }
736736 if (BIO_gets (fp , txt , (int )* field_len + 1 ) > 0 ) {
737- * field_len = strlen (txt );
737+ size_t len = strlen (txt );
738+
739+ while (len > 0 && (txt [len - 1 ] == '\n' || txt [len - 1 ] == '\r' ))
740+ len -- ;
741+ memcpy (field , txt , len );
742+ * field_len = len ;
738743 } else {
739744 * field_len = 0 ;
740- goto done ;
741- }
742-
743- /* files may contain trailing newlines, remove them */
744- while (* field_len > 0 ) {
745- if (txt [* field_len - 1 ] == '\n' || txt [* field_len - 1 ] == '\r' ) {
746- (* field_len )-- ;
747- } else {
748- break ;
749- }
750745 }
751- memcpy (field , txt , * field_len );
752-
753- done :
754746 OPENSSL_free (txt );
755747
756748 BIO_free (fp );
You can’t perform that action at this time.
0 commit comments