summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjsorg71 <jsorg71>2007-01-15 09:02:21 +0000
committerjsorg71 <jsorg71>2007-01-15 09:02:21 +0000
commite14366665be9c483088709985e405d7fb50d820e (patch)
treee0721df3b0ce20b5062fa0a4bf0ade3f1be4e9d9
parent4b802ae8dd102ee8bab5b3af77438060c4525ef9 (diff)
downloadxrdp-proprietary-e14366665be9c483088709985e405d7fb50d820e.tar.gz
xrdp-proprietary-e14366665be9c483088709985e405d7fb50d820e.zip
fix for file_read_line
-rw-r--r--common/file.c42
1 files changed, 28 insertions, 14 deletions
diff --git a/common/file.c b/common/file.c
index 33f0fd37..6d69d874 100644
--- a/common/file.c
+++ b/common/file.c
@@ -91,18 +91,19 @@ file_read_line(struct stream* s, char* text)
{
int i;
int skip_to_end;
+ int at_end;
char c;
char* hold;
skip_to_end = 0;
- if (!s_check(s))
+ if (!s_check_rem(s, 1))
{
return 1;
}
hold = s->p;
i = 0;
in_uint8(s, c);
- while (c != 10 && c != 13 && s_check(s))
+ while (c != 10 && c != 13)
{
if (c == '#' || c == '!')
{
@@ -113,15 +114,35 @@ file_read_line(struct stream* s, char* text)
text[i] = c;
i++;
}
- in_uint8(s, c);
+ if (s_check_rem(s, 1))
+ {
+ in_uint8(s, c);
+ }
+ else
+ {
+ c = 0;
+ break;
+ }
}
if (c == 10 || c == 13)
{
- while ((c == 10 || c == 13) && s_check(s))
+ at_end = 0;
+ while (c == 10 || c == 13)
{
- in_uint8(s, c);
+ if (s_check_rem(s, 1))
+ {
+ in_uint8(s, c);
+ }
+ else
+ {
+ at_end = 1;
+ break;
+ }
+ }
+ if (!at_end)
+ {
+ s->p--;
}
- s->p--;
}
text[i] = 0;
if (text[0] == '[')
@@ -129,14 +150,7 @@ file_read_line(struct stream* s, char* text)
s->p = hold;
return 1;
}
- if (s_check(s))
- {
- return 0;
- }
- else
- {
- return 1;
- }
+ return 0;
}
/*****************************************************************************/