Skip to content

Commit

Permalink
pseudo: Don't allow filenames consisting only of "/"s to be used
Browse files Browse the repository at this point in the history
If the filename only consists of leading slashes (/), then
the pseudo code incorrectly stored an empty filename.

Signed-off-by: Phillip Lougher <phillip@squashfs.org.uk>
  • Loading branch information
plougher committed Jul 2, 2019
1 parent c249ba3 commit 26e4bab
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions squashfs-tools/pseudo.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Create a squashfs filesystem. This is a highly compressed read only
* filesystem.
*
* Copyright (c) 2009, 2010, 2012, 2014, 2017
* Copyright (c) 2009, 2010, 2012, 2014, 2017, 2019
* Phillip Lougher <phillip@squashfs.org.uk>
*
* This program is free software; you can redistribute it and/or
Expand Down Expand Up @@ -52,9 +52,6 @@ static char *get_component(char *target, char **targname)
{
char *start;

while(*target == '/')
target ++;

start = target;
while(*target != '/' && *target != '\0')
target ++;
Expand Down Expand Up @@ -310,7 +307,10 @@ int read_pseudo_def(char *def)
}
*name = '\0';

if(*filename == '\0') {
/* Skip any leading slashes (/) */
for(name = filename; *name == '/'; name ++);

if(*name == '\0') {
ERROR("Not enough or invalid arguments in pseudo file "
"definition \"%s\"\n", orig_def);
goto error;
Expand Down Expand Up @@ -490,7 +490,7 @@ int read_pseudo_def(char *def)
if(type == 's')
dev->symlink = strdup(def);

pseudo = add_pseudo(pseudo, dev, filename, filename);
pseudo = add_pseudo(pseudo, dev, name, name);

free(filename);
return TRUE;
Expand Down

0 comments on commit 26e4bab

Please sign in to comment.