[FIX] prevent issue 93/45093/3
authorVitaliy Cherepanov <v.cherepanov@samsung.com>
Fri, 31 Jul 2015 09:55:47 +0000 (12:55 +0300)
committerVyacheslav Cherkashin <v.cherkashin@samsung.com>
Tue, 4 Aug 2015 09:06:50 +0000 (02:06 -0700)
---------------------------------------------------------------------------------------|
| CID    | Type                          | File              | Function                |
|--------------------------------------------------------------------------------------|
| 453611 | Dereference null return value | daemon/sys_stat.c | get_device_network_type |
|--------------------------------------------------------------------------------------|

Change-Id: Icca85037dedbc86692579c1ab00130f6cb52bb39
Signed-off-by: Vitaliy Cherepanov <v.cherepanov@samsung.com>
daemon/sys_stat.c

index 0b786b8..2abe299 100644 (file)
@@ -1234,25 +1234,27 @@ exit:
 // overall information getter functions
 // ========================================================================
 
-char *print_to_buf(char *buf, size_t *buflen, char *str)
+static char *print_to_buf(char *buf, size_t *buflen, char *str)
 {
        int len = 0;
        int lenin = 0;
 
-       if (strlen(str) > *buflen)
-               goto error_exit;
+       if (strlen(str) > *buflen) {
+               LOGE("can not pack <%s>\n", str);
+               goto exit;
+       }
 
        lenin = snprintf(buf + len, *buflen, str);
-       if (lenin <= 0)
-               goto error_exit;
+       if (lenin <= 0) {
+               LOGE("can not pack <%s>\n", str);
+               goto exit;
+       }
 
        buf += lenin;
        *buflen -= lenin;
 
+exit:
        return buf;
-error_exit:
-       LOGE("can not pack <%s>\n", str);
-       return NULL;
 
 }