centos 7
format weakness #22

4

Weakness Breakdown


Definition:

A format string exploit occurs when the data of an input string is evaluated as a command by the program. This class of attacks is very similar to buffer overflows since an attacker could execute code, read the stack or cause new behaviors that compromise security. Learn more about format string attacks on OWASP attack index.

Warning code(s):

If format strings can be influenced by an attacker, they can be exploited, and note that sprintf variations do not always 0-terminate.

File Name:

libquvi-0.4.1/src/libquvi/vasprintf.c

Context:

The highlighted line of code below is the trigger point of this particular Centos 7 format weakness.

  * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
 * 02110-1301  USA
 */

#include <stdio.h>
#include <stdarg.h>
#include <stdlib.h>

int vasprintf(char **dst, const char *fmt, va_list ap)
{
  va_list apc;
  int len;
  char *p;

  va_copy(apc, ap);
  len = vsnprintf(0, 0, fmt, apc) + 1;
  va_end(apc);

  *dst = p = malloc(len);
  if (!p)
    return (-1);

  return (vsnprintf(p, len, fmt, ap));
}

/* vim: set ts=2 sw=2 tw=72 expandtab: */ 

The registered trademark Linux® is used pursuant to a sublicense from the Linux Foundation, the exclusive licensee of Linus Torvalds, owner of the mark on a world­wide basis.