Changeset 690

Show
Ignore:
Timestamp:
12/29/09 08:50:09 (2 years ago)
Author:
erikd
Message:

src/param.c : Fix dangerous usage of snprintf.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • sweep/trunk/src/param.c

    r688 r690  
    675675 
    676676  if (proc->description != NULL) { 
    677     n = snprintf (buf, BUF_LEN, "%s\n\n", _(proc->description)); 
    678   } 
    679  
    680   if (proc->author != NULL) { 
    681     n += snprintf (buf+n, BUF_LEN, "by %s", proc->author); 
    682   } 
    683  
    684   if (proc->copyright != NULL) { 
    685     n += snprintf (buf+n, BUF_LEN, ", %s.\n", proc->copyright); 
    686   } 
    687  
    688   if (proc->url != NULL) { 
    689     n += snprintf (buf+n, BUF_LEN, "\nFor more information see\n%s\n", 
     677    n = snprintf (buf, sizeof (buf), "%s\n\n", _(proc->description)); 
     678  } 
     679 
     680  if (n < sizeof (buf) && proc->author != NULL) { 
     681    n += snprintf (buf+n, sizeof (buf)-n, "by %s", proc->author); 
     682  } 
     683 
     684  if (n < sizeof (buf) && proc->copyright != NULL) { 
     685    n += snprintf (buf+n, sizeof (buf)-n, ", %s.\n", proc->copyright); 
     686  } 
     687 
     688  if (n < sizeof (buf) && proc->url != NULL) { 
     689    n += snprintf (buf+n, sizeof (buf)-n, "\nFor more information see\n%s\n", 
    690690                   proc->url); 
    691691  }