You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@subversion.apache.org by "Jay Freeman (saurik)" <sa...@saurik.com> on 2002/08/03 10:23:20 UTC
[PATCH] svn status -v dies with revisions > 999999
Small misuse of format specifiers leads to some stack corruption. The
specifier for "width" only sets the minimum number of characters to use
during output, not the maximum; for that you need to use "precision" (as is
done for the various strings in this function), but "precision" doesn't work
for settings maximums on integers anyway. I ended up just moving the
limitation until the actual printf() occurs and make the buffer for the
sprintf() large enough to accept the data. Seemed to work for some reason I
don't even want to understand on my Linux box, but it probably just caused a
different form of corruption.
BTW, it would be nice if it would actually output more than the first 6
characters of the revision, but then again, I'm probably the only person who
is going to run into this problem for _quite_ a while :).
Index: ./status.c
===================================================================
--- ./status.c
+++ ./status.c Sat Aug 3 05:16:08 2002
@@ -150,7 +150,7 @@
svn_wc_status_t *status)
{
char str_status[5];
- char str_rev[7];
+ char str_rev[11];
char update_char;
svn_revnum_t local_rev;
char last_committed[6 + 3 + 8 + 3 + 1] = { 0 };
@@ -207,10 +207,10 @@
else if (status->copied)
strcpy (str_rev, " -");
else
- sprintf (str_rev, "%6ld", local_rev);
+ sprintf (str_rev, "%ld", local_rev);
/* One Printf to rule them all, one Printf to bind them..." */
- printf ("%s %c %s %s%s\n",
+ printf ("%s %c %6.6s %s%s\n",
str_status,
update_char,
str_rev,
Sincerely,
Jay Freeman (saurik)
saurik@saurik.com
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Re: [PATCH] svn status -v dies with revisions > 999999
Posted by Philip Martin <ph...@codematters.co.uk>.
Philip Martin <ph...@codematters.co.uk> writes:
> In svn_cl__print_status_list youngest is the largest possible status,
s/possible status/possible revision number/
> so sprintf that into an array and run strlen. Then pass the length to
> print_long_format.
Except youngest can be SVN_INVALID_REVNUM. In which case a loop over
statusarray to determine the largest revision would be needed.
--
Philip Martin
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Re: [PATCH] svn status -v dies with revisions > 999999
Posted by Philip Martin <ph...@codematters.co.uk>.
"Jay Freeman \(saurik\)" <sa...@saurik.com> writes:
> BTW, it would be nice if it would actually output more than the first 6
> characters of the revision, but then again, I'm probably the only person who
> is going to run into this problem for _quite_ a while :).
In svn_cl__print_status_list youngest is the largest possible status,
so sprintf that into an array and run strlen. Then pass the length to
print_long_format.
>
> Index: ./status.c
> ===================================================================
> --- ./status.c
> +++ ./status.c Sat Aug 3 05:16:08 2002
> @@ -150,7 +150,7 @@
> svn_wc_status_t *status)
> {
> char str_status[5];
> - char str_rev[7];
> + char str_rev[11];
Why 11? I guess that's 2^32 in decimal plus one. Magic numbers
should be documented. What about 64 bit platforms?
> char update_char;
> svn_revnum_t local_rev;
> char last_committed[6 + 3 + 8 + 3 + 1] = { 0 };
> @@ -207,10 +207,10 @@
> else if (status->copied)
> strcpy (str_rev, " -");
> else
> - sprintf (str_rev, "%6ld", local_rev);
> + sprintf (str_rev, "%ld", local_rev);
"%ld" should be "%" SVN_REVNUM_T_FMT
>
> /* One Printf to rule them all, one Printf to bind them..." */
> - printf ("%s %c %s %s%s\n",
> + printf ("%s %c %6.6s %s%s\n",
Use the newly passed in length of youngest and either %*.* or
dynamically construct the format string.
> str_status,
> update_char,
> str_rev,
Please supply a log message.
--
Philip Martin
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org