Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
L
linux
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
linux
Commits
faad0c27
Commit
faad0c27
authored
May 25, 2003
by
Linus Torvalds
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Do a strlcat() to go with the strlcpy().
parent
dc2f9764
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
0 deletions
+30
-0
include/linux/string.h
include/linux/string.h
+3
-0
lib/string.c
lib/string.c
+27
-0
No files found.
include/linux/string.h
View file @
faad0c27
...
...
@@ -37,6 +37,9 @@ extern char * strcat(char *, const char *);
#ifndef __HAVE_ARCH_STRNCAT
extern
char
*
strncat
(
char
*
,
const
char
*
,
__kernel_size_t
);
#endif
#ifndef __HAVE_ARCH_STRLCAT
extern
size_t
strlcat
(
char
*
,
const
char
*
,
__kernel_size_t
);
#endif
#ifndef __HAVE_ARCH_STRCMP
extern
int
strcmp
(
const
char
*
,
const
char
*
);
#endif
...
...
lib/string.c
View file @
faad0c27
...
...
@@ -169,6 +169,33 @@ char * strncat(char *dest, const char *src, size_t count)
}
#endif
#ifndef __HAVE_ARCH_STRLCAT
/**
* strlcat - Append a length-limited, %NUL-terminated string to another
* @dest: The string to be appended to
* @src: The string to append to it
* @count: The size of the destination buffer.
*/
size_t
strlcat
(
char
*
dest
,
const
char
*
src
,
size_t
count
)
{
size_t
dsize
=
strlen
(
dest
);
size_t
len
=
strlen
(
src
);
size_t
res
=
dsize
+
len
;
/* This would be a bug */
BUG_ON
(
dsize
>=
count
);
dest
+=
dsize
;
count
-=
dsize
;
if
(
len
>=
count
)
len
=
count
-
1
;
memcpy
(
dest
,
src
,
len
);
dest
[
len
]
=
0
;
return
res
;
}
EXPORT_SYMBOL
(
strlcat
);
#endif
#ifndef __HAVE_ARCH_STRCMP
/**
* strcmp - Compare two strings
...
...
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