~ubuntu-branches/debian/sid/subversion/sid

« back to all changes in this revision

Viewing changes to subversion/libsvn_subr/error.c

  • Committer: Package Import Robot
  • Author(s): James McCoy
  • Date: 2015-08-07 21:32:47 UTC
  • mfrom: (0.2.15) (4.1.7 experimental)
  • Revision ID: package-import@ubuntu.com-20150807213247-ozyewtmgsr6tkewl
Tags: 1.9.0-1
* Upload to unstable
* New upstream release.
  + Security fixes
    - CVE-2015-3184: Mixed anonymous/authenticated path-based authz with
      httpd 2.4
    - CVE-2015-3187: svn_repos_trace_node_locations() reveals paths hidden
      by authz
* Add >= 2.7 requirement for python-all-dev Build-Depends, needed to run
  tests.
* Remove Build-Conflicts against ruby-test-unit.  (Closes: #791844)
* Remove patches/apache_module_dependency in favor of expressing the
  dependencies in authz_svn.load/dav_svn.load.
* Build-Depend on apache2-dev (>= 2.4.16) to ensure ap_some_authn_required()
  is available when building mod_authz_svn and Depend on apache2-bin (>=
  2.4.16) for runtime support.

Show diffs side-by-side

added added

removed removed

Lines of Context:
67
67
#undef svn_error_create
68
68
#undef svn_error_createf
69
69
#undef svn_error_quick_wrap
 
70
#undef svn_error_quick_wrapf
70
71
#undef svn_error_wrap_apr
71
72
 
72
73
/* Note: Although this is a "__" function, it was historically in the
85
86
 
86
87
/* Cleanup function for errors.  svn_error_clear () removes this so
87
88
   errors that are properly handled *don't* hit this code. */
88
 
#if defined(SVN_DEBUG)
89
89
static apr_status_t err_abort(void *data)
90
90
{
91
91
  svn_error_t *err = data;  /* For easy viewing in a debugger */
92
 
  err = err; /* Fake a use for the variable to avoid compiler warnings */
 
92
  SVN_UNUSED(err);
93
93
 
94
94
  if (!getenv("SVN_DBG_NO_ABORT_ON_ERROR_LEAK"))
95
95
    abort();
96
96
  return APR_SUCCESS;
97
97
}
98
 
#endif
99
98
 
100
99
 
101
100
static svn_error_t *
110
109
    pool = child->pool;
111
110
  else
112
111
    {
113
 
      if (apr_pool_create(&pool, NULL))
 
112
      pool = svn_pool_create(NULL);
 
113
      if (!pool)
114
114
        abort();
115
115
    }
116
116
 
201
201
      va_end(ap);
202
202
      if (msg_apr)
203
203
        {
204
 
          err->message = apr_pstrcat(err->pool, msg, ": ", msg_apr, NULL);
 
204
          err->message = apr_pstrcat(err->pool, msg, ": ", msg_apr,
 
205
                                     SVN_VA_NULL);
205
206
        }
206
207
      else
207
208
        {
224
225
                          new_msg);
225
226
}
226
227
 
 
228
svn_error_t *
 
229
svn_error_quick_wrapf(svn_error_t *child,
 
230
                      const char *fmt,
 
231
                      ...)
 
232
{
 
233
  svn_error_t *err;
 
234
  va_list ap;
 
235
 
 
236
  if (child == SVN_NO_ERROR)
 
237
    return SVN_NO_ERROR;
 
238
 
 
239
  err = make_error_internal(child->apr_err, child);
 
240
 
 
241
  va_start(ap, fmt);
 
242
  err->message = apr_pvsprintf(err->pool, fmt, ap);
 
243
  va_end(ap);
 
244
 
 
245
  return err;
 
246
}
 
247
 
227
248
/* Messages in tracing errors all point to this static string. */
228
249
static const char error_tracing_link[] = "traced call";
229
250
 
259
280
  if (err1 && err2)
260
281
    {
261
282
      svn_error_compose(err1,
262
 
                        svn_error_quick_wrap(err2,
263
 
                                             _("Additional errors:")));
 
283
                        svn_error_create(SVN_ERR_COMPOSED_ERROR, err2, NULL));
264
284
      return err1;
265
285
    }
266
286
  return err1 ? err1 : err2;
314
334
{
315
335
  while (err)
316
336
    {
317
 
      if (err->child)
 
337
      /* I don't think we can change the behavior here, but the additional
 
338
         error chain doesn't define the root cause. Perhaps we should rev
 
339
         this function. */
 
340
      if (err->child /*&& err->child->apr_err != SVN_ERR_COMPOSED_ERROR*/)
318
341
        err = err->child;
319
342
      else
320
343
        break;
336
359
}
337
360
 
338
361
svn_error_t *
339
 
svn_error_dup(svn_error_t *err)
 
362
svn_error_dup(const svn_error_t *err)
340
363
{
341
364
  apr_pool_t *pool;
342
365
  svn_error_t *new_err = NULL, *tmp_err = NULL;
343
366
 
344
 
  if (apr_pool_create(&pool, NULL))
 
367
  if (!err)
 
368
    return SVN_NO_ERROR;
 
369
 
 
370
  pool = svn_pool_create(NULL);
 
371
  if (!pool)
345
372
    abort();
346
373
 
347
374
  for (; err; err = err->child)
388
415
}
389
416
 
390
417
svn_boolean_t
391
 
svn_error__is_tracing_link(svn_error_t *err)
 
418
svn_error__is_tracing_link(const svn_error_t *err)
392
419
{
393
420
#ifdef SVN_ERR__TRACING
394
421
  /* ### A strcmp()?  Really?  I think it's the best we can do unless
423
450
      if (! err)
424
451
        return svn_error_create(
425
452
                 SVN_ERR_ASSERTION_ONLY_TRACING_LINKS,
426
 
                 svn_error_compose_create(
427
 
                   svn_error__malfunction(TRUE, __FILE__, __LINE__,
428
 
                                          NULL /* ### say something? */),
429
 
                   err),
 
