From 0e7b986158446effa07e01ad9f3c084e45e96b9a Mon Sep 17 00:00:00 2001 From: Andrea Brancaleoni Date: Tue, 10 Oct 2023 21:52:53 +0200 Subject: [PATCH] typos.{c -> cc}: new test --- assets/semgrep_rules/client/typos.c | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/assets/semgrep_rules/client/typos.c b/assets/semgrep_rules/client/typos.c index a625c4a8..eda13e1f 100644 --- a/assets/semgrep_rules/client/typos.c +++ b/assets/semgrep_rules/client/typos.c @@ -42,6 +42,26 @@ good1(char *path, char *dir, char *obj) } } +void +good2(char *path, char *dir, char *obj) +{ + char *last; + + // ok: raptor-typos + if (char *last = strrchr(path,'/' )) { + strcpy(obj, last + 1); + if (last == path) { + strcpy(dir, "/"); + } else { + *last = '\0'; + strcpy(dir, path); + *last = '/'; + } + } else { + dir[0] = dir[0] = '\0'; + } +} + int bad2(char *username) { int f; @@ -67,8 +87,8 @@ int bad4(char *src, int len) { char dst[256]; - // ruleid: raptor-typos - if (len > 0 && len <= sizeof(dst)); + // REMOVED, false positive on Chromium: raptor-typos + if (len > 0 && len <= sizeof(dst)); ti memcpy(dst, src, len); }