redirect-stdout: Perform sanity check on paramters passed to public API 85/256385/2
authorKarol Lewandowski <k.lewandowsk@samsung.com>
Thu, 1 Apr 2021 21:10:52 +0000 (23:10 +0200)
committerKarol Lewandowski <k.lewandowsk@samsung.com>
Fri, 2 Apr 2021 07:33:21 +0000 (09:33 +0200)
Change-Id: I060c05cb88fd834dbf6151e32e0e08056b9e9e9d

src/log-redirect-stdout/lib.c

index d008a43..b2aafe1 100644 (file)
 
 EXPORT_API int connect_dlog(int buffer, int fileno, const char *tag, int prio)
 {
-       if (!tag)
+       if (buffer <= LOG_ID_INVALID || buffer >= LOG_ID_MAX)
+               return -EINVAL;
+
+       if (fileno < 0)
+               return -EINVAL;
+
+       if (!tag || tag[0] == '\0')
+               return -EINVAL;
+
+       if (prio <= DLOG_UNKNOWN || prio >= DLOG_PRIO_MAX)
                return -EINVAL;
 
        __attribute__((cleanup(close_fd))) int fd = -1;