[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

[PATCH] svn status -v dies with revisions > 999999

From: Jay Freeman \(saurik\) <saurik_at_saurik.com>
Date: 2002-08-03 12:23:20 CEST

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, " -");
- 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",

Jay Freeman (saurik)

To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Sat Aug 3 12:25:53 2002

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.