| xf.li | bdd93d5 | 2023-05-12 07:10:14 -0700 | [diff] [blame] | 1 | /* Copyright (C) 1994-2016 Free Software Foundation, Inc. | 
|  | 2 | This file is part of the GNU C Library. | 
|  | 3 |  | 
|  | 4 | The GNU C Library is free software; you can redistribute it and/or | 
|  | 5 | modify it under the terms of the GNU Lesser General Public | 
|  | 6 | License as published by the Free Software Foundation; either | 
|  | 7 | version 2.1 of the License, or (at your option) any later version. | 
|  | 8 |  | 
|  | 9 | The GNU C Library is distributed in the hope that it will be useful, | 
|  | 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 
|  | 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU | 
|  | 12 | Lesser General Public License for more details. | 
|  | 13 |  | 
|  | 14 | You should have received a copy of the GNU Lesser General Public | 
|  | 15 | License along with the GNU C Library; if not, see | 
|  | 16 | <http://www.gnu.org/licenses/>.  */ | 
|  | 17 |  | 
|  | 18 | #include <stdarg.h> | 
|  | 19 | #include <stdio.h> | 
|  | 20 | #include "../libio/libioP.h" | 
|  | 21 | #include "../libio/strfile.h" | 
|  | 22 |  | 
|  | 23 |  | 
|  | 24 | static int _IO_str_chk_overflow (_IO_FILE *fp, int c) __THROW; | 
|  | 25 |  | 
|  | 26 | static int | 
|  | 27 | _IO_str_chk_overflow (_IO_FILE *fp, int c) | 
|  | 28 | { | 
|  | 29 | /* When we come to here this means the user supplied buffer is | 
|  | 30 | filled.  */ | 
|  | 31 | __chk_fail (); | 
|  | 32 | } | 
|  | 33 |  | 
|  | 34 |  | 
|  | 35 | static const struct _IO_jump_t _IO_str_chk_jumps = | 
|  | 36 | { | 
|  | 37 | JUMP_INIT_DUMMY, | 
|  | 38 | JUMP_INIT(finish, _IO_str_finish), | 
|  | 39 | JUMP_INIT(overflow, _IO_str_chk_overflow), | 
|  | 40 | JUMP_INIT(underflow, _IO_str_underflow), | 
|  | 41 | JUMP_INIT(uflow, _IO_default_uflow), | 
|  | 42 | JUMP_INIT(pbackfail, _IO_str_pbackfail), | 
|  | 43 | JUMP_INIT(xsputn, _IO_default_xsputn), | 
|  | 44 | JUMP_INIT(xsgetn, _IO_default_xsgetn), | 
|  | 45 | JUMP_INIT(seekoff, _IO_str_seekoff), | 
|  | 46 | JUMP_INIT(seekpos, _IO_default_seekpos), | 
|  | 47 | JUMP_INIT(setbuf, _IO_default_setbuf), | 
|  | 48 | JUMP_INIT(sync, _IO_default_sync), | 
|  | 49 | JUMP_INIT(doallocate, _IO_default_doallocate), | 
|  | 50 | JUMP_INIT(read, _IO_default_read), | 
|  | 51 | JUMP_INIT(write, _IO_default_write), | 
|  | 52 | JUMP_INIT(seek, _IO_default_seek), | 
|  | 53 | JUMP_INIT(close, _IO_default_close), | 
|  | 54 | JUMP_INIT(stat, _IO_default_stat), | 
|  | 55 | JUMP_INIT(showmanyc, _IO_default_showmanyc), | 
|  | 56 | JUMP_INIT(imbue, _IO_default_imbue) | 
|  | 57 | }; | 
|  | 58 |  | 
|  | 59 |  | 
|  | 60 | int | 
|  | 61 | ___vsprintf_chk (char *s, int flags, size_t slen, const char *format, | 
|  | 62 | va_list args) | 
|  | 63 | { | 
|  | 64 | _IO_strfile f; | 
|  | 65 | int ret; | 
|  | 66 | #ifdef _IO_MTSAFE_IO | 
|  | 67 | f._sbf._f._lock = NULL; | 
|  | 68 | #endif | 
|  | 69 |  | 
|  | 70 | if (slen == 0) | 
|  | 71 | __chk_fail (); | 
|  | 72 |  | 
|  | 73 | _IO_no_init (&f._sbf._f, _IO_USER_LOCK, -1, NULL, NULL); | 
|  | 74 | _IO_JUMPS (&f._sbf) = &_IO_str_chk_jumps; | 
|  | 75 | s[0] = '\0'; | 
|  | 76 | _IO_str_init_static_internal (&f, s, slen - 1, s); | 
|  | 77 |  | 
|  | 78 | /* For flags > 0 (i.e. __USE_FORTIFY_LEVEL > 1) request that %n | 
|  | 79 | can only come from read-only format strings.  */ | 
|  | 80 | if (flags > 0) | 
|  | 81 | f._sbf._f._flags2 |= _IO_FLAGS2_FORTIFY; | 
|  | 82 |  | 
|  | 83 | ret = _IO_vfprintf (&f._sbf._f, format, args); | 
|  | 84 |  | 
|  | 85 | *f._sbf._f._IO_write_ptr = '\0'; | 
|  | 86 | return ret; | 
|  | 87 | } | 
|  | 88 | ldbl_hidden_def (___vsprintf_chk, __vsprintf_chk) | 
|  | 89 | ldbl_strong_alias (___vsprintf_chk, __vsprintf_chk) |