<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body><div style="font-family:Arial;">cb67ecd9 (ellie timoney 2016-11-02 10:31:07 +1100 726) s->starts = xmalloc(s->max_start * sizeof(s->starts[0]));<br></div>
<div style="font-family:Arial;"><br></div>
<div style="font-family:Arial;">I see it was already fixed last week.<br></div>
<div style="font-family:Arial;"><br></div>
<div style="font-family:Arial;">Bron.<br></div>
<div><br></div>
<div><br></div>
<div>On Mon, 7 Nov 2016, at 23:23, Egoitz Aurrekoetxea via Cyrus-devel wrote:<br></div>
<blockquote type="cite"><p>God morning!!<br></p><p><br></p><p>Thanks a lot for the confirmation!!<br></p><p><br></p><p>Best regards,<br></p><div style="font-family:Arial;"><br></div>
<div>El 7/11/16 a las 12:43, Bron Gondwana
via Cyrus-devel escribió:<br></div>
<blockquote type="cite" cite="mid:1478519015.1841805.779729681.14EB9927@webmail.messagingengine.com"><div style="font-family:Arial;">You're absolutely right, it should
be changed. If you have a platform where sizeof(int) !=
sizeof(size_t) then you'll have problems with that.<br></div>
<div style="font-family:Arial;"><br></div>
<div style="font-family:Arial;">I'll fix it on the 2.3 branch,
though we probably won't cut a release from it immediately.
It's not supported any more. We released 2.4.0 over 6 years ago
now!<br></div>
<div style="font-family:Arial;"><div style="font-family:Arial;"><br></div>
<div style="font-family:Arial;">Bron.<br></div>
</div>
<div style="font-family:Arial;"><br></div>
<div>On Mon, 7 Nov 2016, at 20:43, Egoitz Aurrekoetxea via
Cyrus-devel wrote:<br></div>
<blockquote type="cite"><div style="font-family:Arial;">Good morning,<br></div>
<div style="font-family:Arial;"><br></div>
<div style="font-family:Arial;"><br></div>
<div style="font-family:Arial;">I have been checking the Cyrus
IMAP 2.3.19 and 2.3.18 code because I have observed some
issues in UID SORT commands in the IMAP protocol. When
performing a command<br></div>
<div style="font-family:Arial;"><br></div>
<div style="font-family:Arial;">like ". UID SORT (SIZE)
US-ASCII ALL TEXT avanzada" in a mailbox where matches were
found caused you to obtain in a debug (or non debug I think)
log the following entry :<br></div>
<div style="font-family:Arial;"><br></div>
<div style="font-family:Arial;">Oct 31 09:17:21 hostname
master[78064]: process 78268 exited, signaled to death by 11<br></div>
<div style="font-family:Arial;"><br></div>
<div style="font-family:Arial;">Lines like this are seen when a
process has been signaled by the kernel with signal 11. Have
been reading this signal is sent to a proccess when it
performs an unauthorized memory<br></div>
<div style="font-family:Arial;"><br></div>
<div style="font-family:Arial;">access attemp (an out of the
own variable, pointer... etc, storage room). After debugging
the code with GDB and doing several checks, have seen the
issue came from the byte2search()<br></div>
<div style="font-family:Arial;"><br></div>
<div style="font-family:Arial;">function when a piece of the
string s->substr was trying to be stored in b. Concretely
the third if in the loop :<br></div>
<div style="font-family:Arial;"><br></div>
<div style="font-family:Arial;"><br></div>
<div style="font-family:Arial;"> for (i = 0, cur = 0; i <
s->max_start; i++) {<br></div>
<div style="font-family:Arial;"> /* no more active offsets
*/<br></div>
<div style="font-family:Arial;"> if (s->starts[i] == -1)<br></div>
<div style="font-family:Arial;"> break;<br></div>
<div style="font-family:Arial;"><br></div>
<div style="font-family:Arial;"> /* if we've passed one
that's not ongoing, copy back */<br></div>
<div style="font-family:Arial;"> if (cur < i) {<br></div>
<div style="font-family:Arial;"> s->starts[cur] =
s->starts[i];<br></div>
<div style="font-family:Arial;"> }<br></div>
<div style="font-family:Arial;"> /* check that the substring
is still maching */<br></div>
<div style="font-family:Arial;"> if (b ==
s->substr[s->offset - s->starts[i]]) {<br></div>
<div style="font-family:Arial;"><br></div>
<div style="font-family:Arial;"><br></div>
<div style="font-family:Arial;">The issue was caused there
because s->starts[i] in this place, was not being able to
be accesed because it was pointing to to data outside
s->starts. After searching where this array was being
initialized<br></div>
<div style="font-family:Arial;"><br></div>
<div style="font-family:Arial;">and it's memory allocated
(which was in search_init function), I tried to allocate 10
bytes more for that pointer. After doing it, there were no
more issues. So I tried allocating just one byte more which it
seemed<br></div>
<div style="font-family:Arial;"><br></div>
<div style="font-family:Arial;">to be enough too (at least for
the patterns I have searched for). At this moment I understood
this pointer (s->starts which was a search_state->substr
pointer inside the search_state structure) was not having<br></div>
<div style="font-family:Arial;"><br></div>
<div style="font-family:Arial;">enough room for all the content
needed to be stored, or at least accesed when calling it. I
checked then the code of Cyrus 2.3.18 and 2.3.19 but didn't
see any kind of differences in the part of the memory<br></div>
<div style="font-family:Arial;"><br></div>
<div style="font-family:Arial;">allocation (in search_init())
or usage (in bytesearch) for s->starts. I deciced to check
Cyrus 2.4 code and I saw it's room was being allocated the
following way :<br></div>
<div style="font-family:Arial;"><br></div>
<div style="font-family:Arial;"><br></div>
<div style="font-family:Arial;"> s->starts =
xmalloc(s->max_start * sizeof(size_t));<br></div>
<div style="font-family:Arial;"><br></div>
<div style="font-family:Arial;"><br></div>
<div style="font-family:Arial;">instead of that in 2.3 was done
:<br></div>
<div style="font-family:Arial;"><br></div>
<div style="font-family:Arial;"><br></div>
<div style="font-family:Arial;"> s->starts =
xmalloc(s->max_start * sizeof(int));<br></div>
<div style="font-family:Arial;"><br></div>
<div style="font-family:Arial;"><br></div>
<div style="font-family:Arial;">So I understood s->starts
should be allocated to the size of a size_t type defined
variable size, instead to the size of an integer variable n
times. After replacing it, has seen definitively all seemed to
be<br></div>
<div style="font-family:Arial;"><br></div>
<div style="font-family:Arial;">working. So wouldn't Cyrus 2.3
sources have this allocation in search_init done with
sizeof(size_t) instead of the sizeof(int)?. I think this is
important because else, when the first character of a<br></div>
<div style="font-family:Arial;"><br></div>
<div style="font-family:Arial;">pattern is repeated more than
one time, the pattern has a would say patlen of 8-9 bytes and
matches exist in the mailbox, that search would end up with a
proccess died due to a signal 11.<br></div>
<div style="font-family:Arial;"><br></div>
<div style="font-family:Arial;"><br></div>
<div style="font-family:Arial;">My env is FreeBSD RELENG_9_0 OS
with a Cyrus 2.3.18_1 port. Am I wrong, shouldn't that
allocation be changed?.<br></div>
<div style="font-family:Arial;"><br></div>
<div style="font-family:Arial;"><br></div>
<div style="font-family:Arial;">Thanks a lot for your time,<br></div>
<div style="font-family:Arial;"><br></div>
<div style="font-family:Arial;">Best regards,<br></div>
<div style="font-family:Arial;"><br></div>
<div style="color:rgb(51, 51, 51);"><div style="font-family:Arial;">-- <br></div>
<div style="font-family:Arial;"><br></div>
<div style="font-family:Arial;"><br></div>
<div style="font-family:Arial;"><br></div>
<div style="color:rgb(51, 51, 51);text-align:left;font-family:Helvetica,Arial,sans-serif;"><div style="margin-top:0px;margin-right:0px;margin-bottom:10px;margin-left:0px;"><img src="cid:part1.33C55506.A671F9BC@sarenet.es" alt="sarenet"><br></div>
<div style="color:rgb(51, 51, 51);font-size:12px;font-weight:bold;font-family:Helvetica,Arial,sans-serif;"><b>Egoitz Aurrekoetxea</b><br></div>
<div style="font-family:Helvetica,Arial,sans-serif;font-weight:normal;font-size:12px;color:rgb(51, 51, 51);">Departamento de sistemas<br></div>
<div style="color:rgb(51, 51, 51);font-size:12px;font-weight:bold;font-family:Helvetica,Arial,sans-serif;"><div style="font-family:Arial;">944 209 470<br></div>
<div style="font-family:Arial;">Parque Tecnológico.
Edificio 103<br></div>
<div style="font-family:Arial;">48170 Zamudio (Bizkaia)<br></div>
</div>
<div style="text-decoration-color:-moz-use-text-color;text-decoration-line:underline;text-decoration-style:solid;line-height:1.2;font-size:12px;color:rgb(0, 122, 196);"><label><a href="mailto:egoitz@sarenet.es">egoitz@sarenet.es</a><br></label></div>
<div style="text-decoration-color:-moz-use-text-color;text-decoration-line:underline;text-decoration-style:solid;line-height:1.2;font-size:12px;color:rgb(0, 122, 196);"><a href="http://www.sarenet.es" style="color:rgb(0, 122, 196);">www.sarenet.es</a><br></div>
<div style="font-family:Arial;"><br></div>
<div style="color:rgb(0, 102, 0);line-height:1.2;font-size:10px;font-weight:normal;font-family:Helvetica,Arial,sans-serif;">Antes de imprimir este correo
electrónico piense si es necesario hacerlo.<br></div>
</div>
</div>
<div><img src="cid:part1.33C55506.A671F9BC@sarenet.es" style="max-width:100%;height:auto;"><br></div>
</blockquote><div style="font-family:Arial;"><br></div>
<div><div>--<br></div>
<div> Bron Gondwana<br></div>
<div> <a href="mailto:brong@fastmail.fm">brong@fastmail.fm</a><br></div>
<div><br></div>
</div>
<div style="font-family:Arial;"><br></div>
</blockquote><div style="font-family:Arial;"><br></div>
<div style="color: rgb(51, 51, 51);"><div style="font-family:Arial;">-- <br></div>
<div style="font-family:Arial;"> <br></div>
<div style="font-family:Arial;"> <br></div>
<div style="font-family:Arial;"> <br></div>
<div style="color: rgb(51, 51, 51); text-align: left; font-family: Helvetica,Arial,sans-serif;"><div style="margin: 0px 0px 10px;"><img alt="sarenet" src="cid:part4.CB3D1068.B6E036F9@sarenet.es"><br></div>
<div style="color: rgb(51, 51, 51); font-size: 12px; font-weight: bold; font-family: Helvetica,Arial,sans-serif;"><b>Egoitz Aurrekoetxea</b><br></div>
<div style="font-family:Helvetica,Arial,sans-serif;font-weight:normal;font-size:12px;color:rgb(51, 51, 51);">Departamento de sistemas<br></div>
<div style="color: rgb(51, 51, 51); font-size: 12px; font-weight: bold; font-family: Helvetica,Arial,sans-serif;"><div style="font-family:Arial;">944 209 470<br></div>
<div style="font-family:Arial;"> Parque Tecnológico. Edificio 103<br></div>
<div style="font-family:Arial;"> 48170 Zamudio (Bizkaia)<br></div>
</div>
<div style="text-decoration: underline; line-height: 1.2; font-size: 12px; color: rgb(0, 122, 196);"><label>egoitz@sarenet.es<br></label></div>
<div style="text-decoration: underline; line-height: 1.2; font-size: 12px; color: rgb(0, 122, 196);"><a style="color: rgb(0, 122, 196);" href="http://www.sarenet.es">www.sarenet.es</a><br></div>
<div style="font-family:Arial;"><br></div>
<div style="color: rgb(0, 102, 0); line-height: 1.2; font-size: 10px; font-weight: normal; font-family: Helvetica,Arial,sans-serif;">Antes de imprimir este correo
electrónico piense si es necesario hacerlo.<br></div>
</div>
</div>
<div><img style="max-width:100%;height:auto;" src="cid:part1.33C55506.A671F9BC@sarenet.es"><br></div>
<div><img style="max-width:100%;height:auto;" src="cid:part4.CB3D1068.B6E036F9@sarenet.es"><br></div>
</blockquote><div style="font-family:Arial;"><br></div>
<div id="sig567075"><div class="signature">--<br></div>
<div class="signature"> Bron Gondwana<br></div>
<div class="signature"> brong@fastmail.fm<br></div>
<div class="signature"><br></div>
</div>
<div style="font-family:Arial;"><br></div>
</body>
</html>