mirror of
https://git.proxmox.com/git/mirror_lxc
synced 2025-07-16 20:34:40 +00:00
lxc-user-nic: dont risk passing EOF
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com> Acked-by: Stéphane Graber <stgraber@ubuntu.com>
This commit is contained in:
parent
8cd80b50ef
commit
8f7b58d68f
@ -179,16 +179,16 @@ static int get_alloted(char *me, char *intype, char *link)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *get_eol(char *s)
|
static char *get_eol(char *s, char *e)
|
||||||
{
|
{
|
||||||
while (*s && *s != '\n')
|
while (s<e && *s && *s != '\n')
|
||||||
s++;
|
s++;
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *get_eow(char *s)
|
static char *get_eow(char *s, char *e)
|
||||||
{
|
{
|
||||||
while (*s && !isblank(*s) && *s != '\n')
|
while (s<e && *s && !isblank(*s) && *s != '\n')
|
||||||
s++;
|
s++;
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
@ -197,22 +197,22 @@ static char *find_line(char *p, char *e, char *u, char *t, char *l)
|
|||||||
{
|
{
|
||||||
char *p1, *p2, *ret;
|
char *p1, *p2, *ret;
|
||||||
|
|
||||||
while (p < e && (p1 = get_eol(p)) < e) {
|
while (p<e && (p1 = get_eol(p, e)) < e) {
|
||||||
ret = p;
|
ret = p;
|
||||||
if (*p == '#')
|
if (*p == '#')
|
||||||
goto next;
|
goto next;
|
||||||
while (isblank(*p)) p++;
|
while (p<e && isblank(*p)) p++;
|
||||||
p2 = get_eow(p);
|
p2 = get_eow(p, e);
|
||||||
if (!p2 || p2-p != strlen(u) || strncmp(p, u, strlen(u)) != 0)
|
if (!p2 || p2-p != strlen(u) || strncmp(p, u, strlen(u)) != 0)
|
||||||
goto next;
|
goto next;
|
||||||
p = p2+1;
|
p = p2+1;
|
||||||
while (isblank(*p)) p++;
|
while (p<e && isblank(*p)) p++;
|
||||||
p2 = get_eow(p);
|
p2 = get_eow(p, e);
|
||||||
if (!p2 || p2-p != strlen(t) || strncmp(p, t, strlen(t)) != 0)
|
if (!p2 || p2-p != strlen(t) || strncmp(p, t, strlen(t)) != 0)
|
||||||
goto next;
|
goto next;
|
||||||
p = p2+1;
|
p = p2+1;
|
||||||
while (isblank(*p)) p++;
|
while (p<e && isblank(*p)) p++;
|
||||||
p2 = get_eow(p);
|
p2 = get_eow(p, e);
|
||||||
if (!p2 || p2-p != strlen(l) || strncmp(p, l, strlen(l)) != 0)
|
if (!p2 || p2-p != strlen(l) || strncmp(p, l, strlen(l)) != 0)
|
||||||
goto next;
|
goto next;
|
||||||
return ret;
|
return ret;
|
||||||
@ -659,7 +659,7 @@ static bool cull_entries(int fd, char *me, char *t, char *br)
|
|||||||
}
|
}
|
||||||
entry_lines = newe;
|
entry_lines = newe;
|
||||||
entry_lines[n].start = p;
|
entry_lines[n].start = p;
|
||||||
entry_lines[n].len = get_eol(p) - entry_lines[n].start;
|
entry_lines[n].len = get_eol(p, e) - entry_lines[n].start;
|
||||||
entry_lines[n].keep = true;
|
entry_lines[n].keep = true;
|
||||||
n++;
|
n++;
|
||||||
if (!get_nic_from_line(p, &nic))
|
if (!get_nic_from_line(p, &nic))
|
||||||
@ -692,7 +692,7 @@ static int count_entries(char *buf, off_t len, char *me, char *t, char *br)
|
|||||||
int count = 0;
|
int count = 0;
|
||||||
while ((buf = find_line(buf, e, me, t, br)) != NULL) {
|
while ((buf = find_line(buf, e, me, t, br)) != NULL) {
|
||||||
count++;
|
count++;
|
||||||
buf = get_eol(buf)+1;
|
buf = get_eol(buf, e)+1;
|
||||||
if (buf >= e)
|
if (buf >= e)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user