Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-cw
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-cw
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
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
88 additions
and
49 deletions
+88
-49
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
+4
-6
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)
*/
unsigned
char
*
_mbsncpy
(
unsigned
char
*
dst
,
const
unsigned
char
*
src
,
MSVCRT_size_t
n
)
{
unsigned
char
*
ret
=
dst
;
if
(
!
n
)
return
dst
;
if
(
MSVCRT___mb_cur_max
>
1
)
{
unsigned
char
*
ret
=
dst
;
while
(
*
src
&&
n
--
)
while
(
*
src
&&
n
)
{
n
--
;
*
dst
++
=
*
src
;
if
(
MSVCRT_isleadbyte
(
*
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
*/
unsigned
char
*
_mbsnbcpy
(
unsigned
char
*
dst
,
const
unsigned
char
*
src
,
MSVCRT_size_t
n
)
{
unsigned
char
*
ret
=
dst
;
if
(
!
n
)
return
dst
;
if
(
MSVCRT___mb_cur_max
>
1
)
{
unsigned
char
*
ret
=
dst
;
while
(
*
src
&&
(
n
--
>
1
))
while
(
*
src
&&
(
n
>
1
))
{
n
--
;
*
dst
++
=
*
src
;
if
(
MSVCRT_isleadbyte
(
*
src
++
))
{
...
...
@@ -268,11 +276,17 @@ unsigned char* _mbsnbcpy(unsigned char* dst, const unsigned char* src, MSVCRT_si
*
dst
++
=
*
src
;
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
mach_port_t
masterPort
;
char
bsdName
[
6
];
/* disk#\0 */
strncpy
(
bsdName
,
stfs
.
f_mntfromname
+
strlen
(
_PATH_DEV
)
,
5
);
bsdName
[
5
]
=
0
;
const
char
*
name
=
stfs
.
f_mntfromname
+
strlen
(
_PATH_DEV
);
memcpy
(
bsdName
,
name
,
min
(
strlen
(
name
)
+
1
,
sizeof
(
bsdName
))
);
bsdName
[
sizeof
(
bsdName
)
-
1
]
=
0
;
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
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_dlsym
(
void
*
handle
,
const
char
*
symbol
,
char
*
error
,
in
t
errorsize
);
extern
int
wine_dlclose
(
void
*
handle
,
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
,
size_
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_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
,
...
...
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
{
struct
dll
*
dll
=
first_dll
;
struct
debug_option
*
opt
;
size_t
len
=
strlen
(
name
);
if
(
!
(
opt
=
malloc
(
sizeof
(
*
opt
)
)))
return
;
opt
->
next
=
NULL
;
opt
->
set
=
set
;
opt
->
clear
=
clear
;
strncpy
(
opt
->
name
,
name
,
sizeof
(
opt
->
name
)
);
opt
->
name
[
sizeof
(
opt
->
name
)
-
1
]
=
0
;
if
(
len
>=
sizeof
(
opt
->
name
))
len
=
sizeof
(
opt
->
name
)
-
1
;
memcpy
(
opt
->
name
,
name
,
len
);
opt
->
name
[
len
]
=
0
;
if
(
last_option
)
last_option
->
next
=
opt
;
else
first_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 )
/***********************************************************************
* 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
void
*
ret
;
...
...
@@ -566,18 +566,26 @@ void *wine_dlopen( const char *filename, int flag, char *error, int errorsize )
dlerror
();
dlerror
();
ret
=
dlopen
(
filename
,
flag
);
s
=
dlerror
();
if
(
error
)
if
(
error
&&
errorsize
)
{
strncpy
(
error
,
s
?
s
:
""
,
errorsize
);
error
[
errorsize
-
1
]
=
'\0'
;
if
(
s
)
{
size_t
len
=
strlen
(
s
);
if
(
len
>=
errorsize
)
len
=
errorsize
-
1
;
memcpy
(
error
,
s
,
len
);
error
[
len
]
=
0
;
}
else
error
[
0
]
=
0
;
}
dlerror
();
return
ret
;
#else
if
(
error
)
{
strncpy
(
error
,
"dlopen interface not detected by configure"
,
errorsize
);
error
[
errorsize
-
1
]
=
'\0'
;
static
const
char
msg
[]
=
"dlopen interface not detected by configure"
;
size_t
len
=
min
(
errorsize
,
sizeof
(
msg
)
);
memcpy
(
error
,
msg
,
len
);
error
[
len
-
1
]
=
0
;
}
return
NULL
;
#endif
...
...
@@ -586,7 +594,7 @@ void *wine_dlopen( const char *filename, int flag, char *error, int errorsize )
/***********************************************************************
* 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
void
*
ret
;
...
...
@@ -594,18 +602,26 @@ void *wine_dlsym( void *handle, const char *symbol, char *error, int errorsize )
dlerror
();
dlerror
();
ret
=
dlsym
(
handle
,
symbol
);
s
=
dlerror
();
if
(
error
)
if
(
error
&&
errorsize
)
{
strncpy
(
error
,
s
?
s
:
""
,
errorsize
);
error
[
errorsize
-
1
]
=
'\0'
;
if
(
s
)
{
size_t
len
=
strlen
(
s
);
if
(
len
>=
errorsize
)
len
=
errorsize
-
1
;
memcpy
(
error
,
s
,
len
);
error
[
len
]
=
0
;
}
else
error
[
0
]
=
0
;
}
dlerror
();
return
ret
;
#else
if
(
error
)
{
strncpy
(
error
,
"dlopen interface not detected by configure"
,
errorsize
);
error
[
errorsize
-
1
]
=
'\0'
;
static
const
char
msg
[]
=
"dlopen interface not detected by configure"
;
size_t
len
=
min
(
errorsize
,
sizeof
(
msg
)
);
memcpy
(
error
,
msg
,
len
);
error
[
len
-
1
]
=
0
;
}
return
NULL
;
#endif
...
...
@@ -614,7 +630,7 @@ void *wine_dlsym( void *handle, const char *symbol, char *error, int errorsize )
/***********************************************************************
* 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
int
ret
;
...
...
@@ -622,18 +638,26 @@ int wine_dlclose( void *handle, char *error, int errorsize )
dlerror
();
dlerror
();
ret
=
dlclose
(
handle
);
s
=
dlerror
();
if
(
error
)
if
(
error
&&
errorsize
)
{
strncpy
(
error
,
s
?
s
:
""
,
errorsize
);
error
[
errorsize
-
1
]
=
'\0'
;
if
(
s
)
{
size_t
len
=
strlen
(
s
);
if
(
len
>=
errorsize
)
len
=
errorsize
-
1
;
memcpy
(
error
,
s
,
len
);
error
[
len
]
=
0
;
}
else
error
[
0
]
=
0
;
}
dlerror
();
return
ret
;
#else
if
(
error
)
{
strncpy
(
error
,
"dlopen interface not detected by configure"
,
errorsize
);
error
[
errorsize
-
1
]
=
'\0'
;
static
const
char
msg
[]
=
"dlopen interface not detected by configure"
;
size_t
len
=
min
(
errorsize
,
sizeof
(
msg
)
);
memcpy
(
error
,
msg
,
len
);
error
[
len
-
1
]
=
0
;
}
return
1
;
#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
int
num_names
;
const
union
cptable
*
cptable
;
FT_SfntName
sfntname
;
char
namebuf
[
4096
];
TT_OS2
*
os2
;
cptable
=
wine_cp_get_table
(
enc
);
if
(
!
cptable
)
{
...
...
@@ -207,13 +206,12 @@ static void fill_fontinfo(FT_Face face, int enc, FILE *fp, int dpi, unsigned cha
num_names
=
FT_Get_Sfnt_Name_Count
(
face
);
for
(
i
=
0
;
i
<
num_names
;
i
++
)
{
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
&&
sfntname
.
language_id
==
0
&&
sfntname
.
name_id
==
0
)
{
strncpy
(
hdr
.
dfCopyright
,
namebuf
,
60
);
hdr
.
dfCopyright
[
59
]
=
'\0'
;
}
size_t
len
=
min
(
sfntname
.
string_len
,
sizeof
(
hdr
.
dfCopyright
)
-
1
);
memcpy
(
hdr
.
dfCopyright
,
sfntname
.
string
,
len
);
hdr
.
dfCopyright
[
len
]
=
0
;
}
}
os2
=
FT_Get_Sfnt_Table
(
face
,
ft_sfnt_os2
);
...
...
tools/winedump/dump.c
View file @
240d4ee9
...
...
@@ -86,15 +86,16 @@ void dump_data( const unsigned char *ptr, unsigned int size, const char *prefix
const
char
*
get_time_str
(
DWORD
_t
)
{
time_t
t
=
(
time_t
)
_t
;
const
char
*
str
=
ctime
(
&
t
);
size_t
len
=
strlen
(
str
);
static
char
buf
[
128
];
/* 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...
*/
strncpy
(
buf
,
ctime
(
&
t
),
sizeof
(
buf
))
;
buf
[
sizeof
(
buf
)
-
1
]
=
'\0'
;
if
(
buf
[
strlen
(
buf
)
-
1
]
==
'\n'
)
buf
[
strlen
(
buf
)
-
1
]
=
'\0'
;
if
(
len
&&
str
[
len
-
1
]
==
'\n'
)
len
--
;
if
(
len
>=
sizeof
(
buf
))
len
=
sizeof
(
buf
)
-
1
;
memcpy
(
buf
,
str
,
len
);
buf
[
len
]
=
0
;
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