[GNUPG HEAD] sqlite3 compatibility issue

Andreas Stieger astieger at suse.com
Thu May 18 15:19:05 CEST 2017


Hi,


On 05/18/2017 02:50 PM, Ineiev wrote:
> GnuPG doesn't build with sqlite 3.7.9 because it has
> no sqlite3_errstr ().  I wonder if it could be worked around like
> [...]
>
>
> @@ -218,33 +221,26 @@ gpgsql_stepx (sqlite3 *db,
>   out:
>    xfree (azColName);
>  
> +  if (err != SQLITE_OK && errmsg && !errstr)
> +    errstr = sqlite3_errmsg (db);
> +
>    if (stmtp)
>      rc = sqlite3_reset (stmt);
>    else
>      rc = sqlite3_finalize (stmt);
> -  if (rc == SQLITE_OK && err)
> -    /* Local error.  */
> -    {
> -      rc = err;
> -      if (errmsg)
> -        {
> -          const char *e = sqlite3_errstr (err);
> -          size_t l = strlen (e) + 1;
> -          *errmsg = sqlite3_malloc (l);
> -          if (! *errmsg)
> -            log_fatal ("Out of memory.\n");
> -          memcpy (*errmsg, e, l);
> -        }
> -    }
> -  else if (rc != SQLITE_OK && errmsg)
> -    /* Error reported by sqlite.  */
> +
> +  if (rc != SQLITE_OK)
> +    errstr = sqlite3_errmsg (db);
> +  else
> +    rc = err;
> +
> +  if (rc != SQLITE_OK && errmsg)
>      {
> -      const char * e = sqlite3_errmsg (db);
> -      size_t l = strlen (e) + 1;
> +      size_t l = strlen (errstr) + 1;
>        *errmsg = sqlite3_malloc (l);
>        if (! *errmsg)
>          log_fatal ("Out of memory.\n");
> -      memcpy (*errmsg, e, l);
> +      memcpy (*errmsg, errstr, l);
>      }
>  
>    return rc;

Too complex. Why not use AC_CHECK_FUNCS to check for the availability of
the function, and conditionally define a stub function matching the
signature of sqlite3_errstr()?

Andreas

-- 
Andreas Stieger <astieger at suse.com>
Project Manager Security
SUSE Linux GmbH, GF: Felix Imendörffer, Jane Smithard, Graham Norton,
HRB 21284 (AG Nürnberg)





More information about the Gnupg-devel mailing list