mirror of
https://github.com/michaelrsweet/pdfio.git
synced 2024-12-27 05:48:20 +01:00
Fix conversion of nul-containing strings to binary.
Move key length checks to a common place.
This commit is contained in:
parent
af07f64bc3
commit
1e33878506
@ -640,17 +640,13 @@ _pdfioCryptoUnlock(
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (!strcmp(cfm, "V2"))
|
|
||||||
{
|
|
||||||
pdf->encryption = PDFIO_ENCRYPTION_RC4_128;
|
|
||||||
if (length < 40 || length > 128)
|
if (length < 40 || length > 128)
|
||||||
length = 128;
|
length = 128; // Default to 128 bits
|
||||||
}
|
|
||||||
if (!strcmp(cfm, "AESV2"))
|
if (!strcmp(cfm, "V2"))
|
||||||
{
|
pdf->encryption = PDFIO_ENCRYPTION_RC4_128;
|
||||||
|
else if (!strcmp(cfm, "AESV2"))
|
||||||
pdf->encryption = PDFIO_ENCRYPTION_AES_128;
|
pdf->encryption = PDFIO_ENCRYPTION_AES_128;
|
||||||
length = 128;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (version == 1 || version == 2)
|
else if (version == 1 || version == 2)
|
||||||
|
@ -284,7 +284,9 @@ _pdfioTokenRead(_pdfio_token_t *tb, // I - Token buffer/stack
|
|||||||
int tch = get_char(tb); // Next char
|
int tch = get_char(tb); // Next char
|
||||||
|
|
||||||
if (tch >= '0' && tch <= '7')
|
if (tch >= '0' && tch <= '7')
|
||||||
|
{
|
||||||
ch = (char)((ch << 3) | (tch - '0'));
|
ch = (char)((ch << 3) | (tch - '0'));
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
tb->bufptr --;
|
tb->bufptr --;
|
||||||
@ -377,8 +379,10 @@ _pdfioTokenRead(_pdfio_token_t *tb, // I - Token buffer/stack
|
|||||||
*buffer = '<';
|
*buffer = '<';
|
||||||
for (litptr = bufptr - 1, hexptr = buffer + 2 * bytes - 1; litptr > buffer; litptr --, hexptr -= 2)
|
for (litptr = bufptr - 1, hexptr = buffer + 2 * bytes - 1; litptr > buffer; litptr --, hexptr -= 2)
|
||||||
{
|
{
|
||||||
hexptr[0] = hexchars[(*litptr >> 4) & 15];
|
int litch = *litptr; // Grab the character
|
||||||
hexptr[1] = hexchars[*litptr & 15];
|
|
||||||
|
hexptr[0] = hexchars[(litch >> 4) & 15];
|
||||||
|
hexptr[1] = hexchars[litch & 15];
|
||||||
}
|
}
|
||||||
bufptr = buffer + 2 * bytes + 1;
|
bufptr = buffer + 2 * bytes + 1;
|
||||||
}
|
}
|
||||||
|
@ -400,6 +400,9 @@ _pdfioValueRead(pdfio_file_t *pdf, // I - PDF file
|
|||||||
|
|
||||||
tempptr = tb->bufptr;
|
tempptr = tb->bufptr;
|
||||||
|
|
||||||
|
while (tempptr < tb->bufend && isspace(*tempptr & 255))
|
||||||
|
tempptr ++; // Skip whitespace as needed...
|
||||||
|
|
||||||
if (tempptr < tb->bufend && isdigit(*tempptr & 255))
|
if (tempptr < tb->bufend && isdigit(*tempptr & 255))
|
||||||
{
|
{
|
||||||
// Integer...
|
// Integer...
|
||||||
@ -412,7 +415,7 @@ _pdfioValueRead(pdfio_file_t *pdf, // I - PDF file
|
|||||||
}
|
}
|
||||||
|
|
||||||
while (tempptr < tb->bufend && isspace(*tempptr & 255))
|
while (tempptr < tb->bufend && isspace(*tempptr & 255))
|
||||||
tempptr ++;
|
tempptr ++; // Skip whitespace
|
||||||
|
|
||||||
if (tempptr < tb->bufend && *tempptr == 'R')
|
if (tempptr < tb->bufend && *tempptr == 'R')
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user