Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

‘if’ clause does not guard... [-Werror=misleading-indentation] #48

Open
xlibun opened this issue Feb 2, 2022 · 18 comments
Open

‘if’ clause does not guard... [-Werror=misleading-indentation] #48

xlibun opened this issue Feb 2, 2022 · 18 comments

Comments

@xlibun
Copy link

xlibun commented Feb 2, 2022

Error:

Hunk #1 succeeded at 32 with fuzz 1.
cc -g -O2  -I. -I./LZMA/lzma465/C -I./LZMA/lzmalt -I./LZMA/lzmadaptive/C/7zip/Compress/LZMA_Lib -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_GNU_SOURCE -DCOMP_DEFAULT=\"gzip\" -Wall -Werror  -DGZIP_SUPPORT -DLZMA_SUPPORT -DXZ_SUPPORT -DLZO_SUPPORT -DXATTR_SUPPORT -DXATTR_DEFAULT   -c -o unsquashfs.o unsquashfs.c
unsquashfs.c: In function ‘read_super’:
unsquashfs.c:1835:5: error: this ‘if’ clause does not guard... [-Werror=misleading-indentation]
 1835 |     if(swap)
      |     ^~
unsquashfs.c:1841:9: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the ‘if’
 1841 |         read_fs_bytes(fd, SQUASHFS_START, sizeof(struct squashfs_super_block),
      |         ^~~~~~~~~~~~~
cc1: all warnings being treated as errors
make: *** [<builtin>: unsquashfs.o] Error 1

code from 1835 to 1845:

if(swap)
        ERROR("Reading a different endian SQUASHFS filesystem on %s\n", source);

	/*
	 * Try to read a Squashfs 4 superblock
	 */
	read_fs_bytes(fd, SQUASHFS_START, sizeof(struct squashfs_super_block),
		&sBlk_4);
	// CJH: swap detection already done generically above
    //swap = sBlk_4.s_magic != SQUASHFS_MAGIC;
	SQUASHFS_INSWAP_SUPER_BLOCK(&sBlk_4);
@h4b4n3r0
Copy link

h4b4n3r0 commented Feb 5, 2022

I have the identical issue on Kali Linux.

@minhng99
Copy link

there are mix of space and tab indentation in that part of the code, just change it all to 4 spaces

@ghost
Copy link

ghost commented Feb 11, 2022

same issue

@Fenr1r-g
Copy link

"there are mix of space and tab indentation in that part of the code, just change it all to 4 spaces"

This is not true, and does nothing to actually fix the problem. The 'if' clause referenced on line 1835 is missing the { and } that includes the ERROR statement that comes afterward. Just adding them, however, doesn't fix the problem, as "unsquashfs.c" looks like it was indented by a psychopath, with random breaks in weird places that don't belong all over the place.

example on where the next error occurs if you fix the if statement (unsquashfs.c:1128:49: error: implicit declaration of function 'makedev' [-Werror=implicit-function-declaration]):

			if(mknod(pathname, chrdev ? S_IFCHR : S_IFBLK,
					makedev((i->data >> 8) & 0xff,
					i->data & 0xff)) == -1) {
				ERROR("create_inode: failed to create "
					"%s device %s, because %s\n",
					chrdev ? "character" : "block",
					pathname, strerror(errno));
				break;
			}

Here's what that SHOULD look like (apologies for the wordwrap):

			if(mknod(pathname, chrdev ? S_IFCHR : S_IFBLK, makedev((i->data >> 8) & 0xff, i->data & 0xff)) == -1) 
			{
				ERROR("create_inode: failed to create %s device %s, because %s\n", chrdev ? "character" : "block", pathname, strerror(errno));
				break;
			}

Now, I don't deal with a lot of C code with what I do, mostly python, so someone tell me if I'm completely off base here. But onesy-twosy fixes aren't going to work here.

I also tried importing the lastest ver of squashfs (4.4) - no dice.

@Fenr1r-g
Copy link

The latest pull request fixes these issues: #47

@diablo0822
Copy link

diablo0822 commented Mar 2, 2022

The latest pull request fixes these issues: #47

this patch can solve this issue, but the build.sh scripts wrote a wrong path which cause the patch not work.

$ diff bd.sh build.sh
35c35
< patch -p0 < patches/patch0.txt
---
> patch -p0 < ../patches/patch0.txt

@AxisRay
Copy link

AxisRay commented Mar 13, 2022

patching file squashfs-tools/unsquashfs.c
Hunk #1 succeeded at 32 with fuzz 1.
cc -g -O2  -I. -I./LZMA/lzma465/C -I./LZMA/lzmalt -I./LZMA/lzmadaptive/C/7zip/Compress/LZMA_Lib -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_GNU_SOURCE -DCOMP_DEFAULT=\"gzip\" -Wall -Werror  -DGZIP_SUPPORT -DLZMA_SUPPORT -DXZ_SUPPORT -DLZO_SUPPORT -DXATTR_SUPPORT -DXATTR_DEFAULT   -c -o unsquashfs.o unsquashfs.c
unsquashfs.c: In function ‘read_super’:
unsquashfs.c:1835:5: error: this ‘if’ clause does not guard... [-Werror=misleading-indentation]
 1835 |     if(swap)
      |     ^~
unsquashfs.c:1841:9: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the ‘if’
 1841 |         read_fs_bytes(fd, SQUASHFS_START, sizeof(struct squashfs_super_block),
      |         ^~~~~~~~~~~~~
cc1: all warnings being treated as errors
make: *** [<builtin>: unsquashfs.o] Error 1

@slsanna
Copy link

slsanna commented Jun 19, 2022

build

So, how to fix? I am dealing with this error since days, tried all solutions on internet and none of them worked.
image

@minhng99
Copy link

build

So, how to fix? I am dealing with this error since days, tried all solutions on internet and none of them worked. image

it's caused by inconsistent indentation (tab/space mixed), find it around that line caused error and make it consistent

@prospero-x
Copy link

prospero-x commented Aug 15, 2022

compiling from commit 82da12 of master from this forked repo solved the issue with me on Kali Release version 2022.3.

@torabi12
Copy link

torabi12 commented Sep 6, 2022

I have the same error on Ubuntu 22.04.1
kép

Can you give me any hint what to do?

@J0hnzon
Copy link

J0hnzon commented Sep 26, 2022

image

@frankviana
Copy link

Solve:

git clone --quiet --depth 1 --branch "master" https://github.com/devttys0/sasquatch

cd sasquatch

wget https://github.com/devttys0/sasquatch/pull/47.patch && patch -p1 < 47.patch && sudo ./build.sh

@iAmG-r00t
Copy link

Despite fixing this error, there is an issue when extracting lzma compressed data from a firmware binary. Where most of the files are empty.

@jacopotediosi
Copy link

Solve:

git clone --quiet --depth 1 --branch "master" https://github.com/devttys0/sasquatch
cd sasquatch
wget https://github.com/devttys0/sasquatch/pull/47.patch && patch -p1 < 47.patch && sudo ./build.sh

Doing this, as noted also by @iAmG-r00t, causes some files to be lost while extracting some squashfs images (e.g., see ReFirmLabs/binwalk#618), don't know why.

On Ubuntu 22.04.1LTS I suggest to compile using #51 instead:

cd /tmp
git clone --quiet --depth 1 --branch "master" https://github.com/devttys0/sasquatch
cd sasquatch
wget https://github.com/devttys0/sasquatch/pull/51.patch && patch -p1 <51.patch
sudo ./build.sh

@B1ank-H
Copy link

B1ank-H commented Jul 16, 2023

compiling from commit 82da12 of master from this forked repo solved the issue with me on Kali Release version 2022.3.

Excellent! Only your method can solve this issue correctly.

@peterpt
Copy link

peterpt commented Nov 22, 2023

I have tried all solutions here and i still have issues compiling unsquashfs , the original git here even after the patch been revised still gives compiling issues and breaks , all others i get a lot of warnings but compile , however i believe this is not a perfect compilation and somethings may break or not work when using this tool , i used pastebin to post all the compilation , and i came here because i was trying to compile binwalk from source and i got stuck in this tool , so i decided to compile this tool manually . https://pastebin.com/p8Cnyxhx

@XueningXu
Copy link

On Ubuntu 22.04.1LTS I suggest to compile using #51 instead:

cd /tmp
git clone --quiet --depth 1 --branch "master" https://github.com/devttys0/sasquatch
cd sasquatch
wget https://github.com/devttys0/sasquatch/pull/51.patch && patch -p1 <51.patch
sudo ./build.sh

Thanks for your solution! It worked for me on WSL2 (Ubuntu 22.04).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests