[BusyBox] Re: busybox-cvs Digest, Vol 10, Issue 14

Vladimir N. Oleynik dzo at simtreas.ru
Mon Jan 19 09:38:06 UTC 2004


Glenn,

> Modified Files:
> 	inetd.c 
> Log Message:
> Use bb_get_chomped_line_from_file
> 
> 
> Index: inetd.c
> ===================================================================
> RCS file: /var/cvs/busybox/networking/inetd.c,v
> retrieving revision 1.6
> retrieving revision 1.7
> diff -u -d -r1.6 -r1.7
> --- inetd.c	28 Jul 2003 09:31:27 -0000	1.6
> +++ inetd.c	17 Jan 2004 00:34:31 -0000	1.7
> @@ -302,7 +302,6 @@
>  }
>  
>  static FILE *fconfig;
> -static char line[256];
>  
>  static FILE *
>  setconfig(void)
> @@ -320,20 +319,6 @@
>  }
>  
>  static char *
> -nextline(void)
> -{
> -	char *cp;
> -	FILE *fd = fconfig;
> -
> -	if (fgets(line, sizeof (line), fd) == NULL)
> -		return ((char *)0);
> -	cp = strchr(line, '\n');
> -	if (cp)
> -		*cp = '\0';
> -	return (line);
> -}
> -
> -static char *
>  skip(char **cpp)
>  {
>  	char *cp = *cpp;
> @@ -351,7 +336,8 @@
>  		c = getc(fconfig);
>  		(void) ungetc(c, fconfig);
>  		if (c == ' ' || c == '\t')
> -			if ((cp = nextline()) != NULL)
> +			cp = bb_get_chomped_line_from_file(fconfig);
> +			if (cp != NULL)

Its bad ideas.
Your make dynamic memory allocation (but not require) from daemon
with exiting after error and make memory leak after sighup signaled and reread 
config.



--w
vodz




More information about the busybox mailing list