453
                 svn_error__malfunction(TRUE, __FILE__, __LINE__,
 
454
                                        NULL /* ### say something? */),
430
455
                 NULL);
431
456
 
432
457
      /* Copy the current error except for its child error pointer
535
560
}
536
561
 
537
562
void
538
 
svn_handle_error(svn_error_t *err, FILE *stream, svn_boolean_t fatal)
539
 
{
540
 
  svn_handle_error2(err, stream, fatal, "svn: ");
541
 
}
542
 
 
543
 
void
544
563
svn_handle_error2(svn_error_t *err,
545
564
                  FILE *stream,
546
565
                  svn_boolean_t fatal,
559
578
  apr_array_header_t *empties;
560
579
  svn_error_t *tmp_err;
561
580
 
562
 
  /* ### The rest of this file carefully avoids using svn_pool_*(),
563
 
     preferring apr_pool_*() instead.  I can't remember why -- it may
564
 
     be an artifact of r843793, or it may be for some deeper reason --
565
 
     but I'm playing it safe and using apr_pool_*() here too. */
566
 
  apr_pool_create(&subpool, err->pool);
 
581
  subpool = svn_pool_create(err->pool);
567
582
  empties = apr_array_make(subpool, 0, sizeof(apr_status_t));
568
583
 
569
584
  tmp_err = err;
611
626
    }
612
627
}
613
628
 
614
 
 
615
 
void
616
 
svn_handle_warning(FILE *stream, svn_error_t *err)
617
 
{
618
 
  svn_handle_warning2(stream, err, "svn: ");
619
 
}
620
 
 
621
 
void
622
 
svn_handle_warning2(FILE *stream, svn_error_t *err, const char *prefix)
 
629
void
 
630
svn_handle_warning2(FILE *stream, const svn_error_t *err, const char *prefix)
623
631
{
624
632
  char buf[256];
 
633
#ifdef SVN_DEBUG
 
634
  const char *symbolic_name = svn_error_symbolic_name(err->apr_err);
 
635
#endif
 
636
 
 
637
#ifdef SVN_DEBUG
 
638
  if (symbolic_name)
 
639
    svn_error_clear(
 
640
      svn_cmdline_fprintf(stream, err->pool, "%swarning: apr_err=%s\n",
 
641
                          prefix, symbolic_name));
 
642
#endif
625
643
 
626
644
  svn_error_clear(svn_cmdline_fprintf
627
645
                  (stream, err->pool,
632
650
}
633
651
 
634
652
const char *
635
 
svn_err_best_message(svn_error_t *err, char *buf, apr_size_t bufsize)
 
653
svn_err_best_message(const svn_error_t *err, char *buf, apr_size_t bufsize)
636
654
{
637
655
  /* Skip over any trace records.  */
638
656
  while (svn_error__is_tracing_link(err))
672
690
  return apr_strerror(statcode, buf, bufsize);
673
691
}
674
692
 
 
693
#ifdef SVN_DEBUG
 
694
/* Defines svn__errno and svn__apr_errno */
 
695
#include "errorcode.inc"
 
696
#endif
 
697
 
675
698
const char *
676
699
svn_error_symbolic_name(apr_status_t statcode)
677
700
{
678
701
  const err_defn *defn;
 
702
#ifdef SVN_DEBUG
 
703
  int i;
 
704
#endif /* SVN_DEBUG */
679
705
 
680
706
  for (defn = error_table; defn->errdesc != NULL; ++defn)
681
707
    if (defn->errcode == (svn_errno_t)statcode)
682
708
      return defn->errname;
683
709
 
684
710
  /* "No error" is not in error_table. */
685
 
  if (statcode == SVN_NO_ERROR)
 
711
  if (statcode == APR_SUCCESS)
686
712
    return "SVN_NO_ERROR";
687
713
 
 
714
#ifdef SVN_DEBUG
 
715
  /* Try errno.h symbols. */
 
716
  /* Linear search through a sorted array */
 
717
  for (i = 0; i < sizeof(svn__errno) / sizeof(svn__errno[0]); i++)
 
718
    if (svn__errno[i].errcode == (int)statcode)
 
719
      return svn__errno[i].errname;
 
720
 
 
721
  /* Try APR errors. */
 
722
  /* Linear search through a sorted array */
 
723
  for (i = 0; i < sizeof(svn__apr_errno) / sizeof(svn__apr_errno[0]); i++)
 
724
    if (svn__apr_errno[i].errcode == (int)statcode)
 
725
      return svn__apr_errno[i].errname;
 
726
#endif /* SVN_DEBUG */
 
727
 
 
728
  /* ### TODO: do we need APR_* error macros?  What about APR_TO_OS_ERROR()? */
 
729
 
688
730
  return NULL;
689
731
}
690
732
 
741
783
  return old_malfunction_handler;
742
784
}
743
785
 
 
786
svn_error_malfunction_handler_t
 
787
svn_error_get_malfunction_handler(void)
 
788
{
 
789
  return malfunction_handler;
 
790
}
 
791
 
744
792
/* Note: Although this is a "__" function, it is in the public ABI, so
745
793
 * we can never remove it or change its signature. */
746
794
svn_error_t *