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
Kirill Smelkov
linux
Commits
8eb73664
Commit
8eb73664
authored
Feb 02, 2004
by
Linus Torvalds
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Warn loudly if somebody passes a negative value as
the size to "vsnprintf()". That's a pretty clear case of overflow.
parent
236d2f49
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
1 deletion
+10
-1
lib/vsprintf.c
lib/vsprintf.c
+10
-1
No files found.
lib/vsprintf.c
View file @
8eb73664
...
@@ -254,6 +254,15 @@ int vsnprintf(char *buf, size_t size, const char *fmt, va_list args)
...
@@ -254,6 +254,15 @@ int vsnprintf(char *buf, size_t size, const char *fmt, va_list args)
/* 'z' support added 23/7/1999 S.H. */
/* 'z' support added 23/7/1999 S.H. */
/* 'z' changed to 'Z' --davidm 1/25/99 */
/* 'z' changed to 'Z' --davidm 1/25/99 */
/* Reject out-of-range values early */
if
(
unlikely
((
int
)
size
<
0
))
{
/* There can be only one.. */
static
int
warn
=
1
;
WARN_ON
(
warn
);
warn
=
0
;
return
0
;
}
str
=
buf
;
str
=
buf
;
end
=
buf
+
size
-
1
;
end
=
buf
+
size
-
1
;
...
@@ -498,7 +507,7 @@ EXPORT_SYMBOL(snprintf);
...
@@ -498,7 +507,7 @@ EXPORT_SYMBOL(snprintf);
*/
*/
int
vsprintf
(
char
*
buf
,
const
char
*
fmt
,
va_list
args
)
int
vsprintf
(
char
*
buf
,
const
char
*
fmt
,
va_list
args
)
{
{
return
vsnprintf
(
buf
,
0xFFFFFFFFUL
,
fmt
,
args
);
return
vsnprintf
(
buf
,
(
~
0U
)
>>
1
,
fmt
,
args
);
}
}
EXPORT_SYMBOL
(
vsprintf
);
EXPORT_SYMBOL
(
vsprintf
);
...
...
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