@@ -186,28 +186,34 @@ getexportent(int fromkernel)
}
ee.e_hostname = xstrdup(hostname);
- if (parseopts(opt, &ee, NULL) < 0) {
- if(ee.e_hostname)
- {
- xfree(ee.e_hostname);
- ee.e_hostname=NULL;
- }
- if(ee.e_uuid)
- {
- xfree(ee.e_uuid);
- ee.e_uuid=NULL;
- }
+ if (parseopts(opt, &ee, NULL) < 0)
+ goto out;
- return NULL;
- }
/* resolve symlinks */
- if (nfsd_realpath(ee.e_path, rpath) != NULL) {
- rpath[sizeof (rpath) - 1] = '\0';
- strncpy(ee.e_path, rpath, sizeof (ee.e_path) - 1);
- ee.e_path[sizeof (ee.e_path) - 1] = '\0';
- }
+ if (nfsd_realpath(ee.e_path, rpath) == NULL) {
+ xlog(L_ERROR, "nfsd_realpath(): unable to resolve path %s", ee.e_path);
+ goto out;
+ };
- return ⅇ
+ if (strlen(rpath) > sizeof(ee.e_path) - 1){
+ xlog(L_ERROR, "%s: export path %s exceeds limit(%lu)", __func__, rpath, sizeof(ee.e_path) - 1);
+ goto out;
+ };
+
+ strcpy(ee.e_path, rpath);
+ return ⅇ
+
+out:
+ if (ee.e_hostname){
+ free(ee.e_hostname);
+ ee.e_hostname = NULL;
+ };
+ if (ee.e_uuid){
+ free(ee.e_uuid);
+ ee.e_uuid = NULL;
+ };
+
+ return NULL;
}
static const struct secinfo_flag_displaymap {
@@ -432,8 +438,8 @@ mkexportent(char *hname, char *path, char *options)
xlog(L_ERROR, "path name %s too long", path);
return NULL;
}
- strncpy(ee.e_path, path, sizeof (ee.e_path));
- ee.e_path[sizeof (ee.e_path) - 1] = '\0';
+ strcpy(ee.e_path, path);
+
if (parseopts(options, &ee, NULL) < 0)
return NULL;
return ⅇ
Signed-off-by: Christopher Bii <christopherbii@hyub.org> --- support/nfs/exports.c | 48 ++++++++++++++++++++++++------------------- 1 file changed, 27 insertions(+), 21 deletions(-)