IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 8526


Ignore:
Timestamp:
Aug 23, 2006, 1:23:13 PM (20 years ago)
Author:
jhoblitt
Message:

fix a buffer overflow in psDBIntToString() by correctly calculating the length of the string and using snprintf instead of sprintf

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/src/db/psDB.c

    r8461 r8526  
    1212 *  @author Joshua Hoblitt
    1313 *
    14  *  @version $Revision: 1.84 $ $Name: not supported by cvs2svn $
    15  *  @date $Date: 2006-08-22 02:41:22 $
     14 *  @version $Revision: 1.85 $ $Name: not supported by cvs2svn $
     15 *  @date $Date: 2006-08-23 23:23:13 $
    1616 *
    1717 *  Copyright (C) 2005-2006  Joshua Hoblitt, University of Hawaii
     
    21252125static char *psDBIntToString(psU64 n)
    21262126{
    2127     // length of string + \0
     2127    // length of string (log10 + 1) + \0
    21282128    // if n is 0, length is 1 char + \0
    2129     size_t length = n ? (size_t)log10((double)n) + 1
     2129    size_t length = n ? (size_t)log10((double)n) + 1 + 1
    21302130                    : 2;
    21312131    char *string = psAlloc(length);
    2132     sprintf(string, "%li", (long int)n);
     2132    snprintf(string, length, "%li", (long int)n);
    21332133
    21342134    return string;
Note: See TracChangeset for help on using the changeset viewer.