teknoraver / rpms / systemd

Forked from rpms/systemd 3 months ago
Clone

Blame SOURCES/0682-lgtm-beef-up-list-of-dangerous-questionnable-API-cal.patch

be0c12
From 8b60932555141e1fe61a343863eae7655c2449a9 Mon Sep 17 00:00:00 2001
be0c12
From: Lennart Poettering <lennart@poettering.net>
be0c12
Date: Tue, 2 Apr 2019 12:43:47 +0200
be0c12
Subject: [PATCH] lgtm: beef up list of dangerous/questionnable API calls not
be0c12
 to make
be0c12
be0c12
(cherry picked from commit 9b4805421eb2a7319f6507a26febfb9d2cdc3a93)
be0c12
be0c12
Related: #2017033
be0c12
---
be0c12
 .../PotentiallyDangerousFunction.ql           | 22 +++++++++++++++++--
be0c12
 1 file changed, 20 insertions(+), 2 deletions(-)
be0c12
be0c12
diff --git a/.lgtm/cpp-queries/PotentiallyDangerousFunction.ql b/.lgtm/cpp-queries/PotentiallyDangerousFunction.ql
be0c12
index ba80f4ad8c..cd0284b37a 100644
be0c12
--- a/.lgtm/cpp-queries/PotentiallyDangerousFunction.ql
be0c12
+++ b/.lgtm/cpp-queries/PotentiallyDangerousFunction.ql
be0c12
@@ -16,10 +16,28 @@ import cpp
be0c12
 predicate potentiallyDangerousFunction(Function f, string message) {
be0c12
   (
be0c12
     f.getQualifiedName() = "fgets" and
be0c12
-    message = "Call to fgets is potentially dangerous. Use read_line() instead."
be0c12
+    message = "Call to fgets() is potentially dangerous. Use read_line() instead."
be0c12
   ) or (
be0c12
     f.getQualifiedName() = "strtok" and
be0c12
-    message = "Call to strtok is potentially dangerous. Use extract_first_word() instead."
be0c12
+    message = "Call to strtok() is potentially dangerous. Use extract_first_word() instead."
be0c12
+  ) or (
be0c12
+    f.getQualifiedName() = "strsep" and
be0c12
+    message = "Call to strsep() is potentially dangerous. Use extract_first_word() instead."
be0c12
+  ) or (
be0c12
+    f.getQualifiedName() = "dup" and
be0c12
+    message = "Call to dup() is potentially dangerous. Use fcntl(fd, FD_DUPFD_CLOEXEC, 3) instead."
be0c12
+  ) or (
be0c12
+    f.getQualifiedName() = "htonl" and
be0c12
+    message = "Call to htonl() is confusing. Use htobe32() instead."
be0c12
+  ) or (
be0c12
+    f.getQualifiedName() = "htons" and
be0c12
+    message = "Call to htons() is confusing. Use htobe16() instead."
be0c12
+  ) or (
be0c12
+    f.getQualifiedName() = "ntohl" and
be0c12
+    message = "Call to ntohl() is confusing. Use be32toh() instead."
be0c12
+  ) or (
be0c12
+    f.getQualifiedName() = "ntohs" and
be0c12
+    message = "Call to ntohs() is confusing. Use be16toh() instead."
be0c12
   )
be0c12
 }
be0c12