Merge pull request #44 from plieven/master
authorRonnie Sahlberg <ronniesahlberg@gmail.com>
Thu, 26 Dec 2013 19:00:04 +0000 (11:00 -0800)
committerRonnie Sahlberg <ronniesahlberg@gmail.com>
Thu, 26 Dec 2013 19:00:04 +0000 (11:00 -0800)
fix 3 flaws detected by valgrind and bump version to intermediate version

configure.ac
examples/nfs-cp.c
lib/libnfs.c

index cca169934899e927c2b9322148813051a50d5b22..98599ee22de218fff905f1bd92dbe3cb5555da38 100644 (file)
@@ -1,5 +1,5 @@
 AC_PREREQ(2.50)
-AC_INIT([libnfs], [1.8.0], [ronniesahlberg@gmail.com])
+AC_INIT([libnfs], [1.8.90], [ronniesahlberg@gmail.com])
 AC_CONFIG_HEADERS([config.h])
 AM_INIT_AUTOMAKE([foreign])
 AC_CANONICAL_HOST
index 4456747059fc9c338b6fd55c2665a37847d1ec28..fe9911de50b6e79c520086ab0413b23db05fd975 100644 (file)
@@ -132,6 +132,7 @@ open_file(const char *url, int flags)
        file_context->fd     = -1;
        file_context->nfs    = NULL;
        file_context->nfsfh  = NULL;
+       file_context->url    = NULL;
        
        if (strncmp(url, "nfs://", 6)) {
                file_context->is_nfs = 0;
index 77645b140f0e17e18c8b372867f63ca478a14584..029c9c94d1f82795a5104e456caec30fdbbc4e3e 100644 (file)
@@ -201,6 +201,7 @@ static struct nfs_url *nfs_parse_url(struct nfs_context *nfs, const char *url, i
                return NULL;
        }
 
+       memset(urls, 0x00, sizeof(struct nfs_url));
        urls->server = strdup(url + 6);
        if (urls->server == NULL) {
                nfs_destroy_url(urls);
@@ -277,11 +278,6 @@ flags:
                }
        }
 
-       if (urls->server && strlen(urls->server) <= 1) {
-               free(urls->server);
-               urls->server = NULL;
-       }
-
        while (flagsp != NULL && *(flagsp+1) != 0) {
                strp = flagsp + 1;
                flagsp = strchr(strp, '&');
@@ -296,6 +292,11 @@ flags:
                }
        }
 
+       if (urls->server && strlen(urls->server) <= 1) {
+               free(urls->server);
+               urls->server = NULL;
+       }
+
        return urls;
 }