[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Cvs-cvs] ccvs/src ChangeLog Makefile.in client.c
From: |
Derek Robert Price |
Subject: |
[Cvs-cvs] ccvs/src ChangeLog Makefile.in client.c |
Date: |
Fri, 07 Apr 2006 17:18:28 +0000 |
CVSROOT: /cvsroot/cvs
Module name: ccvs
Branch:
Changes by: Derek Robert Price <address@hidden> 06/04/07 17:18:28
Modified files:
src : ChangeLog Makefile.in client.c
Log message:
Merge changes from 1.11.x.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/cvs/ccvs/src/ChangeLog.diff?tr1=1.3368&tr2=1.3369&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/cvs/ccvs/src/Makefile.in.diff?tr1=1.165&tr2=1.166&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/cvs/ccvs/src/client.c.diff?tr1=1.442&tr2=1.443&r1=text&r2=text
Patches:
Index: ccvs/src/ChangeLog
diff -u ccvs/src/ChangeLog:1.3368 ccvs/src/ChangeLog:1.3369
--- ccvs/src/ChangeLog:1.3368 Fri Apr 7 14:44:53 2006
+++ ccvs/src/ChangeLog Fri Apr 7 17:18:28 2006
@@ -1,5 +1,12 @@
2006-04-07 Derek Price <address@hidden>
+ * client.c (strto_file_size): New function which checks for errors as
+ it parses file size.
+ (read_counted_file, update_entries, handle_mbinary): Use new function.
+ Remove FIXME.
+ (Thanks to a report from Brendan Harrison
+ <address@hidden>.)
+
* client.c (send_a_repository): Add assertion.
(Thanks to an incorrect report from Brendan Harrison
<address@hidden>.)
Index: ccvs/src/Makefile.in
diff -u ccvs/src/Makefile.in:1.165 ccvs/src/Makefile.in:1.166
--- ccvs/src/Makefile.in:1.165 Mon Mar 20 02:21:57 2006
+++ ccvs/src/Makefile.in Fri Apr 7 17:18:28 2006
@@ -114,8 +114,11 @@
$(top_srcdir)/m4/stdint.m4 $(top_srcdir)/m4/stdint_h.m4 \
$(top_srcdir)/m4/strcase.m4 $(top_srcdir)/m4/strdup.m4 \
$(top_srcdir)/m4/strerror.m4 $(top_srcdir)/m4/strftime.m4 \
- $(top_srcdir)/m4/strstr.m4 $(top_srcdir)/m4/strtol.m4 \
- $(top_srcdir)/m4/strtoul.m4 $(top_srcdir)/m4/sunos57-select.m4 \
+ $(top_srcdir)/m4/strstr.m4 $(top_srcdir)/m4/strtoimax.m4 \
+ $(top_srcdir)/m4/strtol.m4 $(top_srcdir)/m4/strtoll.m4 \
+ $(top_srcdir)/m4/strtoul.m4 $(top_srcdir)/m4/strtoull.m4 \
+ $(top_srcdir)/m4/strtoumax.m4 \
+ $(top_srcdir)/m4/sunos57-select.m4 \
$(top_srcdir)/m4/sys_socket_h.m4 $(top_srcdir)/m4/time_r.m4 \
$(top_srcdir)/m4/timespec.m4 $(top_srcdir)/m4/tm_gmtoff.m4 \
$(top_srcdir)/m4/tzset.m4 $(top_srcdir)/m4/uintmax_t.m4 \
Index: ccvs/src/client.c
diff -u ccvs/src/client.c:1.442 ccvs/src/client.c:1.443
--- ccvs/src/client.c:1.442 Fri Apr 7 14:44:54 2006
+++ ccvs/src/client.c Fri Apr 7 17:18:28 2006
@@ -16,6 +16,9 @@
#include "cvs.h"
+/* C99 Headers. */
+#include <stdint.h>
+
/* GNULIB Headers. */
#include "getline.h"
#include "save-cwd.h"
@@ -1083,11 +1086,46 @@
+/* Attempt to read a file size from a string. Accepts base 8 (0N), base 16
+ * (0xN), or base 10. Exits on error.
+ *
+ * RETURNS
+ * The file size, in a size_t.
+ *
+ * FATAL ERRORS
+ * 1. As strtoumax().
+ * 2. If the number read exceeds SIZE_MAX.
+ */
+static size_t
+strto_file_size (const char *s)
+{
+ uintmax_t tmp;
+ char *endptr;
+
+ /* Read it. */
+ errno = 0;
+ tmp = strtoumax (s, &endptr, 0);
+
+ /* Check for errors. */
+ if (errno || endptr == s)
+ error (1, errno, "Server sent invalid file size `%s'", s);
+ if (*endptr != '\0')
+ error (1, 0,
+ "Server sent trailing characters in file size `%s'",
+ endptr);
+ if (tmp > SIZE_MAX)
+ error (1, 0, "Server sent file size exceeding client max.");
+
+ /* Return it. */
+ return (size_t)tmp;
+}
+
+
+
/* Read from the server the count for the length of a file, then read
- the contents of that file and write them to FILENAME. FULLNAME is
- the name of the file for use in error messages. FIXME-someday:
- extend this to deal with compressed files and make update_entries
- use it. On error, gives a fatal error. */
+ * the contents of that file and write them to FILENAME. FULLNAME is
+ * the name of the file for use in error messages.
+ */
static void
read_counted_file (char *filename, char *fullname)
{
@@ -1110,9 +1148,7 @@
if (size_string[0] == 'z')
error (1, 0, "\
protocol error: compressed files not supported for that operation");
- /* FIXME: should be doing more error checking, probably. Like using
- strtoul and making sure we used up the whole line. */
- size = atoi (size_string);
+ size = strto_file_size (size_string);
free (size_string);
/* A more sophisticated implementation would use only a limited amount
@@ -1393,11 +1429,12 @@
{
char *size_string;
char *mode_string;
- int size;
+ size_t size;
char *buf;
char *temp_filename;
int use_gzip;
int patch_failed;
+ char *s;
read_line (&mode_string);
@@ -1405,13 +1442,15 @@
if (size_string[0] == 'z')
{
use_gzip = 1;
- size = atoi (size_string+1);
+ s = size_string + 1;
}
else
{
use_gzip = 0;
- size = atoi (size_string);
+ s = size_string;
}
+
+ size = strto_file_size (s);
free (size_string);
/* Note that checking this separately from writing the file is
@@ -2803,7 +2842,7 @@
/* Get the size. */
read_line (&size_string);
- size = atoi (size_string);
+ size = strto_file_size (size_string);
free (size_string);
/* OK, now get all the data. The algorithm here is that we read
- [Cvs-cvs] ccvs/src ChangeLog Makefile.in client.c,
Derek Robert Price <=