aboutsummaryrefslogtreecommitdiff
path: root/src/main.c
diff options
context:
space:
mode:
authorDan Fandrich <dan@coneharvesters.com>2008-09-10 20:05:45 +0000
committerDan Fandrich <dan@coneharvesters.com>2008-09-10 20:05:45 +0000
commit6cea51585fc82f3abc540abfc2068517fb804128 (patch)
tree9e589b31029ab992a0672b406b917f4e9549cc32 /src/main.c
parentfce9c3a9f16d4e789fadacfe276fe468f75d9d8a (diff)
Checked in some code improvements and minor fixes that I discovered in the
FreeBSD ports system.
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/main.c b/src/main.c
index e29d78212..0ea9d504d 100644
--- a/src/main.c
+++ b/src/main.c
@@ -4403,7 +4403,7 @@ operate(struct Configurable *config, int argc, argv_item_t argv[])
*/
infd= open(uploadfile, O_RDONLY | O_BINARY);
- if ((infd == -1) || stat(uploadfile, &fileinfo)) {
+ if ((infd == -1) || fstat(infd, &fileinfo)) {
helpf(config->errors, "Can't open '%s'!\n", uploadfile);
if(infd != -1)
close(infd);
@@ -5374,11 +5374,16 @@ rename_if_dos_device_name (char *file_name)
char fname[PATH_MAX];
strncpy(fname, file_name, PATH_MAX-1);
- fname[PATH_MAX-2] = 0; /* Leave room for an extra _ */
+ fname[PATH_MAX-1] = 0;
base = basename (fname);
if (((stat(base, &st_buf)) == 0) && (S_ISCHR(st_buf.st_mode))) {
size_t blen = strlen (base);
+ if (strlen(fname) >= PATH_MAX-1) {
+ /* Make room for the '_' */
+ blen--;
+ base[blen] = 0;
+ }
/* Prepend a '_'. */
memmove (base + 1, base, blen + 1);
base[0] = '_';