mirror of
https://gitlab.winehq.org/wine/wine.git
synced 2024-11-19 17:06:04 -07:00
Merge branch 'asan-wineeps.drv' into 'master'
wineps.drv: Use locale aware variants _sprintf_l and _sscanf_l. (ASan) See merge request wine/wine!6787
This commit is contained in:
commit
e4282c8d96
6 changed files with 28 additions and 32 deletions
|
@ -21,6 +21,7 @@
|
|||
|
||||
#include <stdarg.h>
|
||||
#include <string.h>
|
||||
#include <locale.h>
|
||||
|
||||
#include "windef.h"
|
||||
#include "winbase.h"
|
||||
|
@ -87,6 +88,7 @@ static const PSDRV_DEVMODE DefaultDevmode =
|
|||
|
||||
HINSTANCE PSDRV_hInstance = 0;
|
||||
HANDLE PSDRV_Heap = 0;
|
||||
_locale_t c_locale;
|
||||
|
||||
static BOOL import_ntf_from_reg(void)
|
||||
{
|
||||
|
@ -294,6 +296,7 @@ BOOL WINAPI DllMain( HINSTANCE hinst, DWORD reason, LPVOID reserved )
|
|||
{
|
||||
PSDRV_hInstance = hinst;
|
||||
DisableThreadLibraryCalls(hinst);
|
||||
c_locale = _create_locale( LC_ALL, "C" );
|
||||
|
||||
if (__wine_init_unix_call())
|
||||
return FALSE;
|
||||
|
@ -319,6 +322,7 @@ BOOL WINAPI DllMain( HINSTANCE hinst, DWORD reason, LPVOID reserved )
|
|||
case DLL_PROCESS_DETACH:
|
||||
if (reserved) break;
|
||||
WINE_UNIX_CALL(unix_free_printer_info, NULL);
|
||||
_free_locale( c_locale );
|
||||
HeapDestroy( PSDRV_Heap );
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -884,10 +884,7 @@ PPD *PSDRV_ParsePPD( const WCHAR *fname, HANDLE printer )
|
|||
#define PIA page->ImageableArea
|
||||
if(!PIA) {
|
||||
PIA = HeapAlloc( PSDRV_Heap, 0, sizeof(*PIA) );
|
||||
push_lc_numeric("C");
|
||||
sscanf(tuple.value, "%f%f%f%f", &PIA->llx, &PIA->lly,
|
||||
&PIA->urx, &PIA->ury);
|
||||
pop_lc_numeric();
|
||||
_sscanf_l(tuple.value, "%f%f%f%f", c_locale, &PIA->llx, &PIA->lly, &PIA->urx, &PIA->ury);
|
||||
}
|
||||
#undef PIA
|
||||
}
|
||||
|
@ -908,9 +905,7 @@ PPD *PSDRV_ParsePPD( const WCHAR *fname, HANDLE printer )
|
|||
#define PD page->PaperDimension
|
||||
if(!PD) {
|
||||
PD = HeapAlloc( PSDRV_Heap, 0, sizeof(*PD) );
|
||||
push_lc_numeric("C");
|
||||
sscanf(tuple.value, "%f%f", &PD->x, &PD->y);
|
||||
pop_lc_numeric();
|
||||
_sscanf_l(tuple.value, "%f%f", c_locale, &PD->x, &PD->y);
|
||||
}
|
||||
#undef PD
|
||||
}
|
||||
|
|
|
@ -625,9 +625,7 @@ BOOL PSDRV_WriteArc(print_ctx *ctx, INT x, INT y, INT w, INT h, double ang1,
|
|||
|
||||
/* Make angles -ve and swap order because we're working with an upside
|
||||
down y-axis */
|
||||
push_lc_numeric("C");
|
||||
sprintf(buf, psarc, x, y, w, h, -ang2, -ang1);
|
||||
pop_lc_numeric();
|
||||
_sprintf_l(buf, psarc, c_locale, x, y, w, h, -ang2, -ang1);
|
||||
return PSDRV_WriteSpool(ctx, buf, strlen(buf));
|
||||
}
|
||||
|
||||
|
@ -678,16 +676,11 @@ BOOL PSDRV_WriteSetColor(print_ctx *ctx, PSCOLOR *color)
|
|||
|
||||
switch(color->type) {
|
||||
case PSCOLOR_RGB:
|
||||
push_lc_numeric("C");
|
||||
sprintf(buf, pssetrgbcolor, color->value.rgb.r, color->value.rgb.g,
|
||||
color->value.rgb.b);
|
||||
pop_lc_numeric();
|
||||
_sprintf_l(buf, pssetrgbcolor, c_locale, color->value.rgb.r, color->value.rgb.g, color->value.rgb.b);
|
||||
return PSDRV_WriteSpool(ctx, buf, strlen(buf));
|
||||
|
||||
case PSCOLOR_GRAY:
|
||||
push_lc_numeric("C");
|
||||
sprintf(buf, pssetgray, color->value.gray.i);
|
||||
pop_lc_numeric();
|
||||
_sprintf_l(buf, pssetgray, c_locale, color->value.gray.i);
|
||||
return PSDRV_WriteSpool(ctx, buf, strlen(buf));
|
||||
|
||||
default:
|
||||
|
@ -786,9 +779,7 @@ BOOL PSDRV_WriteRotate(print_ctx *ctx, float ang)
|
|||
{
|
||||
char buf[256];
|
||||
|
||||
push_lc_numeric("C");
|
||||
sprintf(buf, psrotate, ang);
|
||||
pop_lc_numeric();
|
||||
_sprintf_l(buf, psrotate, c_locale, ang);
|
||||
return PSDRV_WriteSpool(ctx, buf, strlen(buf));
|
||||
}
|
||||
|
||||
|
|
|
@ -544,13 +544,7 @@ extern DWORD ASCII85_encode(BYTE *in_buf, DWORD len, BYTE *out_buf);
|
|||
extern void passthrough_enter(print_ctx *ctx);
|
||||
extern void passthrough_leave(print_ctx *ctx);
|
||||
|
||||
#define push_lc_numeric(x) do { \
|
||||
const char *tmplocale = setlocale(LC_NUMERIC,NULL); \
|
||||
setlocale(LC_NUMERIC,x);
|
||||
|
||||
#define pop_lc_numeric() \
|
||||
setlocale(LC_NUMERIC,tmplocale); \
|
||||
} while (0)
|
||||
extern _locale_t c_locale;
|
||||
|
||||
static inline WCHAR *strdupW( const WCHAR *str )
|
||||
{
|
||||
|
|
|
@ -203,11 +203,9 @@ TYPE42 *T42_download_header(print_ctx *ctx, char *ps_name,
|
|||
buf = HeapAlloc(GetProcessHeap(), 0, sizeof(start) + strlen(ps_name) +
|
||||
100);
|
||||
|
||||
push_lc_numeric("C");
|
||||
sprintf(buf, start, ps_name,
|
||||
_sprintf_l(buf, start, c_locale, ps_name,
|
||||
(float)bbox->left / emsize, (float)bbox->bottom / emsize,
|
||||
(float)bbox->right / emsize, (float)bbox->top / emsize);
|
||||
pop_lc_numeric();
|
||||
|
||||
PSDRV_WriteSpool(ctx, buf, strlen(buf));
|
||||
|
||||
|
|
|
@ -326,6 +326,19 @@ static inline int __cdecl printf_s(const char *format, ...)
|
|||
return ret;
|
||||
}
|
||||
|
||||
static inline int __cdecl _sprintf_l(char *buffer, const char *format, _locale_t locale, ...) __WINE_CRT_PRINTF_ATTR(2, 4);
|
||||
static inline int __cdecl _sprintf_l(char *buffer, const char *format, _locale_t locale, ...)
|
||||
{
|
||||
int ret;
|
||||
va_list args;
|
||||
|
||||
va_start(args, locale);
|
||||
ret = __stdio_common_vsprintf(_CRT_INTERNAL_LOCAL_PRINTF_OPTIONS | _CRT_INTERNAL_PRINTF_LEGACY_VSPRINTF_NULL_TERMINATION,
|
||||
buffer, -1, format, locale, args);
|
||||
va_end(args);
|
||||
return ret < 0 ? -1 : ret;
|
||||
}
|
||||
|
||||
static inline int __cdecl sscanf(const char *buffer, const char *format, ...) __WINE_CRT_SCANF_ATTR(2, 3);
|
||||
static inline int __cdecl sscanf(const char *buffer, const char *format, ...)
|
||||
{
|
||||
|
@ -519,6 +532,7 @@ static inline int __cdecl sprintf(char *buffer, const char *format, ...)
|
|||
_ACRTIMP int __cdecl snprintf(char*,size_t,const char*,...) __WINE_CRT_PRINTF_ATTR(3, 4);
|
||||
_ACRTIMP int __cdecl _snprintf(char*,size_t,const char*,...) __WINE_CRT_PRINTF_ATTR(3, 4);
|
||||
_ACRTIMP int __cdecl sprintf(char*,const char*,...) __WINE_CRT_PRINTF_ATTR(2, 3);
|
||||
_ACRTIMP int __cdecl _sprintf_l(char*,const char*,_locale_t,...) __WINE_CRT_PRINTF_ATTR(2, 4);
|
||||
|
||||
#endif /* !_NO_CRT_STDIO_INLINE */
|
||||
|
||||
|
|
Loading…
Reference in a new issue