Mercurial > mplayer.hg
annotate osdep/vsscanf.c @ 35394:7bad316da87a
stream ftp: Pass full buffer size to snprintf
Previously the buffer size was always passed as one less than
the underlying buffer's size. This is not using the underlying
buffer to its full potential according to the C99 standard. The
last byte of the buffers were never used.
No vulnerabilities should have been caused by this mistake because
the strings stored in the buffers were zero terminated at all
times. Neither were out-of-array writes nor reads possible.
author | al |
---|---|
date | Mon, 26 Nov 2012 23:36:00 +0000 |
parents | 5cfef41a1771 |
children |
rev | line source |
---|---|
28744 | 1 /* |
2 * vsscanf implementation for systems that do not have it in libc | |
3 * | |
4 * This file is part of MPlayer. | |
5 * | |
6 * MPlayer is free software; you can redistribute it and/or modify | |
7 * it under the terms of the GNU General Public License as published by | |
8 * the Free Software Foundation; either version 2 of the License, or | |
9 * (at your option) any later version. | |
10 * | |
11 * MPlayer is distributed in the hope that it will be useful, | |
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 * GNU General Public License for more details. | |
15 * | |
16 * You should have received a copy of the GNU General Public License along | |
17 * with MPlayer; if not, write to the Free Software Foundation, Inc., | |
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | |
19 */ | |
8290
1dd8fe0776d3
Add our own vsscanf implementation, in case the system's libc does not have
jkeil
parents:
diff
changeset
|
20 |
28744 | 21 #include "config.h" |
8290
1dd8fe0776d3
Add our own vsscanf implementation, in case the system's libc does not have
jkeil
parents:
diff
changeset
|
22 |
1dd8fe0776d3
Add our own vsscanf implementation, in case the system's libc does not have
jkeil
parents:
diff
changeset
|
23 #include <stdio.h> |
1dd8fe0776d3
Add our own vsscanf implementation, in case the system's libc does not have
jkeil
parents:
diff
changeset
|
24 #include <stdarg.h> |
1dd8fe0776d3
Add our own vsscanf implementation, in case the system's libc does not have
jkeil
parents:
diff
changeset
|
25 |
1dd8fe0776d3
Add our own vsscanf implementation, in case the system's libc does not have
jkeil
parents:
diff
changeset
|
26 int |
1dd8fe0776d3
Add our own vsscanf implementation, in case the system's libc does not have
jkeil
parents:
diff
changeset
|
27 vsscanf(const char *str, const char *format, va_list ap) |
1dd8fe0776d3
Add our own vsscanf implementation, in case the system's libc does not have
jkeil
parents:
diff
changeset
|
28 { |
1dd8fe0776d3
Add our own vsscanf implementation, in case the system's libc does not have
jkeil
parents:
diff
changeset
|
29 /* XXX: can this be implemented in a more portable way? */ |
1dd8fe0776d3
Add our own vsscanf implementation, in case the system's libc does not have
jkeil
parents:
diff
changeset
|
30 long p1 = va_arg(ap, long); |
1dd8fe0776d3
Add our own vsscanf implementation, in case the system's libc does not have
jkeil
parents:
diff
changeset
|
31 long p2 = va_arg(ap, long); |
1dd8fe0776d3
Add our own vsscanf implementation, in case the system's libc does not have
jkeil
parents:
diff
changeset
|
32 long p3 = va_arg(ap, long); |
1dd8fe0776d3
Add our own vsscanf implementation, in case the system's libc does not have
jkeil
parents:
diff
changeset
|
33 long p4 = va_arg(ap, long); |
1dd8fe0776d3
Add our own vsscanf implementation, in case the system's libc does not have
jkeil
parents:
diff
changeset
|
34 long p5 = va_arg(ap, long); |
1dd8fe0776d3
Add our own vsscanf implementation, in case the system's libc does not have
jkeil
parents:
diff
changeset
|
35 return sscanf(str, format, p1, p2, p3, p4, p5); |
1dd8fe0776d3
Add our own vsscanf implementation, in case the system's libc does not have
jkeil
parents:
diff
changeset
|
36 } |