Skip to content

Commit

Permalink
Format: Fixing space indent when there is no signature.
Browse files Browse the repository at this point in the history
Incorporating feedback from Bu11etmagnet related to checking is an unsigned size_t is negative.
  • Loading branch information
Neal Krawetz committed Nov 6, 2024
1 parent 872b90c commit b3aadc5
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/format-isobmff.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ sealfield * Seal_BMFF (sealfield *Args, mmapfile *Mmap)
Args = Seal_BMFFsign(Args,Mmap); // Add a signature as needed
if (SealGetIindex(Args,"@s",2)==0) // no signatures
{
printf("No SEAL signatures found.\n");
printf(" No SEAL signatures found.\n");
}

return(Args);
Expand Down
2 changes: 1 addition & 1 deletion src/format-jpeg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -721,7 +721,7 @@ sealfield * Seal_JPEG (sealfield *Args, mmapfile *Mmap)
Args = Seal_JPEGsign(Args,Mmap,FFDAoffset, (PreviousBlockType == 0xffe8) ? 0xffe9 : 0xffe8);
if (SealGetIindex(Args,"@s",2)==0) // no signatures
{
printf("No SEAL signatures found.\n");
printf(" No SEAL signatures found.\n");
}

return(Args);
Expand Down
2 changes: 1 addition & 1 deletion src/format-matroska.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ sealfield * Seal_Matroska (sealfield *Args, mmapfile *Mmap)
Args = Seal_Matroskasign(Args,Mmap); // Add a signature as needed
if (SealGetIindex(Args,"@s",2)==0) // no signatures
{
printf("No SEAL signatures found.\n");
printf(" No SEAL signatures found.\n");
}

return(Args);
Expand Down
2 changes: 1 addition & 1 deletion src/format-png.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ sealfield * Seal_PNG (sealfield *Args, mmapfile *Mmap)
Args = Seal_PNGsign(Args,Mmap,IEND_offset); // Add a signature as needed
if (SealGetIindex(Args,"@s",2)==0) // no signatures
{
printf("No SEAL signatures found.\n");
printf(" No SEAL signatures found.\n");
}

return(Args);
Expand Down
2 changes: 1 addition & 1 deletion src/format-riff.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ sealfield * Seal_RIFF (sealfield *Args, mmapfile *Mmap)
Args = Seal_RIFFsign(Args,Mmap); // Add a signature as needed
if (SealGetIindex(Args,"@s",2)==0) // no signatures
{
printf("No SEAL signatures found.\n");
printf(" No SEAL signatures found.\n");
}

return(Args);
Expand Down
13 changes: 7 additions & 6 deletions src/seal-parse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ void SealStrEncode (sealfield *Data)
// Count amount of new space required
for(i=j=0; i < Data->ValueLen; i++,j++)
{
if (strchr("'\"",Data->Value[i])) { j++; }
if (strchr("'\"\\",Data->Value[i])) { j++; }
}

// i=string length, j=new string length
Expand All @@ -78,14 +78,15 @@ void SealStrEncode (sealfield *Data)
Data->Value = (byte*)realloc(Data->Value,Data->ValueLen+4);
memset(Data->Value+i,0,j-i+4); // clear new memory
// Now copy over all new characters
i--; j--; // Start at the last character
while((i >= 0) && (j > i))
// Start at the last character
// NOTE: Can't check if (i >= 0) since size_t is unsigned; always true.
while((i > 0) && (j > i))
{
Data->Value[j] = Data->Value[i];
if (strchr("'\"",Data->Value[i]))
Data->Value[j-1] = Data->Value[i-1];
if (strchr("'\"\\",Data->Value[i-1]))
{
j--;
Data->Value[j]='\\';
Data->Value[j-1]='\\';
}
j--; i--;
}
Expand Down
2 changes: 1 addition & 1 deletion src/sign-verify.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -657,7 +657,7 @@ sealfield * SealVerify (sealfield *Rec, mmapfile *Mmap)
If it's 1, then check if it covers the start of the file.
*****/
signum = SealGetIindex(Rec,"@s",2);
if (signum < 1) // should never happen
if (signum < 1) // happens if the seal record is corrupted
{
printf(" WARNING: Invalid SEAL record count (%ld).\n",signum);
return(Rec);
Expand Down

0 comments on commit b3aadc5

Please sign in to comment.