winspool: Filter invalid characters when creating the PPD filename.
Fixes potential crash when trying to print if a CUPS printer name
contains an asterisk.
Signed-off-by: Owen Rudge <orudge@codeweavers.com>
Signed-off-by: Huw Davies <huw@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
(cherry picked from commit 6b906e8237
)
Signed-off-by: Michael Stefaniuc <mstefani@winehq.org>
This commit is contained in:
parent
5cf41e251d
commit
fb53228568
|
@ -721,13 +721,18 @@ fail:
|
||||||
static WCHAR *get_ppd_filename( const WCHAR *dir, const WCHAR *file_name )
|
static WCHAR *get_ppd_filename( const WCHAR *dir, const WCHAR *file_name )
|
||||||
{
|
{
|
||||||
static const WCHAR dot_ppd[] = {'.','p','p','d',0};
|
static const WCHAR dot_ppd[] = {'.','p','p','d',0};
|
||||||
int len = (strlenW( dir ) + strlenW( file_name )) * sizeof(WCHAR) + sizeof(dot_ppd);
|
static const WCHAR invalid_chars[] = {'*','?','<','>','|','"','/','\\',0};
|
||||||
WCHAR *ppd = HeapAlloc( GetProcessHeap(), 0, len );
|
int dir_len = strlenW( dir ), file_len = strlenW( file_name );
|
||||||
|
int len = (dir_len + file_len + ARRAY_SIZE( dot_ppd )) * sizeof(WCHAR);
|
||||||
|
WCHAR *ppd = HeapAlloc( GetProcessHeap(), 0, len ), *p;
|
||||||
|
|
||||||
if (!ppd) return NULL;
|
if (!ppd) return NULL;
|
||||||
strcpyW( ppd, dir );
|
memcpy( ppd, dir, dir_len * sizeof(WCHAR) );
|
||||||
strcatW( ppd, file_name );
|
memcpy( ppd + dir_len, file_name, file_len * sizeof(WCHAR) );
|
||||||
strcatW( ppd, dot_ppd );
|
memcpy( ppd + dir_len + file_len, dot_ppd, sizeof(dot_ppd) );
|
||||||
|
|
||||||
|
p = ppd + dir_len;
|
||||||
|
while ((p = strpbrkW( p, invalid_chars ))) *p++ = '_';
|
||||||
|
|
||||||
return ppd;
|
return ppd;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue