Skip to content

Commit

Permalink
Remove use of PATH_MAX in path_name()
Browse files Browse the repository at this point in the history
The length of a file path on the checked filesystem has no relation to
the maximum path length of the system fsck is running on. So replace it
with a constant of our own.

As a bonus this will not fail compilation on a system without PATH_MAX.

Signed-off-by: Andreas Bombe <aeb@debian.org>
  • Loading branch information
andreasbombe committed Feb 22, 2016
1 parent b1a38ab commit ed4e47b
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/check.c
Expand Up @@ -28,7 +28,6 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <limits.h>
#include <time.h>

#include "common.h"
Expand All @@ -39,6 +38,10 @@
#include "lfn.h"
#include "check.h"


/* the longest path on the filesystem that can be handled by path_name() */
#define PATH_NAME_MAX 1023

static DOS_FILE *root;

/* get start field of a dir entry */
Expand Down Expand Up @@ -204,12 +207,12 @@ off_t alloc_rootdir_entry(DOS_FS * fs, DIR_ENT * de, const char *pattern)
*/
static char *path_name(DOS_FILE * file)
{
static char path[PATH_MAX * 2];
static char path[PATH_NAME_MAX * 2];

if (!file)
*path = 0; /* Reached the root directory */
else {
if (strlen(path_name(file->parent)) > PATH_MAX)
if (strlen(path_name(file->parent)) > PATH_NAME_MAX)
die("Path name too long.");
if (strcmp(path, "/") != 0)
strcat(path, "/");
Expand Down

0 comments on commit ed4e47b

Please sign in to comment.