cvs commit: ALFS/nALFS/src options.c

kpfleming at linuxfromscratch.org kpfleming at linuxfromscratch.org
Tue Nov 4 20:28:56 PST 2003


kpfleming    03/11/04 21:28:56

  Modified:    nALFS/src options.c
  Log:
  check vsnprintf() return value to ensure that we don't try to print an uninitialized buffer
  
  Revision  Changes    Path
  1.17      +5 -3      ALFS/nALFS/src/options.c
  
  Index: options.c
  ===================================================================
  RCS file: /home/cvsroot/ALFS/nALFS/src/options.c,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- options.c	5 Nov 2003 04:22:41 -0000	1.16
  +++ options.c	5 Nov 2003 04:28:56 -0000	1.17
  @@ -193,10 +193,12 @@
   	char buffer[MAX_ERROR_MSG_LEN];
   
   	va_start(ap, format);
  -	vsnprintf(buffer, sizeof buffer, format, ap);
  +	if (vsnprintf(buffer, sizeof buffer, format, ap) > 0)
  +		Nprint_err("Option \"%s\" invalid value: %s",
  +			   option->name, buffer);
  +	else
  +		Nprint_err("Option \"%s\" invalid value", option->name);
   	va_end(ap);
  -	Nprint_err("Option \"%s\" invalid value: %s",
  -		   option->name, buffer);
   }
   
   static int validate_number_minmax(const struct option_s *option,
  
  
  



More information about the alfs-log mailing list