This is a multi-part message in MIME format.
--------------030206050307030704030908
Content-Type: text/plain; charset=ISO-8859-15
Content-Transfer-Encoding: 7bit
Hendrik Baecker wrote:
Based on your patch, i suggest this construction, to avoid open dirhandles.
Best regards
Herbert Straub
> There was a typo in my last patch according to the try to printout the
> actual temp_path value with snprintf...
>
> Please take this patch instead!
>
> Regards
> Hendrik
>
> ------------------------------------------------------------------------
>
> --- ./nagios3-clean/base/config.c 2007-03-25 10:06:23.000000000 +0200
> +++ ./nagios3/base/config.c 2007-03-25 11:18:09.000000000 +0200
> @@ -404,6 +404,20 @@
> break;
> }
>
> + if(opendir((char *)value)==NULL){
> + strcpy(error_message,"Temp path is not valid");
> + error=TRUE;
> + break;
> + }
> + // Maybe we should close the dirhandle but what to close
> + // without a normal DIR handle?
> + // With a temp DIR Handle there would be a new only temp variable...
> + //
> + // closedir(SOMESTUPID_HANDLE);
> + //
> + // Maybe we should check if the DIR Handle is writeable by us?
> + // AFAIK we need ...
> +
> my_free((void **)&temp_path);
> if((temp_path=(char *)strdup(value))){
> strip(temp_path);
>
> ------------------------------------------------------------------------
--------------030206050307030704030908
Content-Type: text/x-patch;
name="config.c.-temp_path_checking-v2-hs.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="config.c.-temp_path_checking-v2-hs.patch"
--- base/config.c.orig 2007-03-25 14:52:52.000000000 +0200
+++ base/config.c 2007-03-25 15:04:55.000000000 +0200
@@ -398,12 +398,20 @@
else if(!strcmp(variable,"temp_path")){
+ DIR *tmpdir;
if(strlen(value)>MAX_FILENAME_LENGTH-1){
strcpy(error_message,"Temp path is too long");
error=TRUE;
break;
}
+ if((tmpdir=opendir((char *)value))==NULL){
+ strcpy(error_message,"Temp path is not valid");
+ error=TRUE;
+ break;
+ }
+ closedir(tmpdir);
+
my_free((void **)&temp_path);
if((temp_path=(char *)strdup(value))){
strip(temp_path);
--------------030206050307030704030908--
This post was automatically imported from historical nagios-devel mailing list archives
Original poster: [email protected]