From 082e84855d5f07c088beac66080cad0b6e1dadc3 Mon Sep 17 00:00:00 2001 From: Toomas Soome Date: Sat, 22 Jun 2019 08:56:38 +0300 Subject: 11270 libipp-listener: strtok() can return NULL and we do leak open file Reviewed by: Gergő Mihály Doma Reviewed by: Norm Jacobs Approved by: Dan McDonald MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- usr/src/lib/print/libipp-listener/common/common.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/usr/src/lib/print/libipp-listener/common/common.c b/usr/src/lib/print/libipp-listener/common/common.c index a18797a879..22ec0dc07d 100644 --- a/usr/src/lib/print/libipp-listener/common/common.c +++ b/usr/src/lib/print/libipp-listener/common/common.c @@ -232,7 +232,6 @@ add_supported_locales(papi_attribute_t ***attributes) papiAttributeListAddString(attributes, PAPI_ATTR_REPLACE, "generated-natural-language-supported", "en-us"); -#ifndef __linux__ /* this is Solaris specific */ if ((fp = fopen("/usr/lib/locale/lcttab", "r")) != NULL) { char buf[1024]; @@ -241,6 +240,8 @@ add_supported_locales(papi_attribute_t ***attributes) int i, passed = 1; name = strtok(buf, " \t\n"); + if (name == NULL) + continue; for (i = 0; ((passed == 1) && (name[i] != NULL)); i++) if (isalpha(name[i]) != 0) @@ -264,8 +265,8 @@ add_supported_locales(papi_attribute_t ***attributes) name); } } + (void) fclose(fp); } -#endif } void -- cgit v1.2.3