File tree Expand file tree Collapse file tree 2 files changed +4
-4
lines changed Expand file tree Collapse file tree 2 files changed +4
-4
lines changed Original file line number Diff line number Diff line change @@ -124,7 +124,7 @@ void bignum_from_string(_Ptr<struct bn> n, _Nt_array_ptr<char> str : count(nbyte
124124}
125125
126126
127- void bignum_to_string (_Ptr < struct bn > n , char * str : itype ( _Array_ptr < char > ) count (nbytes ), int nbytes )
127+ void bignum_to_string (_Ptr < struct bn > n , _Nt_array_ptr < char > str : count (nbytes ), int nbytes )
128128{
129129 require (n , "n is null" );
130130 require (str , "str is null" );
@@ -135,9 +135,9 @@ void bignum_to_string(_Ptr<struct bn> n, char *str : itype(_Array_ptr<char>) cou
135135 int i = 0 ; /* index into string representation. */
136136
137137 /* reading last array-element "MSB" first -> big endian */
138- while ((j >= 0 ) && (nbytes > ( i + 1 ) ))
138+ while ((j >= 0 ) && (nbytes >= i + 2 * WORD_SIZE ))
139139 {
140- sprintf (& str [i ], SPRINTF_FORMAT_STR , n -> array [j ]);
140+ snprintf (& str [i ], nbytes - i + 1 , SPRINTF_FORMAT_STR , n -> array [j ]);
141141 i += (2 * WORD_SIZE ); /* step WORD_SIZE hex-byte(s) forward in the string. */
142142 j -= 1 ; /* step one element back in the array. */
143143 }
Original file line number Diff line number Diff line change @@ -91,7 +91,7 @@ void bignum_init(_Ptr<struct bn> n);
9191void bignum_from_int (_Ptr < struct bn > n , DTYPE_TMP i );
9292int bignum_to_int (_Ptr < struct bn > n );
9393void bignum_from_string (_Ptr < struct bn > n , _Nt_array_ptr < char > str : count (nbytes ), int nbytes );
94- void bignum_to_string (_Ptr < struct bn > n , char * str : itype ( _Array_ptr < char > ) count (maxsize ), int maxsize );
94+ void bignum_to_string (_Ptr < struct bn > n , _Nt_array_ptr < char > str : count (maxsize ), int maxsize );
9595
9696/* Basic arithmetic operations: */
9797void bignum_add (_Ptr < struct bn > a , _Ptr < struct bn > b , _Ptr < struct bn > c ); /* c = a + b */
You can’t perform that action at this time.
0 commit comments