Changeset 22 for trunk/src/slib.c


Ignore:
Timestamp:
Feb 23, 2006, 12:03:58 AM (19 years ago)
Author:
rainer
Message:

Minor code revisions.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/slib.c

    r20 r22  
    231231  if (flag == 1)
    232232    {
    233       sprintf        (val, _("\n---------  %10s "), file);
     233      sl_snprintf    (val, 81, _("\n---------  %10s "), file);
    234234      sl_strlcpy     (msg,    val,   80);
    235       sprintf        (val, _(" --- %6d ---------\n"), line);
     235      sl_snprintf    (val, 81, _(" --- %6d ---------\n"), line);
    236236      sl_strlcat     (msg,     val,   80);
    237237      sh_log_console (msg);
     
    578578#if !defined(HOST_IS_I86SOLARIS)
    579579#if !defined (_GNU_SOURCE)
     580/* flawfinder: ignore */
    580581extern int vsnprintf ( char *str, size_t n,
    581582                       const char *format, va_list ap );
     
    777778
    778779#if defined(HAVE_VSNPRINTF) && !defined(HAVE_BROKEN_VSNPRINTF)
    779   len = vsnprintf (str, n, format, vl);
     780  len = vsnprintf (str, n, format, vl);                /* flawfinder: ignore */
    780781  str[n-1] = '\0';
    781782#else
    782   VA_COPY (vl2, vl);                   /* save the argument list           */
     783  VA_COPY (vl2, vl);                     /* save the argument list           */
    783784  total = sl_printf_count (format, vl);
    784   len   = (int) total;
     785  len = (int) total;
    785786  if (total < n)
    786787    {
     788      /* flawfinder: ignore */
    787789      vsprintf (str, format, vl2);       /* program has checked that it fits */
    788790      str[n-1] = '\0';
     
    804806 * ENULL:  src || format == NULL
    805807 * ERANGE: n out of range
    806  * ETRUNC: truncated
     808 * ETRUNC: truncated (unimplemented)
    807809 */
    808810int sl_snprintf(char *str, size_t n,
     
    821823  va_start (vl, format);
    822824#if defined(HAVE_VSNPRINTF) && !defined(HAVE_BROKEN_VSNPRINTF)
     825  /* flawfinder: ignore */
    823826  vsnprintf (str, n, format, vl);
    824827  str[n-1] = '\0';
     
    828831  if (total < n)
    829832    {
     833      /* flawfinder: ignore */
    830834      vsprintf (str, format, vl2);     /* program has checked that it fits */
    831835      str[n-1] = '\0';
     
    15681572SL_TICKET sl_make_ticket (int fd, char * filename)
    15691573{
     1574  size_t    len;
    15701575  SL_TICKET ticket;
    15711576  SL_ENTER(_("sl_make_ticket"));
     
    15871592    }
    15881593
    1589    if ( (ofiles[fd]->path = (char *) malloc( strlen(filename)+1) ) == NULL)
     1594  len = sl_strlen(filename)+1;
     1595
     1596  if ( (ofiles[fd]->path = (char *) malloc(len) ) == NULL)
    15901597    {
    15911598      free(ofiles[fd]);
     
    16051612    }
    16061613
    1607   strcpy (ofiles[fd]->path, filename);                    /* Known to fit  */
     1614  sl_strlcpy (ofiles[fd]->path, filename, len);
    16081615  ofiles[fd]->ticket = ticket;
    16091616  ofiles[fd]->fd     = fd;
     
    16461653  int           fd;
    16471654  int           sflags;
     1655  size_t        len;
    16481656  SL_TICKET     ticket;
    16491657 
     
    18201828    }
    18211829
    1822    if ( (ofiles[fd]->path = (char *) malloc( strlen(filename)+1) ) == NULL)
     1830  len = sl_strlen(filename)+1;
     1831
     1832  if ( (ofiles[fd]->path = (char *) malloc(len) ) == NULL)
    18231833    {
    18241834      free(ofiles[fd]);
     
    18401850    }
    18411851
    1842   strcpy (ofiles[fd]->path, filename);                    /* Known to fit  */
     1852  sl_strlcpy (ofiles[fd]->path, filename, len);
    18431853  ofiles[fd]->ticket = ticket;
    18441854  ofiles[fd]->fd     = fd;
Note: See TracChangeset for help on using the changeset viewer.