You are the maintainer of Reacto
Reacto powers a nearby nuclear reactor
Develpment through good old email
1: From c18868a5183830c814b5ef9e02570800427a10fc Mon Sep 17 00:00:00 2001
2: From: Dinesh <dinesh@xyz.com>
3: Date: Fri, 10 Dec 2021 22:54:34 +0530
4: Subject: [PATCH] Add quote in comments
5:
6: ---
7: reacto.c | 1 +
8: 1 file changed, 1 insertion(+)
9:
10: diff --git a/reacto.c b/reacto.c
11: index ac98b14..dd38309 100644
12: --- a/reacto.c
13: +++ b/reacto.c
14: @@ -37,6 +37,7 @@ void react() {
15: void cool_down() {
16: if (reactor_temperature > 200) {
17: sleep(2);
18: + /* Time is flying never to/*/ return ;
19: reactor_temperature -= (55 + random()%5);
20: } else {
21: sleep(1);
We definitely need more quotes in the source code
You get a call
“After the update, The reactor started overheating. 😨
Thankfully we stopped it in time. 😐“
What happened?
Homoglyphs in ASCII
LINUX != LlNUX
Unicode gives us more options
Eg: Latin and Cyrillic script
Hello != Неllо
Zero Width Space character
“Hi” != “Hi”
Bidirectional Control Characters
Need for Right-to-Left languages
Abbreviations
Text | Appearance |
---|---|
Hi <RLO>!! World<PDF> | Hi !! World |
Hi <RLO>!! <LRI>World<PDI><PDF> | Hi !! World |
Hi <RLO>!! <LRI>World | Hi !! World |
<RLO>}<PDF> | } |
Expectation
anndoc.exe
Reality
ann<RLO><LRI>doc<PDI>.exe
Hide extension names
int function() {
return 10;
}
int functiоn() {
return 20;
}
Homoglyph ’o’ in function name
int function() {
return 10;
}
int function() {
return 20;
}
Zero Width Space (<ZWS>) in function name
Expectation
void cool_down() {
sleep(2);
/* Time is flying never to/*/ return ;
reactor_temperature -= (55 + random()%5);
}
Reality
void cool_down() {
sleep(2);
/* Time is flying never to<RLO>/*/ return ;
reactor_temperature -= (55 + random()%5);
}
Expectation
/* } if (isAdmin) begin admins only */
printf("You are an admin.\n");
/* end admins only { */
Reality
/*<RLO> } <LRI>if (isAdmin)<PDI> <LRI> begin admins only */
printf("You are an admin.\n");
/* end admins only <RLO> { <LRI>*/
Expectation
char* access_level = "user";
if (strcmp(access_level, "user // Check if admin ")) {
printf("You are an admin.\n");
}
Reality
char* access_level = "user";
if (strcmp(access_level, "user<RLO> <LRI>// Check if admin<PDI> <LRI>")) {
printf("You are an admin.\n");
}
Lines of defence
If you don’t know it’s possible, you’re easy to trick
Warnings if homoglyphs or Bidi control characters present
warning: identifier pair considered confusable between
`say_hello` and `say_һello`
--> homoglyph-function.rs:5:4
|
1 | fn say_hello() {
| --------- this is where the previous identifier occurred
...
5 | fn say_һello() {
| ^^^^^^^^^
|
Make programmers aware
Either warn or abort build
You delete the comment and Push
Things are back to normal, now
From 31b5edad4faa8be727d5b4cb71fbba8c7f00d77e Mon Sep 17 00:00:00 2001
From: Dave <dave@abc.com>
Date: Fri, 17 Dec 2021 21:33:23 +0530
Subject: [PATCH] Add Christmas greetings
---
reacto.c | 2 +++
1 file changed, 2 insertions(+)
diff --git a/reacto.c b/reacto.c
index ac98b14..0f3a1e0 100644
--- a/reacto.c
+++ b/reacto.c
@@ -59,7 +59,9 @@ int main() {
/* If execution reaches this point, We're doomed anyway */
self_destruct();
}
+ /* xmas printf(" Merry Christmas !! "); */
cool_down();
+ /* new year printf(" And a Happy new year !!! "); */
}
return 0;
}
But, It’s Christmas time anyway.
Expectation
/* xmas printf("Merry Christmas!!"); */
cool_down();
/* new year printf("And a Happy new year!!!"); */
Reality (Commented cooldown)
/* xmas <RLO> <LRI>printf("Merry Christmas!!");<PDI> <LRI>*<ZWS>/<PDI>
cool_down();
/* new year <RLO> <LRI>printf("And a Happy new year!!!");<PDI> <LRI>*/
Thanks for listening, Questions?