Matt McCutchen's Web Site
/
rsync
/
rsync.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Implemented the --what-has-changed functionality.
[rsync/rsync.git]
/
lib
/
compat.c
diff --git
a/lib/compat.c
b/lib/compat.c
index
a783a01
..
97b40ff
100644
(file)
--- a/
lib/compat.c
+++ b/
lib/compat.c
@@
-116,10
+116,12
@@
{
size_t len = strlen(s);
size_t ret = len;
{
size_t len = strlen(s);
size_t ret = len;
- if (bufsize <= 0) return 0;
- if (len >= bufsize) len = bufsize-1;
- memcpy(d, s, len);
- d[len] = 0;
+ if (bufsize > 0) {
+ if (len >= bufsize)
+ len = bufsize-1;
+ memcpy(d, s, len);
+ d[len] = 0;
+ }
return ret;
}
#endif
return ret;
}
#endif
@@
-138,10
+140,9
@@
size_t len2 = strlen(s);
size_t ret = len1 + len2;
size_t len2 = strlen(s);
size_t ret = len1 + len2;
- if (len1+len2 >= bufsize) {
- len2 = bufsize - (len1+1);
- }
- if (len2 > 0) {
+ if (len1 < bufsize - 1) {
+ if (len2 >= bufsize - len1)
+ len2 = bufsize - len1 - 1;
memcpy(d+len1, s, len2);
d[len1+len2] = 0;
}
memcpy(d+len1, s, len2);
d[len1+len2] = 0;
}
@@
-154,7
+155,7
@@
{
unsigned char *p = (unsigned char *)&ip.s_addr;
static char buf[18];
{
unsigned char *p = (unsigned char *)&ip.s_addr;
static char buf[18];
-#if WORDS_BIGENDIAN
+#if
def
WORDS_BIGENDIAN
snprintf(buf, 18, "%d.%d.%d.%d",
(int)p[0], (int)p[1], (int)p[2], (int)p[3]);
#else
snprintf(buf, 18, "%d.%d.%d.%d",
(int)p[0], (int)p[1], (int)p[2], (int)p[3]);
#else
@@
-195,7
+196,7
@@
/* some systems don't take the 2nd argument */
int sys_gettimeofday(struct timeval *tv)
{
/* some systems don't take the 2nd argument */
int sys_gettimeofday(struct timeval *tv)
{
-#if HAVE_GETTIMEOFDAY_TZ
+#if
def
HAVE_GETTIMEOFDAY_TZ
return gettimeofday(tv, NULL);
#else
return gettimeofday(tv);
return gettimeofday(tv, NULL);
#else
return gettimeofday(tv);