<h4>opensips log error</h4>

<p>localhost opensips: ERROR:db_sqlite:db_sqlite_insert: failed to prepare: (near "1.0": syntax error)<br>
localhost opensips: ERROR:db_sqlite:db_sqlite_insert: insert query failed near "1.0": syntax error</p>

<h4>gdb query</h4>

<p>(gdb) print query_holder<br><br>
$3 = {<br><br>
  s = 0x852740  "insert into presentity (domain,username,event,etag,expires,sender,body,received_time ) values ('sqlite.sipy.org','jarrod','presence','a.1429566087.15836.8.0',1429569706,'','&lt;?xml version='1.0' encodin"..., len = 655}</p>

<h4>synopsis</h4>

<p>the val2str seems to simply use strncpy for appending the the sql buffer which obviously will not escape single quotes.  the preferred method is probably to use bindings to prepared statements (<a href="https://www.sqlite.org/c3ref/bind_blob.html">https://www.sqlite.org/c3ref/bind_blob.html</a>) which would entail replacing the values with ? or so and relooping over the value array using the index as the second argument of something like sqlite3_bind_text.  The libsqlite3 also seems to include sqlite3_snprintf and some other functions but they dont appear to be safe.</p>

<p>going home, just reporting this here, thanks.</p>

<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">&mdash;<br>Reply to this email directly or <a href="https://github.com/OpenSIPS/opensips/issues/473">view it on GitHub</a>.<img alt="" height="1" src="https://github.com/notifications/beacon/AFOcibXI6XrTzGA4znUIV1K97ruWWFWnks5oBXaNgaJpZM4EEsjg.gif" width="1" /></p>
<div itemscope itemtype="http://schema.org/EmailMessage">
  <div itemprop="action" itemscope itemtype="http://schema.org/ViewAction">
    <link itemprop="url" href="https://github.com/OpenSIPS/opensips/issues/473"></link>
    <meta itemprop="name" content="View Issue"></meta>
  </div>
  <meta itemprop="description" content="View this Issue on GitHub"></meta>
</div>