You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@subversion.apache.org by Karl Fogel <kf...@red-bean.com> on 2007/12/10 20:55:36 UTC

Re: svn commit: r28368 - trunk/subversion/libsvn_repos

"Dongsheng Song" <do...@gmail.com> writes:
> Could you use  "llu" instead of "APR_UINT64_T_FMT", otherwise:
>
> $ ../../tools/po/po-update.sh zh_CN
> Building subversion.pot...
> ../libsvn_repos/reporter.c:168: warning: Although being used in a
> format string position, the msgid is not a valid C format string.
> Reason: The string ends in the middle of a directive.

Hrm.  I hate to not use the mechanism provided by APR for exactly this
purpose.  Is there any way to shut off that warning for a specific
string?

-Karl

> 2007/12/10, kfogel@tigris.org <kf...@tigris.org>:
>> Author: kfogel
>> Date: Sun Dec  9 15:37:55 2007
>> New Revision: 28368
>>
>> Log:
>> * subversion/libsvn_repos/reporter.c
>>   (read_string): Protect against a highly unlikely wraparound in
>>     allocation size, for the children's sake.
>>
>> Found by: Timo Sirainen <ts...@iki.fi>
>> Review by: glasser
>>            danderson
>>
>>
>> Modified:
>>    trunk/subversion/libsvn_repos/reporter.c
>>
>> Modified: trunk/subversion/libsvn_repos/reporter.c
>> URL: http://svn.collab.net/viewvc/svn/trunk/subversion/libsvn_repos/reporter.c?pathrev=28368&r1=28367&r2=28368
>> ==============================================================================
>> --- trunk/subversion/libsvn_repos/reporter.c    (original)
>> +++ trunk/subversion/libsvn_repos/reporter.c    Sun Dec  9 15:37:55 2007
>> @@ -157,6 +157,18 @@
>>    char *buf;
>>
>>    SVN_ERR(read_number(&len, temp, pool));
>> +
>> +  /* Len can never be less than zero.  But could len be so large that
>> +     len + 1 wraps around and we end up passing 0 to apr_palloc(),
>> +     thus getting a pointer to no storage?  Probably not (16 exabyte
>> +     string, anyone?) but let's be future-proof anyway. */
>> +  if (len + 1 < len)
>> +    {
>> +      return svn_error_createf(SVN_ERR_REPOS_BAD_REVISION_REPORT, NULL,
>> +                               _("Invalid length (%" APR_UINT64_T_FMT ") "
>> +                                 "when about to read a string"), len);
>> +    }
>> +
>>    buf = apr_palloc(pool, len + 1);
>>    SVN_ERR(svn_io_file_read_full(temp, buf, len, NULL, pool));
>>    buf[len] = 0;
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: svn-unsubscribe@subversion.tigris.org
>> For additional commands, e-mail: svn-help@subversion.tigris.org
>>
>>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Re: svn commit: r28368 - trunk/subversion/libsvn_repos

Posted by Dongsheng Song <do...@gmail.com>.
Yes, the current pot is bad:

#: ../libsvn_repos/reporter.c:168
msgid "Invalid length (%"
msgstr ""

If apply the following patch, it's good:

#: ../libsvn_repos/reporter.c:168
#, c-format
msgid "Invalid length (%%%s) when about to read a string"
msgstr ""

===================================================================
--- subversion/libsvn_repos/reporter.c  (revision 28499)
+++ subversion/libsvn_repos/reporter.c  (working copy)
@@ -155,6 +155,7 @@
 {
   apr_uint64_t len;
   char *buf;
+  char *fmt;

   SVN_ERR(read_number(&len, temp, pool));

@@ -164,9 +165,10 @@
      string, anyone?) but let's be future-proof anyway. */
   if (len + 1 < len)
     {
+      fmt = apr_psprintf(pool, _("Invalid length (%%%s) when about to read
"
+                        "a string"), APR_UINT64_T_FMT);
       return svn_error_createf(SVN_ERR_REPOS_BAD_REVISION_REPORT, NULL,
-                               _("Invalid length (%" APR_UINT64_T_FMT ") "
-                                 "when about to read a string"), len);
+                               fmt, len);
     }

   buf = apr_palloc(pool, len + 1);


Dongsheng

