On Sun, 9 Apr 2000, OpenSSL Project wrote:

>     o ERR_error_string(..., buf) does not know how large buf is,
>       there should be ERR_error_string_n(..., buf, bufsize)
>       or similar.

Diff attached.

-d

--
| "Bombay is 250ms from New York in the new world order" - Alan Cox
| Damien Miller - http://www.mindrot.org/
| Email: [EMAIL PROTECTED] (home) -or- [EMAIL PROTECTED] (work)


diff -ru openssl-0.9.5a-orig/crypto/err/err.c openssl-0.9.5a/crypto/err/err.c
--- openssl-0.9.5a-orig/crypto/err/err.c        Tue Mar 14 10:54:30 2000
+++ openssl-0.9.5a/crypto/err/err.c     Mon Apr 10 21:43:33 2000
@@ -510,6 +510,31 @@
        return(ret);
        }
 
+void ERR_error_string_n(unsigned long e, char *buf, size_t len)
+       {
+       char lsbuf[64], fsbuf[64], rsbuf[64];
+       const char *ls,*fs,*rs;
+       unsigned long l,f,r;
+
+       l=ERR_GET_LIB(e);
+       f=ERR_GET_FUNC(e);
+       r=ERR_GET_REASON(e);
+
+       ls=ERR_lib_error_string(e);
+       fs=ERR_func_error_string(e);
+       rs=ERR_reason_error_string(e);
+
+       if (ls == NULL) 
+               snprintf(lsbuf, sizeof(lsbuf), "lib(%lu)", l);
+       if (fs == NULL)
+               snprintf(fsbuf, sizeof(fsbuf), "func(%lu)", f);
+       if (rs == NULL)
+               snprintf(rsbuf, sizeof(rsbuf), "reason(%lu)", r);
+
+       snprintf(buf, len,"error:%08lX:%s:%s:%s", e, ls?ls:lsbuf, 
+               fs?fs:fsbuf, rs?rs:rsbuf);
+       }
+
 LHASH *ERR_get_string_table(void)
        {
        return(error_hash);
diff -ru openssl-0.9.5a-orig/crypto/err/err.h openssl-0.9.5a/crypto/err/err.h
--- openssl-0.9.5a-orig/crypto/err/err.h        Sun Feb  6 08:28:09 2000
+++ openssl-0.9.5a/crypto/err/err.h     Mon Apr 10 21:43:33 2000
@@ -230,6 +230,7 @@
                                       const char **data,int *flags);
 void ERR_clear_error(void );
 char *ERR_error_string(unsigned long e,char *buf);
+void ERR_error_string_n(unsigned long e, char *buf, size_t len);
 const char *ERR_lib_error_string(unsigned long e);
 const char *ERR_func_error_string(unsigned long e);
 const char *ERR_reason_error_string(unsigned long e);
diff -ru openssl-0.9.5a-orig/include/openssl/err.h 
openssl-0.9.5a/include/openssl/err.h
--- openssl-0.9.5a-orig/include/openssl/err.h   Sun Feb  6 08:28:09 2000
+++ openssl-0.9.5a/include/openssl/err.h        Mon Apr 10 21:43:33 2000
@@ -230,6 +230,7 @@
                                       const char **data,int *flags);
 void ERR_clear_error(void );
 char *ERR_error_string(unsigned long e,char *buf);
+void ERR_error_string_n(unsigned long e, char *buf, size_t len);
 const char *ERR_lib_error_string(unsigned long e);
 const char *ERR_func_error_string(unsigned long e);
 const char *ERR_reason_error_string(unsigned long e);

Reply via email to