Check-in [5aadfc2b05]
Overview
Comment:Ensure inode lookups are within bounds
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | add-inode
Files: files | file ages | folders
SHA3-256: 5aadfc2b051e7a274b9d930eb1a2ba36d3f2a3d58dd7ab3c63558aeb1549d9de
User & Date: rkeene on 2020-04-13 17:58:37
Other Links: branch diff | manifest | tags
Context
2020-04-13
20:25
Merged in trunk Leaf check-in: a178887263 user: rkeene tags: add-inode
17:58
Ensure inode lookups are within bounds check-in: 5aadfc2b05 user: rkeene tags: add-inode
17:11
Added start of ABI change to allow lookups by inode as an optimization check-in: 142a373444 user: rkeene tags: add-inode
Changes

Modified lib/xvfs/xvfs.c.rvt from [d0cf525af8] to [6cafb9a4b1].

91
92
93
94
95
96
97






98
99
100
101
102
103
104
	if (count == NULL) {
		return(NULL);
	}
	
	/*
	 * Use user-supplied inode, or look up the path
	 */






	if (inode == XVFS_INODE_NULL) {
		/*
		 * Get the inode from the lookup function
		 */
		inode = xvfs_<?= $::xvfs::fsName ?>_nameToIndex(path);
		if (inode == XVFS_NAME_LOOKUP_ERROR) {
			*count = XVFS_RV_ERR_ENOENT;







>
>
>
>
>
>







91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
	if (count == NULL) {
		return(NULL);
	}
	
	/*
	 * Use user-supplied inode, or look up the path
	 */
	if (inode != XVFS_INODE_NULL) {
		if (inode >= <?= [llength $::xvfs::outputFiles] ?> || inode < 0) {
			inode = XVFS_INODE_NULL;
			path = NULL;
		}
	}
	if (inode == XVFS_INODE_NULL) {
		/*
		 * Get the inode from the lookup function
		 */
		inode = xvfs_<?= $::xvfs::fsName ?>_nameToIndex(path);
		if (inode == XVFS_NAME_LOOKUP_ERROR) {
			*count = XVFS_RV_ERR_ENOENT;
141
142
143
144
145
146
147






148
149
150
151
152
153
154
		return(NULL);
	}


	/*
	 * Use user-supplied inode, or look up the path
	 */






	if (inode == XVFS_INODE_NULL) {
		/*
		 * Get the inode from the lookup function
		 */
		inode = xvfs_<?= $::xvfs::fsName ?>_nameToIndex(path);
		if (inode == XVFS_NAME_LOOKUP_ERROR) {
			*length = XVFS_RV_ERR_ENOENT;







>
>
>
>
>
>







147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
		return(NULL);
	}


	/*
	 * Use user-supplied inode, or look up the path
	 */
	if (inode != XVFS_INODE_NULL) {
		if (inode >= <?= [llength $::xvfs::outputFiles] ?> || inode < 0) {
			inode = XVFS_INODE_NULL;
			path = NULL;
		}
	}
	if (inode == XVFS_INODE_NULL) {
		/*
		 * Get the inode from the lookup function
		 */
		inode = xvfs_<?= $::xvfs::fsName ?>_nameToIndex(path);
		if (inode == XVFS_NAME_LOOKUP_ERROR) {
			*length = XVFS_RV_ERR_ENOENT;
196
197
198
199
200
201
202






203
204
205
206
207
208
209
	if (!statBuf) {
		return(XVFS_RV_ERR_EINVAL);
	}
	
	/*
	 * Use user-supplied inode, or look up the path
	 */






	if (inode == XVFS_INODE_NULL) {
		/*
		 * Get the inode from the lookup function
		 */
		inode = xvfs_<?= $::xvfs::fsName ?>_nameToIndex(path);
		if (inode == XVFS_NAME_LOOKUP_ERROR) {
			return(XVFS_RV_ERR_ENOENT);







>
>
>
>
>
>







208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
	if (!statBuf) {
		return(XVFS_RV_ERR_EINVAL);
	}
	
	/*
	 * Use user-supplied inode, or look up the path
	 */
	if (inode != XVFS_INODE_NULL) {
		if (inode >= <?= [llength $::xvfs::outputFiles] ?> || inode < 0) {
			inode = XVFS_INODE_NULL;
			path = NULL;
		}
	}
	if (inode == XVFS_INODE_NULL) {
		/*
		 * Get the inode from the lookup function
		 */
		inode = xvfs_<?= $::xvfs::fsName ?>_nameToIndex(path);
		if (inode == XVFS_NAME_LOOKUP_ERROR) {
			return(XVFS_RV_ERR_ENOENT);

Modified xvfs-create-c.c from [56b4842ff2] to [3e031870d5].

313
314
315
316
317
318
319


320
321
322
323
324
325
326
		fprintf(outfp, "static const struct xvfs_file_data xvfs_");
		fprintf(outfp, "%s", options->name);
		fprintf(outfp, "_data[] = {\n");
		parse_xvfs_minirivet_directory(outfp, xvfs_state, options->directory, "");
		fprintf(outfp, "};\n");
	} else if (strcmp(buffer_p, "[zlib adler32 $::xvfs::fsName 0]") == 0) {
		fprintf(outfp, "%lu", adler32(0, (unsigned char *) options->name, strlen(options->name)));


	} else if (strcmp(buffer_p, "$hashTableHeader") == 0) {
		parse_xvfs_minirivet_hashtable_header(outfp, xvfs_state);
	} else if (strcmp(buffer_p, "[dict get $hashTable body]") == 0) {
		parse_xvfs_minirivet_hashtable_body(outfp, xvfs_state);
	} else {
		fprintf(outfp, "@INVALID@%s@INVALID@", buffer_p);
	}







>
>







313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
		fprintf(outfp, "static const struct xvfs_file_data xvfs_");
		fprintf(outfp, "%s", options->name);
		fprintf(outfp, "_data[] = {\n");
		parse_xvfs_minirivet_directory(outfp, xvfs_state, options->directory, "");
		fprintf(outfp, "};\n");
	} else if (strcmp(buffer_p, "[zlib adler32 $::xvfs::fsName 0]") == 0) {
		fprintf(outfp, "%lu", adler32(0, (unsigned char *) options->name, strlen(options->name)));
	} else if (strcmp(buffer_p, "[llength $::xvfs::outputFiles]") == 0) {
		fprintf(outfp, "%lu", xvfs_state->child_count);
	} else if (strcmp(buffer_p, "$hashTableHeader") == 0) {
		parse_xvfs_minirivet_hashtable_header(outfp, xvfs_state);
	} else if (strcmp(buffer_p, "[dict get $hashTable body]") == 0) {
		parse_xvfs_minirivet_hashtable_body(outfp, xvfs_state);
	} else {
		fprintf(outfp, "@INVALID@%s@INVALID@", buffer_p);
	}