2007/12/15, Erik Huelsmann <eh...@gmail.com>:
>
> On Dec 10, 2007 9:55 PM, Karl Fogel <kf...@red-bean.com> wrote:
> > "Dongsheng Song" <do...@gmail.com> writes:
> > > Could you use  "llu" instead of "APR_UINT64_T_FMT", otherwise:
> > >
> > > $ ../../tools/po/po-update.sh zh_CN
> > > Building subversion.pot...
> > > ../libsvn_repos/reporter.c:168: warning: Although being used in a
> > > format string position, the msgid is not a valid C format string.
> > > Reason: The string ends in the middle of a directive.
> >
> > Hrm.  I hate to not use the mechanism provided by APR for exactly this
> > purpose.  Is there any way to shut off that warning for a specific
> > string?
>
> No. xgettext doesn't expand defines, so it doesn't know you're
> concatenating strings there.
>
> What we do in other places is: apr_psprintf the number into a string
> and insert the %s format specifier in the error string.
>
> HTH,
>
>
> Erik.

Re: svn commit: r28368 - trunk/subversion/libsvn_repos

Posted by Erik Huelsmann <eh...@gmail.com>.
On Dec 10, 2007 9:55 PM, Karl Fogel <kf...@red-bean.com> wrote:
> "Dongsheng Song" <do...@gmail.com> writes:
> > Could you use  "llu" instead of "APR_UINT64_T_FMT", otherwise:
> >
> > $ ../../tools/po/po-update.sh zh_CN
> > Building subversion.pot...
> > ../libsvn_repos/reporter.c:168: warning: Although being used in a
> > format string position, the msgid is not a valid C format string.
> > Reason: The string ends in the middle of a directive.
>
> Hrm.  I hate to not use the mechanism provided by APR for exactly this
> purpose.  Is there any way to shut off that warning for a specific
> string?

No. xgettext doesn't expand defines, so it doesn't know you're
concatenating strings there.

What we do in other places is: apr_psprintf the number into a string
and insert the %s format specifier in the error string.

HTH,


Erik.
>
>
> > 2007/12/10, kfogel@tigris.org <kf...@tigris.org>:
> >> Author: kfogel
> >> Date: Sun Dec  9 15:37:55 2007
> >> New Revision: 28368
> >>
> >> Log:
> >> * subversion/libsvn_repos/reporter.c
> >>   (read_string): Protect against a highly unlikely wraparound in
> >>     allocation size, for the children's sake.
> >>
> >> Found by: Timo Sirainen <ts...@iki.fi>
> >> Review by: glasser
> >>            danderson
> >>
> >>
> >> Modified:
> >>    trunk/subversion/libsvn_repos/reporter.c
> >>
> >> Modified: trunk/subversion/libsvn_repos/reporter.c
> >> URL: http://svn.collab.net/viewvc/svn/trunk/subversion/libsvn_repos/reporter.c?pathrev=28368&r1=28367&r2=28368
> >> ==============================================================================
> >> --- trunk/subversion/libsvn_repos/reporter.c    (original)
> >> +++ trunk/subversion/libsvn_repos/reporter.c    Sun Dec  9 15:37:55 2007
> >> @@ -157,6 +157,18 @@
> >>    char *buf;
> >>
> >>    SVN_ERR(read_number(&len, temp, pool));
> >> +
> >> +  /* Len can never be less than zero.  But could len be so large that
> >> +     len + 1 wraps around and we end up passing 0 to apr_palloc(),
> >> +     thus getting a pointer to no storage?  Probably not (16 exabyte
> >> +     string, anyone?) but let's be future-proof anyway. */
> >> +  if (len + 1 < len)
> >> +    {
> >> +      return svn_error_createf(SVN_ERR_REPOS_BAD_REVISION_REPORT, NULL,
> >> +                               _("Invalid length (%" APR_UINT64_T_FMT ") "
> >> +                                 "when about to read a string"), len);
> >> +    }
> >> +
> >>    buf = apr_palloc(pool, len + 1);
> >>    SVN_ERR(svn_io_file_read_full(temp, buf, len, NULL, pool));
> >>    buf[len] = 0;
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: svn-unsubscribe@subversion.tigris.org
> >> For additional commands, e-mail: svn-help@subversion.tigris.org
> >>
> >>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
> For additional commands, e-mail: dev-help@subversion.tigris.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org