<html>
  <head>
    <meta content="text/html; charset=windows-1252"
      http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <p>God morning!!<br>
    </p>
    <p><br>
    </p>
    <p>Thanks a lot for the confirmation!!</p>
    <p><br>
    </p>
    <p>Best regards,<br>
    </p>
    <br>
    <div class="moz-cite-prefix">El 7/11/16 a las 12:43, Bron Gondwana
      via Cyrus-devel escribió:<br>
    </div>
    <blockquote
cite="mid:1478519015.1841805.779729681.14EB9927@webmail.messagingengine.com"
      type="cite">
      <title></title>
      <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;"><br>
        Bron.<br>
      </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: 0px 0px 10px;"><img alt="sarenet"
                src="cid:part1.33C55506.A671F9BC@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><a class="moz-txt-link-abbreviated" href="mailto:egoitz@sarenet.es">egoitz@sarenet.es</a><br>
              </label></div>
            <div style="text-decoration: underline; line-height: 1.2;
              font-size: 12px; color: rgb(0, 122, 196);"><a
                moz-do-not-send="true" 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>
      </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">  <a class="moz-txt-link-abbreviated" href="mailto:brong@fastmail.fm">brong@fastmail.fm</a><br>
        </div>
        <div class="signature"><br>
        </div>
      </div>
      <div style="font-family:Arial;"><br>
      </div>
    </blockquote>
    <br>
    <div class="moz-signature">-- <br>
      <style>
body {
        font-family:Helvetica, Arial, sans-serif;
        font-size:12px;
        color:#333;
}
.moz-signature { color:#333!important; }
.firmasarenet {
        font-family:Helvetica, Arial, sans-serif;
        text-align:left;
        color:#333333;
}
.titulosarenet {
        font-family:Helvetica, Arial, sans-serif;
        font-weight:bold;
        font-size:12px;
        color:#333333;
}
.textosarenet {
        font-family:Helvetica, Arial, sans-serif;
        font-weight:bold;
        font-size:12px;
        color:#333333;
}
.dptosarenet { }
.imgsarenet { margin:0px 0px 10px 0px }
.imgsarenet img { }
.lnksarenet {
        color:#007AC4!important;
        font-size:12px;
        line-height:1.2;
        text-decoration:underline;
}
.firmasarenet a { color:#007ac4!important }
.imprimirsarenet {
        font-family:Helvetica, Arial, sans-serif;
        font-weight:normal;
        font-size:10px;
        line-height:1.2;
        color:#006600
}
</style><br>
      <br>
      <div style="clear:both; text-align:left;" class="firmasarenet">
        <div style="margin:0 0 10px 0" class="imgsarenet"><img
            src="cid:part4.CB3D1068.B6E036F9@sarenet.es" alt="sarenet"></div>
        <div style="font-family:Helvetica, Arial, sans-serif;
          font-weight:bold; font-size:14px; color:#333333"
          class="titulosarenet"><strong>Egoitz Aurrekoetxea</strong></div>
        <div style="font-family:Helvetica, Arial, sans-serif;
          font-weight:normal; font-size:12px; color:#333333"
          class="dptosarenet">Departamento de sistemas</div>
        <div style="font-family:Helvetica, Arial, sans-serif;
          font-weight:normal; font-size:12px; color:#333333"
          class="textosarenet">944 209 470<br>
          Parque Tecnológico. Edificio 103<br>
          48170 Zamudio (Bizkaia)</div>
        <div style="font-family:Helvetica, Arial, sans-serif;
          font-weight:normal; font-size:12px; color:#007AC4;
          line-height:1.2" class="lnksarenet"><a
            href="mailto:egoitz@sarenet.es" id="mailto" style="
            font-size:12px; color:#007AC4; text-decoration:underline;"><label
              id="label_email">egoitz@sarenet.es</label></a></div>
        <div style="font-family:Helvetica, Arial, sans-serif;
          font-weight:normal; font-size:12px; color:#007AC4;
          line-height:1.2" class="lnksarenet"><a
            href="http://www.sarenet.es" style=" font-size:12px;
            color:#007AC4; text-decoration:underline;">www.sarenet.es</a></div>
        <br>
        <div style="font-family:Helvetica, Arial, sans-serif;
          font-weight:normal; font-size:10px; color:#A0C361"
          class="imprimirsarenet">Antes de imprimir este correo
          electrónico piense si es necesario hacerlo.</div>
      </div>
    </div>
  </body>
</html>