changeset 63:ca419e61f7f2

fix for a bug that recpt1 crashes if dirname(3) returns '.'
author Yoshiki Yazawa <yaz@honeyplanet.jp>
date Sat, 10 Oct 2009 01:11:34 +0900
parents c6a5c844c7fd
children 98a92ce5382e
files recpt1/recpt1.c
diffstat 1 files changed, 3 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/recpt1/recpt1.c	Fri Oct 09 14:02:18 2009 +0900
+++ b/recpt1/recpt1.c	Sat Oct 10 01:11:34 2009 +0900
@@ -786,11 +786,12 @@
     else {
         if(!fileless) {
             int status;
-            char *dir = dirname(strdup(argv[optind + 2]));
+            char *path = strdup(argv[optind + 2]);
+            char *dir = dirname(path);
             status = mkpath(dir, 0777);
             if(status == -1)
                 perror("mkpath");
-            free(dir);
+            free(path);
 
             wfd = open(argv[optind + 2], (O_RDWR | O_CREAT | O_TRUNC), 0666);
             if(wfd < 0) {