Skip to content

Commit

Permalink
Move variable declaration to beginning of block
Browse files Browse the repository at this point in the history
  • Loading branch information
plusvic committed May 22, 2017
1 parent 944afa1 commit 0dfe1e8
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions libyara/modules/pe.c
Original file line number Diff line number Diff line change
Expand Up @@ -1205,6 +1205,9 @@ void pe_parse_certificates(

if (serial_der != NULL)
{
unsigned char* serial_bytes;
char *serial_ascii;

bytes = i2d_ASN1_INTEGER(serial, &serial_der);

// i2d_ASN1_INTEGER() moves the pointer as it writes into
Expand All @@ -1213,7 +1216,7 @@ void pe_parse_certificates(
serial_der -= bytes;

// Skip over DER type, length information
unsigned char* serial_bytes = serial_der + 2;
serial_bytes = serial_der + 2;
bytes -= 2;

// Also allocate space to hold the "common" string format:
Expand All @@ -1224,7 +1227,7 @@ void pe_parse_certificates(
// The last one doesn't have the colon, but the extra byte is used
// for the NULL terminator.

char *serial_ascii = (char*) yr_malloc(bytes * 3);
serial_ascii = (char*) yr_malloc(bytes * 3);

if (serial_ascii)
{
Expand All @@ -1235,14 +1238,14 @@ void pe_parse_certificates(
// Don't put the colon on the last one.
if (j < bytes - 1)
snprintf(
(char*) serial_ascii + 3 * j, 4, "%02x:", serial_bytes[j]);
serial_ascii + 3 * j, 4, "%02x:", serial_bytes[j]);
else
snprintf(
(char*) serial_ascii + 3 * j, 3, "%02x", serial_bytes[j]);
serial_ascii + 3 * j, 3, "%02x", serial_bytes[j]);
}

set_string(
(char*) serial_ascii,
serial_ascii,
pe->object,
"signatures[%i].serial",
counter);
Expand Down

0 comments on commit 0dfe1e8

Please sign in to comment.