Skip to content

Commit 037e9d5

Browse files
committed
Merge branch 'pb/maint-1.6.2-userdiff-fix' into maint
* pb/maint-1.6.2-userdiff-fix: upload-archive: fix infinite loop on Cygwin avoid exponential regex match for java and objc function names
2 parents a437900 + 1b19fa4 commit 037e9d5

2 files changed

Lines changed: 10 additions & 7 deletions

File tree

builtin-upload-archive.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -80,16 +80,17 @@ static void error_clnt(const char *fmt, ...)
8080
die("sent error to the client: %s", buf);
8181
}
8282

83-
static void process_input(int child_fd, int band)
83+
static ssize_t process_input(int child_fd, int band)
8484
{
8585
char buf[16384];
8686
ssize_t sz = read(child_fd, buf, sizeof(buf));
8787
if (sz < 0) {
8888
if (errno != EAGAIN && errno != EINTR)
8989
error_clnt("read error: %s\n", strerror(errno));
90-
return;
90+
return sz;
9191
}
9292
send_sideband(1, band, buf, sz, LARGE_PACKET_MAX);
93+
return sz;
9394
}
9495

9596
int cmd_upload_archive(int argc, const char **argv, const char *prefix)
@@ -131,6 +132,7 @@ int cmd_upload_archive(int argc, const char **argv, const char *prefix)
131132

132133
while (1) {
133134
struct pollfd pfd[2];
135+
ssize_t processed[2] = { 0, 0 };
134136
int status;
135137

136138
pfd[0].fd = fd1[0];
@@ -147,12 +149,12 @@ int cmd_upload_archive(int argc, const char **argv, const char *prefix)
147149
}
148150
if (pfd[0].revents & POLLIN)
149151
/* Data stream ready */
150-
process_input(pfd[0].fd, 1);
152+
processed[0] = process_input(pfd[0].fd, 1);
151153
if (pfd[1].revents & POLLIN)
152154
/* Status stream ready */
153-
process_input(pfd[1].fd, 2);
155+
processed[1] = process_input(pfd[1].fd, 2);
154156
/* Always finish to read data when available */
155-
if ((pfd[0].revents | pfd[1].revents) & POLLIN)
157+
if (processed[0] || processed[1])
156158
continue;
157159

158160
if (waitpid(writer, &status, 0) < 0)

userdiff.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ PATTERNS("html", "^[ \t]*(<[Hh][1-6][ \t].*>.*)$",
1313
"[^<>= \t]+|[^[:space:]]|[\x80-\xff]+"),
1414
PATTERNS("java",
1515
"!^[ \t]*(catch|do|for|if|instanceof|new|return|switch|throw|while)\n"
16-
"^[ \t]*(([ \t]*[A-Za-z_][A-Za-z_0-9]*){2,}[ \t]*\\([^;]*)$",
16+
"^[ \t]*(([A-Za-z_][A-Za-z_0-9]*[ \t]+)+[A-Za-z_][A-Za-z_0-9]*[ \t]*\\([^;]*)$",
17+
/* -- */
1718
"[a-zA-Z_][a-zA-Z0-9_]*"
1819
"|[-+0-9.e]+[fFlL]?|0[xXbB]?[0-9a-fA-F]+[lL]?"
1920
"|[-+*/<>%&^|=!]="
@@ -25,7 +26,7 @@ PATTERNS("objc",
2526
/* Objective-C methods */
2627
"^[ \t]*([-+][ \t]*\\([ \t]*[A-Za-z_][A-Za-z_0-9* \t]*\\)[ \t]*[A-Za-z_].*)$\n"
2728
/* C functions */
28-
"^[ \t]*(([ \t]*[A-Za-z_][A-Za-z_0-9]*){2,}[ \t]*\\([^;]*)$\n"
29+
"^[ \t]*(([A-Za-z_][A-Za-z_0-9]*[ \t]+)+[A-Za-z_][A-Za-z_0-9]*[ \t]*\\([^;]*)$\n"
2930
/* Objective-C class/protocol definitions */
3031
"^(@(implementation|interface|protocol)[ \t].*)$",
3132
/* -- */

0 commit comments

Comments
 (0)