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
Fixed the sending of large files with older rsync versions by
[rsync/rsync.git]
/
popt
/
poptconfig.c
diff --git
a/popt/poptconfig.c
b/popt/poptconfig.c
index
5023566
..
9733d15
100644
(file)
--- a/
popt/poptconfig.c
+++ b/
popt/poptconfig.c
@@
-2,46
+2,48
@@
* \file popt/poptconfig.c
*/
* \file popt/poptconfig.c
*/
-/* (C) 1998-200
0
Red Hat, Inc. -- Licensing details are in the COPYING
+/* (C) 1998-200
2
Red Hat, Inc. -- Licensing details are in the COPYING
file accompanying popt source distributions, available from
ftp://ftp.rpm.org/pub/rpm/dist. */
#include "system.h"
#include "poptint.h"
file accompanying popt source distributions, available from
ftp://ftp.rpm.org/pub/rpm/dist. */
#include "system.h"
#include "poptint.h"
+/*@access poptContext @*/
/*@-compmempass@*/ /* FIX: item->option.longName kept, not dependent. */
/*@-compmempass@*/ /* FIX: item->option.longName kept, not dependent. */
-static void configLine(poptContext con,
unsigned
char * line)
+static void configLine(poptContext con, char * line)
/*@modifies con @*/
{
/*@modifies con @*/
{
- /*@-type@*/
- int nameLength = strlen(con->appName);
- /*@=type@*/
+ size_t nameLength;
const char * entryType;
const char * opt;
poptItem item = (poptItem) alloca(sizeof(*item));
int i, j;
const char * entryType;
const char * opt;
poptItem item = (poptItem) alloca(sizeof(*item));
int i, j;
+
+ if (con->appName == NULL)
+ return;
+ nameLength = strlen(con->appName);
+/*@-boundswrite@*/
memset(item, 0, sizeof(*item));
memset(item, 0, sizeof(*item));
- /*@-type@*/
if (strncmp(line, con->appName, nameLength)) return;
if (strncmp(line, con->appName, nameLength)) return;
- /*@=type@*/
line += nameLength;
line += nameLength;
- if (*line == '\0' || !is
space(*
line)) return;
+ if (*line == '\0' || !is
Space(
line)) return;
- while (*line != '\0' && is
space(*
line)) line++;
+ while (*line != '\0' && is
Space(
line)) line++;
entryType = line;
entryType = line;
- while (*line == '\0' || !is
space(*
line)) line++;
+ while (*line == '\0' || !is
Space(
line)) line++;
*line++ = '\0';
*line++ = '\0';
- while (*line != '\0' && is
space(*
line)) line++;
+ while (*line != '\0' && is
Space(
line)) line++;
if (*line == '\0') return;
opt = line;
if (*line == '\0') return;
opt = line;
- while (*line == '\0' || !is
space(*
line)) line++;
+ while (*line == '\0' || !is
Space(
line)) line++;
*line++ = '\0';
*line++ = '\0';
- while (*line != '\0' && is
space(*
line)) line++;
+ while (*line != '\0' && is
Space(
line)) line++;
if (*line == '\0') return;
/*@-temptrans@*/ /* FIX: line alias is saved */
if (*line == '\0') return;
/*@-temptrans@*/ /* FIX: line alias is saved */
@@
-80,6
+82,7
@@
static void configLine(poptContext con, unsigned char * line)
item->argc = j;
}
/*@=modobserver@*/
item->argc = j;
}
/*@=modobserver@*/
+/*@=boundswrite@*/
/*@-nullstate@*/ /* FIX: item->argv[] may be NULL */
if (!strcmp(entryType, "alias"))
/*@-nullstate@*/ /* FIX: item->argv[] may be NULL */
if (!strcmp(entryType, "alias"))
@@
-92,9
+95,9
@@
static void configLine(poptContext con, unsigned char * line)
int poptReadConfigFile(poptContext con, const char * fn)
{
int poptReadConfigFile(poptContext con, const char * fn)
{
- const
unsigned
char * file, * chptr, * end;
-
unsigned
char * buf;
-/*@dependent@*/
unsigned
char * dst;
+ const char * file, * chptr, * end;
+ char * buf;
+/*@dependent@*/ char * dst;
int fd, rc;
off_t fileLength;
int fd, rc;
off_t fileLength;
@@
-106,9
+109,7
@@
int poptReadConfigFile(poptContext con, const char * fn)
if (fileLength == -1 || lseek(fd, 0, 0) == -1) {
rc = errno;
(void) close(fd);
if (fileLength == -1 || lseek(fd, 0, 0) == -1) {
rc = errno;
(void) close(fd);
- /*@-mods@*/
errno = rc;
errno = rc;
- /*@=mods@*/
return POPT_ERROR_ERRNO;
}
return POPT_ERROR_ERRNO;
}
@@
-116,14
+117,13
@@
int poptReadConfigFile(poptContext con, const char * fn)
if (read(fd, (char *)file, fileLength) != fileLength) {
rc = errno;
(void) close(fd);
if (read(fd, (char *)file, fileLength) != fileLength) {
rc = errno;
(void) close(fd);
- /*@-mods@*/
errno = rc;
errno = rc;
- /*@=mods@*/
return POPT_ERROR_ERRNO;
}
if (close(fd) == -1)
return POPT_ERROR_ERRNO;
return POPT_ERROR_ERRNO;
}
if (close(fd) == -1)
return POPT_ERROR_ERRNO;
+/*@-boundswrite@*/
dst = buf = alloca(fileLength + 1);
chptr = file;
dst = buf = alloca(fileLength + 1);
chptr = file;
@@
-134,7
+134,7
@@
int poptReadConfigFile(poptContext con, const char * fn)
case '\n':
*dst = '\0';
dst = buf;
case '\n':
*dst = '\0';
dst = buf;
- while (*dst && is
space(*
dst)) dst++;
+ while (*dst && is
Space(
dst)) dst++;
if (*dst && *dst != '#')
configLine(con, dst);
chptr++;
if (*dst && *dst != '#')
configLine(con, dst);
chptr++;
@@
-155,6
+155,7
@@
int poptReadConfigFile(poptContext con, const char * fn)
}
}
/*@=infloops@*/
}
}
/*@=infloops@*/
+/*@=boundswrite@*/
return 0;
}
return 0;
}
@@
-164,18
+165,16
@@
int poptReadDefaultConfig(poptContext con, /*@unused@*/ UNUSED(int useEnv))
char * fn, * home;
int rc;
char * fn, * home;
int rc;
- /*@-type@*/
- if (!con->appName) return 0;
- /*@=type@*/
+ if (con->appName == NULL) return 0;
rc = poptReadConfigFile(con, "/etc/popt");
if (rc) return rc;
rc = poptReadConfigFile(con, "/etc/popt");
if (rc) return rc;
- if (getuid() != geteuid()) return 0;
if ((home = getenv("HOME"))) {
if ((home = getenv("HOME"))) {
- fn = alloca(strlen(home) + 20);
- strcpy(fn, home);
- strcat(fn, "/.popt");
+ size_t bufsize = strlen(home) + 20;
+ fn = alloca(bufsize);
+ if (fn == NULL) return 0;
+ snprintf(fn, bufsize, "%s/.popt", home);
rc = poptReadConfigFile(con, fn);
if (rc) return rc;
}
rc = poptReadConfigFile(con, fn);
if (rc) return rc;
}