vasprintf.c (267897) | vasprintf.c (275698) |
---|---|
1/* 2 * Copyright (c) Ian F. Darwin 1986-1995. 3 * Software written by Ian F. Darwin and others; 4 * maintained 1995-present by Christos Zoulas and others. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: --- 94 unchanged lines hidden (view full) --- 103code to handle those situations (only one place to modify). 104A buffer overflow can only occur if your sprintf() do strange things or when 105you use strange formats. 106 107*/ 108#include "file.h" 109 110#ifndef lint | 1/* 2 * Copyright (c) Ian F. Darwin 1986-1995. 3 * Software written by Ian F. Darwin and others; 4 * maintained 1995-present by Christos Zoulas and others. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: --- 94 unchanged lines hidden (view full) --- 103code to handle those situations (only one place to modify). 104A buffer overflow can only occur if your sprintf() do strange things or when 105you use strange formats. 106 107*/ 108#include "file.h" 109 110#ifndef lint |
111FILE_RCSID("@(#)$File: vasprintf.c,v 1.12 2014/05/14 23:09:21 christos Exp $") | 111FILE_RCSID("@(#)$File: vasprintf.c,v 1.13 2014/12/04 15:56:46 christos Exp $") |
112#endif /* lint */ 113 114#include <assert.h> 115#include <string.h> 116#include <stdlib.h> 117#include <stdarg.h> 118#include <ctype.h> 119#ifdef HAVE_LIMITS_H --- 508 unchanged lines hidden (view full) --- 628{ 629 xprintf_struct s; 630 int retval; 631 632 s.src_string = format_string; 633#ifdef va_copy 634 va_copy (s.vargs, vargs); 635#else | 112#endif /* lint */ 113 114#include <assert.h> 115#include <string.h> 116#include <stdlib.h> 117#include <stdarg.h> 118#include <ctype.h> 119#ifdef HAVE_LIMITS_H --- 508 unchanged lines hidden (view full) --- 628{ 629 xprintf_struct s; 630 int retval; 631 632 s.src_string = format_string; 633#ifdef va_copy 634 va_copy (s.vargs, vargs); 635#else |
636#ifdef __va_copy | 636# ifdef __va_copy |
637 __va_copy (s.vargs, vargs); | 637 __va_copy (s.vargs, vargs); |
638#else | 638# else 639# ifdef WIN32 640 s.vargs = vargs; 641# else |
639 memcpy (&s.vargs, &vargs, sizeof (s.va_args)); | 642 memcpy (&s.vargs, &vargs, sizeof (s.va_args)); |
640#endif /* __va_copy */ | 643# endif /* WIN32 */ 644# endif /* __va_copy */ |
641#endif /* va_copy */ 642 s.maxlen = (size_t)INT_MAX; 643 644 retval = core(&s); 645 va_end(s.vargs); 646 if (retval == EOF) { 647 *ptr = NULL; 648 return EOF; 649 } 650 651 *ptr = s.buffer_base; 652 return retval; 653} | 645#endif /* va_copy */ 646 s.maxlen = (size_t)INT_MAX; 647 648 retval = core(&s); 649 va_end(s.vargs); 650 if (retval == EOF) { 651 *ptr = NULL; 652 return EOF; 653 } 654 655 *ptr = s.buffer_base; 656 return retval; 657} |