Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
240d4ee9
Commit
240d4ee9
authored
Apr 25, 2005
by
Alexandre Julliard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove a few more instances of strncpy.
parent
172e731c
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
87 additions
and
48 deletions
+87
-48
mbcs.c
dlls/msvcrt/mbcs.c
+26
-12
file.c
dlls/ntdll/file.c
+3
-3
library.h
include/wine/library.h
+3
-3
debug.c
libs/wine/debug.c
+4
-2
loader.c
libs/wine/loader.c
+42
-18
sfnt2fnt.c
tools/sfnt2fnt.c
+3
-5
dump.c
tools/winedump/dump.c
+6
-5
No files found.
dlls/msvcrt/mbcs.c
View file @
240d4ee9
...
@@ -223,22 +223,29 @@ void _mbccpy(unsigned char* dest, const unsigned char* src)
...
@@ -223,22 +223,29 @@ void _mbccpy(unsigned char* dest, const unsigned char* src)
*/
*/
unsigned
char
*
_mbsncpy
(
unsigned
char
*
dst
,
const
unsigned
char
*
src
,
MSVCRT_size_t
n
)
unsigned
char
*
_mbsncpy
(
unsigned
char
*
dst
,
const
unsigned
char
*
src
,
MSVCRT_size_t
n
)
{
{
unsigned
char
*
ret
=
dst
;
if
(
!
n
)
if
(
!
n
)
return
dst
;
return
dst
;
if
(
MSVCRT___mb_cur_max
>
1
)
if
(
MSVCRT___mb_cur_max
>
1
)
{
{
unsigned
char
*
ret
=
dst
;
while
(
*
src
&&
n
)
while
(
*
src
&&
n
--
)
{
{
n
--
;
*
dst
++
=
*
src
;
*
dst
++
=
*
src
;
if
(
MSVCRT_isleadbyte
(
*
src
++
))
if
(
MSVCRT_isleadbyte
(
*
src
++
))
*
dst
++
=
*
src
++
;
*
dst
++
=
*
src
++
;
}
}
while
(
n
--
)
*
dst
++
=
'\0'
;
return
ret
;
}
}
return
strncpy
(
dst
,
src
,
n
);
/* ASCII CP */
else
{
while
(
n
)
{
n
--
;
if
(
!
(
*
dst
++
=
*
src
++
))
break
;
}
}
while
(
n
--
)
*
dst
++
=
0
;
return
ret
;
}
}
/*********************************************************************
/*********************************************************************
...
@@ -246,13 +253,14 @@ unsigned char* _mbsncpy(unsigned char* dst, const unsigned char* src, MSVCRT_siz
...
@@ -246,13 +253,14 @@ unsigned char* _mbsncpy(unsigned char* dst, const unsigned char* src, MSVCRT_siz
*/
*/
unsigned
char
*
_mbsnbcpy
(
unsigned
char
*
dst
,
const
unsigned
char
*
src
,
MSVCRT_size_t
n
)
unsigned
char
*
_mbsnbcpy
(
unsigned
char
*
dst
,
const
unsigned
char
*
src
,
MSVCRT_size_t
n
)
{
{
unsigned
char
*
ret
=
dst
;
if
(
!
n
)
if
(
!
n
)
return
dst
;
return
dst
;
if
(
MSVCRT___mb_cur_max
>
1
)
if
(
MSVCRT___mb_cur_max
>
1
)
{
{
unsigned
char
*
ret
=
dst
;
while
(
*
src
&&
(
n
>
1
))
while
(
*
src
&&
(
n
--
>
1
))
{
{
n
--
;
*
dst
++
=
*
src
;
*
dst
++
=
*
src
;
if
(
MSVCRT_isleadbyte
(
*
src
++
))
if
(
MSVCRT_isleadbyte
(
*
src
++
))
{
{
...
@@ -268,11 +276,17 @@ unsigned char* _mbsnbcpy(unsigned char* dst, const unsigned char* src, MSVCRT_si
...
@@ -268,11 +276,17 @@ unsigned char* _mbsnbcpy(unsigned char* dst, const unsigned char* src, MSVCRT_si
*
dst
++
=
*
src
;
*
dst
++
=
*
src
;
n
--
;
n
--
;
}
}
while
(
n
--
)
*
dst
++
=
'\0'
;
return
ret
;
}
}
return
strncpy
(
dst
,
src
,
n
);
/* ASCII CP */
else
{
while
(
n
)
{
n
--
;
if
(
!
(
*
dst
++
=
*
src
++
))
break
;
}
}
while
(
n
--
)
*
dst
++
=
0
;
return
ret
;
}
}
/*********************************************************************
/*********************************************************************
...
...
dlls/ntdll/file.c
View file @
240d4ee9
...
@@ -1515,9 +1515,9 @@ NTSTATUS WINAPI NtQueryVolumeInformationFile( HANDLE handle, PIO_STATUS_BLOCK io
...
@@ -1515,9 +1515,9 @@ NTSTATUS WINAPI NtQueryVolumeInformationFile( HANDLE handle, PIO_STATUS_BLOCK io
mach_port_t
masterPort
;
mach_port_t
masterPort
;
char
bsdName
[
6
];
/* disk#\0 */
char
bsdName
[
6
];
/* disk#\0 */
const
char
*
name
=
stfs
.
f_mntfromname
+
strlen
(
_PATH_DEV
);
strncpy
(
bsdName
,
stfs
.
f_mntfromname
+
strlen
(
_PATH_DEV
)
,
5
);
memcpy
(
bsdName
,
name
,
min
(
strlen
(
name
)
+
1
,
sizeof
(
bsdName
))
);
bsdName
[
5
]
=
0
;
bsdName
[
sizeof
(
bsdName
)
-
1
]
=
0
;
kernResult
=
IOMasterPort
(
MACH_PORT_NULL
,
&
masterPort
);
kernResult
=
IOMasterPort
(
MACH_PORT_NULL
,
&
masterPort
);
...
...
include/wine/library.h
View file @
240d4ee9
...
@@ -39,9 +39,9 @@ extern void wine_exec_wine_binary( const char *name, char **argv, char **envp, i
...
@@ -39,9 +39,9 @@ extern void wine_exec_wine_binary( const char *name, char **argv, char **envp, i
typedef
void
(
*
load_dll_callback_t
)(
void
*
,
const
char
*
);
typedef
void
(
*
load_dll_callback_t
)(
void
*
,
const
char
*
);
extern
void
*
wine_dlopen
(
const
char
*
filename
,
int
flag
,
char
*
error
,
in
t
errorsize
);
extern
void
*
wine_dlopen
(
const
char
*
filename
,
int
flag
,
char
*
error
,
size_
t
errorsize
);
extern
void
*
wine_dlsym
(
void
*
handle
,
const
char
*
symbol
,
char
*
error
,
in
t
errorsize
);
extern
void
*
wine_dlsym
(
void
*
handle
,
const
char
*
symbol
,
char
*
error
,
size_
t
errorsize
);
extern
int
wine_dlclose
(
void
*
handle
,
char
*
error
,
in
t
errorsize
);
extern
int
wine_dlclose
(
void
*
handle
,
char
*
error
,
size_
t
errorsize
);
extern
void
wine_dll_set_callback
(
load_dll_callback_t
load
);
extern
void
wine_dll_set_callback
(
load_dll_callback_t
load
);
extern
void
*
wine_dll_load
(
const
char
*
filename
,
char
*
error
,
int
errorsize
,
int
*
file_exists
);
extern
void
*
wine_dll_load
(
const
char
*
filename
,
char
*
error
,
int
errorsize
,
int
*
file_exists
);
extern
void
*
wine_dll_load_main_exe
(
const
char
*
name
,
char
*
error
,
int
errorsize
,
extern
void
*
wine_dll_load_main_exe
(
const
char
*
name
,
char
*
error
,
int
errorsize
,
...
...
libs/wine/debug.c
View file @
240d4ee9
...
@@ -121,13 +121,15 @@ void wine_dbg_add_option( const char *name, unsigned char set, unsigned char cle
...
@@ -121,13 +121,15 @@ void wine_dbg_add_option( const char *name, unsigned char set, unsigned char cle
{
{
struct
dll
*
dll
=
first_dll
;
struct
dll
*
dll
=
first_dll
;
struct
debug_option
*
opt
;
struct
debug_option
*
opt
;
size_t
len
=
strlen
(
name
);
if
(
!
(
opt
=
malloc
(
sizeof
(
*
opt
)
)))
return
;
if
(
!
(
opt
=
malloc
(
sizeof
(
*
opt
)
)))
return
;
opt
->
next
=
NULL
;
opt
->
next
=
NULL
;
opt
->
set
=
set
;
opt
->
set
=
set
;
opt
->
clear
=
clear
;
opt
->
clear
=
clear
;
strncpy
(
opt
->
name
,
name
,
sizeof
(
opt
->
name
)
);
if
(
len
>=
sizeof
(
opt
->
name
))
len
=
sizeof
(
opt
->
name
)
-
1
;
opt
->
name
[
sizeof
(
opt
->
name
)
-
1
]
=
0
;
memcpy
(
opt
->
name
,
name
,
len
);
opt
->
name
[
len
]
=
0
;
if
(
last_option
)
last_option
->
next
=
opt
;
if
(
last_option
)
last_option
->
next
=
opt
;
else
first_option
=
opt
;
else
first_option
=
opt
;
last_option
=
opt
;
last_option
=
opt
;
...
...
libs/wine/loader.c
View file @
240d4ee9
...
@@ -558,7 +558,7 @@ void wine_init( int argc, char *argv[], char *error, int error_size )
...
@@ -558,7 +558,7 @@ void wine_init( int argc, char *argv[], char *error, int error_size )
/***********************************************************************
/***********************************************************************
* wine_dlopen
* wine_dlopen
*/
*/
void
*
wine_dlopen
(
const
char
*
filename
,
int
flag
,
char
*
error
,
in
t
errorsize
)
void
*
wine_dlopen
(
const
char
*
filename
,
int
flag
,
char
*
error
,
size_
t
errorsize
)
{
{
#ifdef HAVE_DLOPEN
#ifdef HAVE_DLOPEN
void
*
ret
;
void
*
ret
;
...
@@ -566,18 +566,26 @@ void *wine_dlopen( const char *filename, int flag, char *error, int errorsize )
...
@@ -566,18 +566,26 @@ void *wine_dlopen( const char *filename, int flag, char *error, int errorsize )
dlerror
();
dlerror
();
dlerror
();
dlerror
();
ret
=
dlopen
(
filename
,
flag
);
ret
=
dlopen
(
filename
,
flag
);
s
=
dlerror
();
s
=
dlerror
();
if
(
error
)
if
(
error
&&
errorsize
)
{
if
(
s
)
{
{
strncpy
(
error
,
s
?
s
:
""
,
errorsize
);
size_t
len
=
strlen
(
s
);
error
[
errorsize
-
1
]
=
'\0'
;
if
(
len
>=
errorsize
)
len
=
errorsize
-
1
;
memcpy
(
error
,
s
,
len
);
error
[
len
]
=
0
;
}
else
error
[
0
]
=
0
;
}
}
dlerror
();
dlerror
();
return
ret
;
return
ret
;
#else
#else
if
(
error
)
if
(
error
)
{
{
strncpy
(
error
,
"dlopen interface not detected by configure"
,
errorsize
);
static
const
char
msg
[]
=
"dlopen interface not detected by configure"
;
error
[
errorsize
-
1
]
=
'\0'
;
size_t
len
=
min
(
errorsize
,
sizeof
(
msg
)
);
memcpy
(
error
,
msg
,
len
);
error
[
len
-
1
]
=
0
;
}
}
return
NULL
;
return
NULL
;
#endif
#endif
...
@@ -586,7 +594,7 @@ void *wine_dlopen( const char *filename, int flag, char *error, int errorsize )
...
@@ -586,7 +594,7 @@ void *wine_dlopen( const char *filename, int flag, char *error, int errorsize )
/***********************************************************************
/***********************************************************************
* wine_dlsym
* wine_dlsym
*/
*/
void
*
wine_dlsym
(
void
*
handle
,
const
char
*
symbol
,
char
*
error
,
in
t
errorsize
)
void
*
wine_dlsym
(
void
*
handle
,
const
char
*
symbol
,
char
*
error
,
size_
t
errorsize
)
{
{
#ifdef HAVE_DLOPEN
#ifdef HAVE_DLOPEN
void
*
ret
;
void
*
ret
;
...
@@ -594,18 +602,26 @@ void *wine_dlsym( void *handle, const char *symbol, char *error, int errorsize )
...
@@ -594,18 +602,26 @@ void *wine_dlsym( void *handle, const char *symbol, char *error, int errorsize )
dlerror
();
dlerror
();
dlerror
();
dlerror
();
ret
=
dlsym
(
handle
,
symbol
);
ret
=
dlsym
(
handle
,
symbol
);
s
=
dlerror
();
s
=
dlerror
();
if
(
error
)
if
(
error
&&
errorsize
)
{
if
(
s
)
{
{
strncpy
(
error
,
s
?
s
:
""
,
errorsize
);
size_t
len
=
strlen
(
s
);
error
[
errorsize
-
1
]
=
'\0'
;
if
(
len
>=
errorsize
)
len
=
errorsize
-
1
;
memcpy
(
error
,
s
,
len
);
error
[
len
]
=
0
;
}
else
error
[
0
]
=
0
;
}
}
dlerror
();
dlerror
();
return
ret
;
return
ret
;
#else
#else
if
(
error
)
if
(
error
)
{
{
strncpy
(
error
,
"dlopen interface not detected by configure"
,
errorsize
);
static
const
char
msg
[]
=
"dlopen interface not detected by configure"
;
error
[
errorsize
-
1
]
=
'\0'
;
size_t
len
=
min
(
errorsize
,
sizeof
(
msg
)
);
memcpy
(
error
,
msg
,
len
);
error
[
len
-
1
]
=
0
;
}
}
return
NULL
;
return
NULL
;
#endif
#endif
...
@@ -614,7 +630,7 @@ void *wine_dlsym( void *handle, const char *symbol, char *error, int errorsize )
...
@@ -614,7 +630,7 @@ void *wine_dlsym( void *handle, const char *symbol, char *error, int errorsize )
/***********************************************************************
/***********************************************************************
* wine_dlclose
* wine_dlclose
*/
*/
int
wine_dlclose
(
void
*
handle
,
char
*
error
,
in
t
errorsize
)
int
wine_dlclose
(
void
*
handle
,
char
*
error
,
size_
t
errorsize
)
{
{
#ifdef HAVE_DLOPEN
#ifdef HAVE_DLOPEN
int
ret
;
int
ret
;
...
@@ -622,18 +638,26 @@ int wine_dlclose( void *handle, char *error, int errorsize )
...
@@ -622,18 +638,26 @@ int wine_dlclose( void *handle, char *error, int errorsize )
dlerror
();
dlerror
();
dlerror
();
dlerror
();
ret
=
dlclose
(
handle
);
ret
=
dlclose
(
handle
);
s
=
dlerror
();
s
=
dlerror
();
if
(
error
)
if
(
error
&&
errorsize
)
{
{
strncpy
(
error
,
s
?
s
:
""
,
errorsize
);
if
(
s
)
error
[
errorsize
-
1
]
=
'\0'
;
{
size_t
len
=
strlen
(
s
);
if
(
len
>=
errorsize
)
len
=
errorsize
-
1
;
memcpy
(
error
,
s
,
len
);
error
[
len
]
=
0
;
}
else
error
[
0
]
=
0
;
}
}
dlerror
();
dlerror
();
return
ret
;
return
ret
;
#else
#else
if
(
error
)
if
(
error
)
{
{
strncpy
(
error
,
"dlopen interface not detected by configure"
,
errorsize
);
static
const
char
msg
[]
=
"dlopen interface not detected by configure"
;
error
[
errorsize
-
1
]
=
'\0'
;
size_t
len
=
min
(
errorsize
,
sizeof
(
msg
)
);
memcpy
(
error
,
msg
,
len
);
error
[
len
-
1
]
=
0
;
}
}
return
1
;
return
1
;
#endif
#endif
...
...
tools/sfnt2fnt.c
View file @
240d4ee9
...
@@ -163,7 +163,6 @@ static void fill_fontinfo(FT_Face face, int enc, FILE *fp, int dpi, unsigned cha
...
@@ -163,7 +163,6 @@ static void fill_fontinfo(FT_Face face, int enc, FILE *fp, int dpi, unsigned cha
int
num_names
;
int
num_names
;
const
union
cptable
*
cptable
;
const
union
cptable
*
cptable
;
FT_SfntName
sfntname
;
FT_SfntName
sfntname
;
char
namebuf
[
4096
];
TT_OS2
*
os2
;
TT_OS2
*
os2
;
cptable
=
wine_cp_get_table
(
enc
);
cptable
=
wine_cp_get_table
(
enc
);
if
(
!
cptable
)
{
if
(
!
cptable
)
{
...
@@ -207,12 +206,11 @@ static void fill_fontinfo(FT_Face face, int enc, FILE *fp, int dpi, unsigned cha
...
@@ -207,12 +206,11 @@ static void fill_fontinfo(FT_Face face, int enc, FILE *fp, int dpi, unsigned cha
num_names
=
FT_Get_Sfnt_Name_Count
(
face
);
num_names
=
FT_Get_Sfnt_Name_Count
(
face
);
for
(
i
=
0
;
i
<
num_names
;
i
++
)
{
for
(
i
=
0
;
i
<
num_names
;
i
++
)
{
FT_Get_Sfnt_Name
(
face
,
i
,
&
sfntname
);
FT_Get_Sfnt_Name
(
face
,
i
,
&
sfntname
);
memcpy
(
namebuf
,
sfntname
.
string
,
sfntname
.
string_len
);
namebuf
[
sfntname
.
string_len
]
=
'\0'
;
if
(
sfntname
.
platform_id
==
1
&&
sfntname
.
encoding_id
==
0
&&
if
(
sfntname
.
platform_id
==
1
&&
sfntname
.
encoding_id
==
0
&&
sfntname
.
language_id
==
0
&&
sfntname
.
name_id
==
0
)
{
sfntname
.
language_id
==
0
&&
sfntname
.
name_id
==
0
)
{
strncpy
(
hdr
.
dfCopyright
,
namebuf
,
60
);
size_t
len
=
min
(
sfntname
.
string_len
,
sizeof
(
hdr
.
dfCopyright
)
-
1
);
hdr
.
dfCopyright
[
59
]
=
'\0'
;
memcpy
(
hdr
.
dfCopyright
,
sfntname
.
string
,
len
);
hdr
.
dfCopyright
[
len
]
=
0
;
}
}
}
}
...
...
tools/winedump/dump.c
View file @
240d4ee9
...
@@ -86,15 +86,16 @@ void dump_data( const unsigned char *ptr, unsigned int size, const char *prefix
...
@@ -86,15 +86,16 @@ void dump_data( const unsigned char *ptr, unsigned int size, const char *prefix
const
char
*
get_time_str
(
DWORD
_t
)
const
char
*
get_time_str
(
DWORD
_t
)
{
{
time_t
t
=
(
time_t
)
_t
;
time_t
t
=
(
time_t
)
_t
;
const
char
*
str
=
ctime
(
&
t
);
size_t
len
=
strlen
(
str
);
static
char
buf
[
128
];
static
char
buf
[
128
];
/* FIXME: I don't get the same values from MS' pedump running under Wine...
/* FIXME: I don't get the same values from MS' pedump running under Wine...
* I wonder if Wine isn't broken wrt to GMT settings...
* I wonder if Wine isn't broken wrt to GMT settings...
*/
*/
strncpy
(
buf
,
ctime
(
&
t
),
sizeof
(
buf
))
;
if
(
len
&&
str
[
len
-
1
]
==
'\n'
)
len
--
;
buf
[
sizeof
(
buf
)
-
1
]
=
'\0'
;
if
(
len
>=
sizeof
(
buf
))
len
=
sizeof
(
buf
)
-
1
;
if
(
buf
[
strlen
(
buf
)
-
1
]
==
'\n'
)
memcpy
(
buf
,
str
,
len
);
buf
[
strlen
(
buf
)
-
1
]
=
'\0'
;
buf
[
len
]
=
0
;
return
buf
;
return
buf
;
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment