mirror of
https://gitlab.winehq.org/wine/wine.git
synced 2024-11-19 17:06:04 -07:00
winebuild: Replace sprintf with snprintf to avoid deprecation warnings on macOS.
This commit is contained in:
parent
070e393146
commit
1d8ef42a75
Notes:
Alexandre Julliard
2024-09-19 23:03:14 +02:00
Approved-by: Rémi Bernon (@rbernon) Approved-by: Huw Davies (@huw) Approved-by: Alexandre Julliard (@julliard) Merge-Request: https://gitlab.winehq.org/wine/wine/merge_requests/6524
1 changed files with 4 additions and 2 deletions
|
@ -208,16 +208,18 @@ static const char valid_chars[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRS
|
||||||
/* encode a dll name into a linker-compatible name */
|
/* encode a dll name into a linker-compatible name */
|
||||||
static char *encode_dll_name( const char *name )
|
static char *encode_dll_name( const char *name )
|
||||||
{
|
{
|
||||||
char *p, *ret;
|
char *p, *ret, *ret_end;
|
||||||
int len = strlen(name);
|
int len = strlen(name);
|
||||||
|
|
||||||
if (strendswith( name, ".dll" )) len -= 4;
|
if (strendswith( name, ".dll" )) len -= 4;
|
||||||
if (strspn( name, valid_chars ) >= len) return strmake( "%.*s", len, name );
|
if (strspn( name, valid_chars ) >= len) return strmake( "%.*s", len, name );
|
||||||
|
|
||||||
ret = p = xmalloc( len * 4 + 1 );
|
ret = p = xmalloc( len * 4 + 1 );
|
||||||
|
ret_end = ret + (len * 4 + 1);
|
||||||
for ( ; len > 0; len--, name++)
|
for ( ; len > 0; len--, name++)
|
||||||
{
|
{
|
||||||
if (!strchr( valid_chars, *name )) p += sprintf( p, "$x%02x", *name );
|
if (!strchr( valid_chars, *name ))
|
||||||
|
p += snprintf( p, ret_end - p, "$x%02x", *name );
|
||||||
else *p++ = *name;
|
else *p++ = *name;
|
||||||
}
|
}
|
||||||
*p = 0;
|
*p = 0;
|
||||||
|
|
Loading…
Reference in a new issue