Skip to content

Commit 17bd4fc

Browse files
committed
Avoid infinite loops when expanding variables
1 parent 218dbeb commit 17bd4fc

File tree

4 files changed

+15
-5
lines changed

4 files changed

+15
-5
lines changed

Blink/Info.plist

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,10 @@
6363
<true/>
6464
<key>LSSupportsOpeningDocumentsInPlace</key>
6565
<true/>
66+
<key>NSBluetoothPeripheralUsageDescription</key>
67+
<string>keyboard</string>
68+
<key>NSSiriUsageDescription</key>
69+
<string>storing commands</string>
6670
<key>NSUserActivityTypes</key>
6771
<array>
6872
<string>com.blink.cmdline</string>
@@ -76,16 +80,18 @@
7680
<true/>
7781
<key>UILaunchStoryboardName</key>
7882
<string>LaunchScreen</string>
83+
<key>UIMainStoryboardFile</key>
84+
<string>Main</string>
7985
<key>UIRequiredDeviceCapabilities</key>
8086
<array>
8187
<string>armv7</string>
8288
</array>
8389
<key>UISupportedInterfaceOrientations</key>
8490
<array>
91+
<string>UIInterfaceOrientationLandscapeRight</string>
92+
<string>UIInterfaceOrientationLandscapeLeft</string>
8593
<string>UIInterfaceOrientationPortraitUpsideDown</string>
8694
<string>UIInterfaceOrientationPortrait</string>
87-
<string>UIInterfaceOrientationLandscapeLeft</string>
88-
<string>UIInterfaceOrientationLandscapeRight</string>
8995
</array>
9096
<key>UISupportsDocumentBrowser</key>
9197
<true/>

Blink/SmartKeys/SmartKeysController.m

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ - (void)viewDidLoad
153153
[self.allKeys addObjectsFromArray:AlternateKeys];
154154
[self.allKeys addObjectsFromArray:CursorKeys];
155155
[self.allKeys addObject:[[SmartKey alloc] initWithName:KbdEscKey symbol:UIKeyInputEscape]];
156+
[super viewDidLoad];
156157
}
157158

158159
- (void)invalidateTimer

Blink/TermController.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,5 +61,6 @@
6161
- (void)terminate;
6262
- (void)sigwinch;
6363
- (BOOL)executeCommand:(NSMutableArray*)listArgv;
64+
- (void)createPTY;
6465

6566
@end

Sessions/MCPSession.m

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,8 @@ - (char **) makeargs:(NSMutableArray*) listArgv argc:(int*) argc
133133
// Operations on individual arguments
134134
NSString *argument = [listArgv objectAtIndex:i];
135135
// 1b) expand environment variables, + "~" (not wildcards ? and *)
136-
while ([argument containsString:@"$"]) {
136+
bool stopParsing = false;
137+
while (([argument containsString:@"$"]) && !stopParsing) {
137138
// It has environment variables inside. Work on them one by one.
138139
// position of first "$" sign:
139140
NSRange r1 = [argument rangeOfString:@"$"];
@@ -152,7 +153,7 @@ - (char **) makeargs:(NSMutableArray*) listArgv argc:(int*) argc
152153
NSString* replacement_string = [NSString stringWithCString:variable encoding:NSASCIIStringEncoding];
153154
variable_string = [[NSString stringWithCString:"$" encoding:NSASCIIStringEncoding] stringByAppendingString:variable_string];
154155
argument = [argument stringByReplacingOccurrencesOfString:variable_string withString:replacement_string];
155-
}
156+
} else stopParsing = true;
156157
}
157158
// Bash spec: only convert "~" if: at the beginning of argument, after a ":" or the first "="
158159
// ("=" scenario for export, but we use setenv, so no "=").
@@ -325,6 +326,7 @@ - (bool)executeCommand:(int)argc argv:(char **)argv {
325326
free(cmd);
326327
stdout = saved_out;
327328
stderr = saved_err;
329+
stdin = _stream.in;
328330
}
329331
}
330332
return false;
@@ -341,7 +343,7 @@ - (BOOL)executeCommand:(NSMutableArray*) listArgv {
341343
}
342344

343345
// This is a superset of all commands available. We check at runtime whether they are actually available (using ios_executable)
344-
char* commandList[] = {"ls", "touch", "rm", "cp", "ln", "link", "mv", "mkdir", "chown", "chgrp", "chflags", "chmod", "du", "df", "chksum", "sum", "stat", "readlink", "compress", "uncompress", "gzip", "gunzip", "tar", "printenv", "pwd", "uname", "date", "env", "id", "groups", "whoami", "uptime", "w", "cat", "wc", "grep", "egrep", "fgrep", "curl", "python", "lua", "luac", "amstex", "cslatex", "csplain", "eplain", "etex", "jadetex", "latex", "mex", "mllatex", "mltex", "pdflatex", "pdftex", "pdfcslatex", "pdfcstex", "pdfcsplain", "pdfetex", "pdfjadetex", "pdfmex", "pdfxmltex", "texsis", "utf8mex", "xmltex", "lualatex", "luatex", "texlua", "texluac", "dviluatex", "dvilualatex", "bibtex", "setenv", "unsetenv", "cd",
346+
char* commandList[] = {"ls", "touch", "rm", "cp", "ln", "link", "mv", "mkdir", "chown", "chgrp", "chflags", "chmod", "du", "df", "chksum", "sum", "stat", "readlink", "compress", "uncompress", "gzip", "gunzip", "tar", "printenv", "pwd", "uname", "date", "env", "id", "groups", "whoami", "uptime", "w", "cat", "wc", "grep", "egrep", "fgrep", "curl", "python", "lua", "luac", "amstex", "cslatex", "csplain", "eplain", "etex", "jadetex", "latex", "mex", "mllatex", "mltex", "pdflatex", "pdftex", "pdfcslatex", "pdfcstex", "pdfcsplain", "pdfetex", "pdfjadetex", "pdfmex", "pdfxmltex", "texsis", "utf8mex", "xmltex", "lualatex", "luatex", "texlua", "texluac", "dviluatex", "dvilualatex", "bibtex", "setenv", "unsetenv", "cd",
345347
NULL}; // must end with NULL pointer
346348

347349
// Commands defined outside of ios_executable:

0 commit comments

Comments
 (0)