diff options
Diffstat (limited to 'usr/src')
-rw-r--r-- | usr/src/cmd/lp/lib/papi/service.c | 25 | ||||
-rw-r--r-- | usr/src/lib/print/libpapi-dynamic/common/service.c | 27 | ||||
-rw-r--r-- | usr/src/lib/print/libpapi-ipp/common/service.c | 25 | ||||
-rw-r--r-- | usr/src/lib/print/libpapi-lpd/common/service.c | 23 |
4 files changed, 37 insertions, 63 deletions
diff --git a/usr/src/cmd/lp/lib/papi/service.c b/usr/src/cmd/lp/lib/papi/service.c index a15434fcfb..38f9ba60c2 100644 --- a/usr/src/cmd/lp/lib/papi/service.c +++ b/usr/src/cmd/lp/lib/papi/service.c @@ -23,15 +23,10 @@ * Use is subject to license terms. */ -#pragma ident "%Z%%M% %I% %E% SMI" - -/*LINTLIBRARY*/ - #include <stdlib.h> #include <stdio.h> #include <stdarg.h> #include <string.h> -#include <alloca.h> #include <libintl.h> #include <papi_impl.h> @@ -284,20 +279,18 @@ detailed_error(service_t *svc, char *fmt, ...) { if ((svc != NULL) && (fmt != NULL)) { va_list ap; - size_t size; - char *message = alloca(BUFSIZ); + char *message; + int rv; va_start(ap, fmt); - /* - * fill in the message. If the buffer is too small, allocate - * one that is large enough and fill it in. - */ - if ((size = vsnprintf(message, BUFSIZ, fmt, ap)) >= BUFSIZ) - if ((message = alloca(size)) != NULL) - vsnprintf(message, size, fmt, ap); + rv = vasprintf(&message, fmt, ap); va_end(ap); - papiAttributeListAddString(&svc->attributes, PAPI_ATTR_APPEND, - "detailed-status-message", message); + if (rv >= 0) { + papiAttributeListAddString(&svc->attributes, + PAPI_ATTR_APPEND, "detailed-status-message", + message); + free(message); + } } } diff --git a/usr/src/lib/print/libpapi-dynamic/common/service.c b/usr/src/lib/print/libpapi-dynamic/common/service.c index 55f1732a65..fb1316f559 100644 --- a/usr/src/lib/print/libpapi-dynamic/common/service.c +++ b/usr/src/lib/print/libpapi-dynamic/common/service.c @@ -27,17 +27,12 @@ /* $Id: service.c 172 2006-05-24 20:54:00Z njacobs $ */ -#pragma ident "%Z%%M% %I% %E% SMI" - -/*LINTLIBRARY*/ - #include <stdlib.h> #include <stdio.h> #include <stdarg.h> #include <sys/types.h> #include <unistd.h> #include <string.h> -#include <alloca.h> #include <libintl.h> #include <papi_impl.h> #include <config-site.h> @@ -550,23 +545,21 @@ detailed_error(service_t *svc, char *fmt, ...) { if ((svc != NULL) && (fmt != NULL)) { va_list ap; - size_t size; - char *message = alloca(BUFSIZ); + char *message; + int rv; va_start(ap, fmt); - /* - * fill in the message. If the buffer is too small, allocate - * one that is large enough and fill it in. - */ - if ((size = vsnprintf(message, BUFSIZ, fmt, ap)) >= BUFSIZ) - if ((message = alloca(size)) != NULL) - vsnprintf(message, size, fmt, ap); + rv = vasprintf(&message, fmt, ap); va_end(ap); - papiAttributeListAddString(&svc->attributes, PAPI_ATTR_APPEND, - "detailed-status-message", message); + if (rv >= 0) { + papiAttributeListAddString(&svc->attributes, + PAPI_ATTR_APPEND, "detailed-status-message", + message); #ifdef DEBUG - fprintf(stderr, "detailed_error(%s)\n", message); + fprintf(stderr, "detailed_error(%s)\n", message); #endif + free(message); + } } } diff --git a/usr/src/lib/print/libpapi-ipp/common/service.c b/usr/src/lib/print/libpapi-ipp/common/service.c index e5531f1422..eac12c17f3 100644 --- a/usr/src/lib/print/libpapi-ipp/common/service.c +++ b/usr/src/lib/print/libpapi-ipp/common/service.c @@ -27,15 +27,10 @@ /* $Id: service.c 171 2006-05-20 06:00:32Z njacobs $ */ -#pragma ident "%Z%%M% %I% %E% SMI" - -/*LINTLIBRARY*/ - #include <stdlib.h> #include <stdio.h> #include <stdarg.h> #include <string.h> -#include <alloca.h> #include <libintl.h> #include <papi_impl.h> @@ -375,20 +370,18 @@ detailed_error(service_t *svc, char *fmt, ...) { if ((svc != NULL) && (fmt != NULL)) { va_list ap; - size_t size; - char *message = alloca(BUFSIZ); + char *message; + int rv; va_start(ap, fmt); - /* - * fill in the message. If the buffer is too small, allocate - * one that is large enough and fill it in. - */ - if ((size = vsnprintf(message, BUFSIZ, fmt, ap)) >= BUFSIZ) - if ((message = alloca(size)) != NULL) - vsnprintf(message, size, fmt, ap); + rv = vasprintf(&message, fmt, ap); va_end(ap); - papiAttributeListAddString(&svc->attributes, PAPI_ATTR_APPEND, - "detailed-status-message", message); + if (rv >= 0) { + papiAttributeListAddString(&svc->attributes, + PAPI_ATTR_APPEND, "detailed-status-message", + message); + free(message); + } } } diff --git a/usr/src/lib/print/libpapi-lpd/common/service.c b/usr/src/lib/print/libpapi-lpd/common/service.c index c39ea0cbb5..7d5eccf1d9 100644 --- a/usr/src/lib/print/libpapi-lpd/common/service.c +++ b/usr/src/lib/print/libpapi-lpd/common/service.c @@ -27,13 +27,10 @@ /* $Id: service.c 163 2006-05-09 15:07:45Z njacobs $ */ -#pragma ident "%Z%%M% %I% %E% SMI" - #include <stdlib.h> #include <stdio.h> #include <string.h> #include <stdarg.h> -#include <alloca.h> #include <uri.h> #include <papi_impl.h> @@ -280,20 +277,18 @@ detailed_error(service_t *svc, char *fmt, ...) { if ((svc != NULL) && (fmt != NULL)) { va_list ap; - size_t size; - char *message = alloca(BUFSIZ); + char *message; + int rv; va_start(ap, fmt); - /* - * fill in the message. If the buffer is too small, allocate - * one that is large enough and fill it in. - */ - if ((size = vsnprintf(message, BUFSIZ, fmt, ap)) >= BUFSIZ) - if ((message = alloca(size)) != NULL) - vsnprintf(message, size, fmt, ap); + rv = vasprintf(&message, fmt, ap); va_end(ap); - papiAttributeListAddString(&svc->attributes, PAPI_ATTR_APPEND, - "detailed-status-message", message); + if (rv >= 0) { + papiAttributeListAddString(&svc->attributes, + PAPI_ATTR_APPEND, "detailed-status-message", + message); + free(message); + } } } |