From: aland Date: Wed, 18 Aug 1999 00:44:05 +0000 (+0000) Subject: allowed for the possibility we might be logging log messages X-Git-Tag: first-build~72 X-Git-Url: http://www.project-moonshot.org/gitweb/?a=commitdiff_plain;h=af5ee806b24186635d073bd1c4ee640e91c20439;p=freeradius.git allowed for the possibility we might be logging log messages in librad_log, through the use of a local buffer added more descriptive warning messages to dict.c --- diff --git a/src/lib/dict.c b/src/lib/dict.c index 91bea62..9ba6762 100644 --- a/src/lib/dict.c +++ b/src/lib/dict.c @@ -166,11 +166,11 @@ static int my_dict_init(char *dir, char *fn) FILE *fp; char dirtmp[256]; char buf[256]; - char namestr[64]; - char valstr[64]; - char attrstr[64]; - char typestr[64]; - char vendorstr[64]; + char namestr[256]; + char valstr[256]; + char attrstr[256]; + char typestr[256]; + char vendorstr[256]; char *p; char *keyword; char *data; @@ -257,6 +257,7 @@ static int my_dict_init(char *dir, char *fn) if (is_nmc && vendorstr[0] == 0) { if (!vendor_usr_seen) { if (dict_addvendor("USR", VENDORPEC_USR) < 0) + librad_log("dict_init: %s[%d]: %s", fn, line, librad_errstr); return -1; vendor_usr_seen = 1; } @@ -298,6 +299,8 @@ static int my_dict_init(char *dir, char *fn) } if (dict_addattr(namestr, vendor, type, value) < 0) { + librad_log("dict_init: %s[%d]: %s", + fn, line, librad_errstr); return -1; } @@ -334,6 +337,8 @@ static int my_dict_init(char *dir, char *fn) sscanf(valstr, "%i", &value); if (dict_addvalue(namestr, attrstr, value) < 0) { + librad_log("dict_init: %s[%d]: %s", + fn, line, librad_errstr); return -1; } } @@ -361,8 +366,11 @@ static int my_dict_init(char *dir, char *fn) value = atoi(valstr); /* Create a new VENDOR entry for the list */ - if (dict_addvendor(attrstr, value) < 0) + if (dict_addvendor(attrstr, value) < 0) { + librad_log("dict_init: %s[%d]: %s", + fn, line, librad_errstr); return -1; + } #ifdef ATTRIB_NMC if (value == VENDORPEC_USR) vendor_usr_seen = 1; diff --git a/src/lib/log.c b/src/lib/log.c index 768567a..a00f91c 100644 --- a/src/lib/log.c +++ b/src/lib/log.c @@ -15,16 +15,26 @@ char librad_errstr[1024]; +/* + * Do logging to a static buffer. Note that we MIGHT be asked + * to write a previous log message to librad_errstr. + * + * This also isn't multithreaded-safe, so it'll have to be changed + * in the future. + */ void librad_log(char *fmt, ...) { va_list ap; + char my_errstr[sizeof(librad_errstr)]; va_start(ap, fmt); + #ifdef HAVE_VSNPRINTF - vsnprintf(librad_errstr, sizeof(librad_errstr), fmt, ap); + vsnprintf(my_errstr, sizeof(my_errstr), fmt, ap); #else - vsprintf(librad_errstr, fmt, ap); + vsprintf(my_errstr, fmt, ap); #endif + strcpy(librad_errstr, my_errstr); va_end(ap); } @@ -38,4 +48,3 @@ void librad_perror(char *fmt, ...) fprintf(stderr, ": "); fprintf(stderr, "%s\n", librad_errstr); } -