mirror of
https://gitea.psi.ch/ELOG/elog.git
synced 2026-09-08 17:13:56 +00:00
Fixed stack overflow of Select -> Edit with many replies
SVN revision: 2292
This commit is contained in:
parent
c5954c47d1
commit
4ec1c2edc3
23
src/elogd.c
23
src/elogd.c
@ -9105,29 +9105,40 @@ void rsicon(char *name, char *comment, char *elcode)
|
|||||||
void compare_attributes(LOGBOOK * lbs, int message_id, char attrib[MAX_N_ATTR][NAME_LENGTH], int *n)
|
void compare_attributes(LOGBOOK * lbs, int message_id, char attrib[MAX_N_ATTR][NAME_LENGTH], int *n)
|
||||||
{
|
{
|
||||||
int status, i, n_reply;
|
int status, i, n_reply;
|
||||||
char reply_to[MAX_REPLY_TO * 10], attr[MAX_N_ATTR][NAME_LENGTH], list[MAX_N_ATTR][NAME_LENGTH];
|
char reply_to[MAX_REPLY_TO * 10], *attr, *list;
|
||||||
|
|
||||||
status = el_retrieve(lbs, message_id, NULL, attr_list, attr, lbs->n_attr,
|
attr = xmalloc(MAX_N_ATTR * NAME_LENGTH);
|
||||||
|
assert(attr);
|
||||||
|
status = el_retrieve(lbs, message_id, NULL, attr_list, (char (*)[NAME_LENGTH]) attr, lbs->n_attr,
|
||||||
NULL, NULL, NULL, reply_to, NULL, NULL, NULL);
|
NULL, NULL, NULL, reply_to, NULL, NULL, NULL);
|
||||||
if (status != EL_SUCCESS)
|
if (status != EL_SUCCESS) {
|
||||||
|
xfree(attr);
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (*n == 0)
|
if (*n == 0)
|
||||||
memcpy(attrib, attr, sizeof(attr));
|
memcpy(attrib, attr, sizeof(attr));
|
||||||
else {
|
else {
|
||||||
for (i = 0; i < lbs->n_attr; i++)
|
for (i = 0; i < lbs->n_attr; i++)
|
||||||
if (!strieq(attrib[i], attr[i]))
|
if (!strieq(attrib[i], attr+i*NAME_LENGTH))
|
||||||
sprintf(attrib[i], "- %s -", loc("keep original values"));
|
sprintf(attrib[i], "- %s -", loc("keep original values"));
|
||||||
}
|
}
|
||||||
(*n)++;
|
(*n)++;
|
||||||
if (isparam("elmode") && strieq(getparam("elmode"), "threaded")) {
|
if (isparam("elmode") && strieq(getparam("elmode"), "threaded")) {
|
||||||
|
|
||||||
|
list = xmalloc(MAX_N_ATTR * NAME_LENGTH);
|
||||||
|
assert(list);
|
||||||
|
|
||||||
// go through all replies in threaded mode
|
// go through all replies in threaded mode
|
||||||
n_reply = strbreak(reply_to, list, MAX_N_ATTR, ",", FALSE);
|
n_reply = strbreak(reply_to, (char (*)[NAME_LENGTH]) list, MAX_N_ATTR, ",", FALSE);
|
||||||
for (i = 0; i < n_reply; i++) {
|
for (i = 0; i < n_reply; i++) {
|
||||||
compare_attributes(lbs, atoi(list[i]), attrib, n);
|
compare_attributes(lbs, atoi(list+i*NAME_LENGTH), attrib, n);
|
||||||
|
|
||||||
|
xfree(list);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
xfree(attr);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*------------------------------------------------------------------*/
|
/*------------------------------------------------------------------*/
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user