Skip to content

Commit

Permalink
add lua script
Browse files Browse the repository at this point in the history
  • Loading branch information
laffer1 committed Dec 22, 2023
1 parent 4bcc93d commit e74df84
Show file tree
Hide file tree
Showing 2 changed files with 691 additions and 0 deletions.
39 changes: 39 additions & 0 deletions tools/coccinelle/copystr9.cocci
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
@ nostorederror_nostoredlen @
expression __src, __dst, __len;
statement S1;
@@

S1
-copystr(__src, __dst, __len, NULL);
+strlcpy(__dst, __src, __len);

@ ifcondition_nostoredlen @
expression __src, __dst, __len;
statement S1;
@@
if (
(
-copystr(__src, __dst, __len, NULL) == ENAMETOOLONG
|
-copystr(__src, __dst, __len, NULL) != 0
|
-copystr(__src, __dst, __len, NULL)
)
+strlcpy(__dst, __src, __len) >= __len
) S1

@ nostorederror_storedlen1 @
expression __src, __dst, __len;
identifier __done;
statement S1;
@@
S1
(
-copystr(__src, __dst, __len, &__done);
+__done = strlcpy(__dst, __src, __len);
+__done = MIN(__done, __len);
|
-copystr(__src, __dst, __len, __done);
+ *__done = strlcpy(__dst, __src, __len);
+ *__done = MIN(*__done, __len);
)
Loading

0 comments on commit e74df84

Please sign in to comment.