Skip to content

Commit

Permalink
Merge pull request martijnvanbrummelen#634 from PartialVolume/Additio…
Browse files Browse the repository at this point in the history
…nal_fix_to_endian_code

Tidy up endian swap code
  • Loading branch information
PartialVolume authored Jan 2, 2025
2 parents 523ebc4 + 6e4ca14 commit 618a8d6
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/miscellaneous.c
Original file line number Diff line number Diff line change
Expand Up @@ -632,8 +632,7 @@ void fix_endian_model_names( char* model )
char* model_lower_case;
int swap_endian_flag = 0;

length = strlen( model ) + 1;
nwipe_log( NWIPE_LOG_INFO, " length = %i", length );
length = strlen( model );

tmp_string = calloc( length + 1, 1 );
model_lower_case = calloc( length + 1, 1 );
Expand All @@ -645,6 +644,7 @@ void fix_endian_model_names( char* model )
/* "ASSMNU G" = "SAMSUNG ", tested against model Samsung HM160HC so that
* "ASSMNU G MH61H0 C" becomes "SAMSUNG HM160HC ")
*/

if( !( strncmp( model_lower_case, "assmnu g", 8 ) ) )
{
swap_endian_flag = 1;
Expand Down Expand Up @@ -694,13 +694,16 @@ void fix_endian_model_names( char* model )
{
while( model[idx] != 0 && idx < length )
{
tmp_string[idx2 + 1] = model[idx];
if( model[idx + 1] != 0 )
{
/* Swap the bytes */
tmp_string[idx2 + 1] = model[idx];
tmp_string[idx2] = model[idx + 1];
}
else
{
/* Copy the last odd byte and exit while loop */
tmp_string[idx2] = model[idx];
break;
}

Expand Down

0 comments on commit 618a8d6

Please sign in to comment.