LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 06-09-2013, 11:52 PM   #1
sryzdn
Member
 
Registered: Feb 2013
Posts: 274

Rep: Reputation: 9
zero byte character


Hi,

What does it mean that "zero byte" character is not allowed in file names in linux?
 
Old 06-10-2013, 12:18 AM   #2
evo2
LQ Guru
 
Registered: Jan 2009
Location: Japan
Distribution: Mostly Debian and CentOS
Posts: 6,724

Rep: Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705
Hi,

that is also known as "null character", usually represented as '\0'. Is this a specific problem you are having? If so,what is the file name, and what program is giving the error?

Evo2.
 
Old 06-10-2013, 01:48 AM   #3
sryzdn
Member
 
Registered: Feb 2013
Posts: 274

Original Poster
Rep: Reputation: 9
Quote:
Originally Posted by evo2 View Post
Hi,

that is also known as "null character", usually represented as '\0'. Is this a specific problem you are having? If so,what is the file name, and what program is giving the error?

Evo2.
I am with gcc. I am receiving the error that some file names are having disallowed zero byte characters !!! But I can not find any "\0" in any one of them !!!
 
Old 06-10-2013, 06:49 AM   #4
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,359

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
See this table http://www.asciitable.com/
 
Old 06-10-2013, 01:57 PM   #5
rtmistler
Moderator
 
Registered: Mar 2011
Location: USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 9,882
Blog Entries: 13

Rep: Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930
It's probably another un-printable character. chrism is correct you should check the ASCII table. I find that most characters which are acceptable are between 0x20 and 0x7e. But certain other characters such as "\" and "/" typically will cause problems even if you are able to name a file using those characters, same for *, ", ', `, %, #, ... try to stick with letters and numbers and use either SPACE, UNDERSCORE, or MINUS to delineate between terms in your file name.
 
Old 06-10-2013, 06:14 PM   #6
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,359

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
Traditionally on *nix, we never use space in filenames, even though its legal.
This is because the convention for programs is that space delineates a break between separate arguments.
Been working in *nix for many years and never seen a space in a filename for a file supplied by a *nix supplier.
Just about the same for anyone who has worked on *nix for any length of time; they don't put spaces.

Of course sometimes you have to deal with it eg MSWin sourced files, but when possible I replace with underscores before processing.
 
Old 06-11-2013, 04:55 AM   #7
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
Blog Entries: 31

Rep: Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208
Quote:
Originally Posted by chrism01 View Post
Just about the same for anyone who has worked on *nix for any length of time; they don't put spaces.
I started on UNIX in '91 and use spaces liberally in file names; the only consideration is whether they improve legibility (for humans).

I take the view that UNIX was designed with any character except "\" legitimate in a pathname component and only NUL impracticable to use -- so we are free to make the most of them

And, yes, I write software to suit.

EDIT: "\" is a typo for "/"

Last edited by catkin; 06-11-2013 at 07:34 AM.
 
Old 06-11-2013, 07:16 AM   #8
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,359

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
I should have said most; there's always one ....
 
Old 06-11-2013, 07:24 AM   #9
rtmistler
Moderator
 
Registered: Mar 2011
Location: USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 9,882
Blog Entries: 13

Rep: Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930
Yeah, I don't do spaces or special chars, just use either dash or underscore. You pretty much have to de-limit all chars from the top row of the keyboard with backslash if you use them in a name, plus we all got used to typing underscore over the years.

@sryzdn

Did you get your question answered/problem resolved? If not, it would make sense to cut/paste in brackets the errors you're receiving when you try compiling.
 
Old 06-11-2013, 09:24 AM   #10
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,912

Rep: Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513
It is possibly not a "unprintable" character as it is possible for a non-ascii character to be put in (these are two or three byte characters, and sometimes a null byte can be part of them).
 
Old 06-11-2013, 10:39 AM   #11
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,399
Blog Entries: 2

Rep: Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908
Quote:
Originally Posted by sryzdn View Post
But I can not find any "\0" in any one of them !!!
How are you looking for them? Most standard commandline tools don't have a way to print unprintable characters, so they show up differently on your terminal than you might expect them to. To truly see what bytes compose your filenames, I suggest using opendir() & readdir() to acquire filenames. Using this, you can then print the filenames using some code to print each individual byte in the filename using some always-printable format such as hexadecimal notation. As I understand it, blackhat hackers have used techniques such as embedding unprintable characters in filenames to conceal the presence of undesirable files, which works if the viewer of said filenames cannot reveal the true filename strings.

The readdir() man page says that the filename is supposed to be null-terminated, so effectively this rules out embedded nulls as part of the filename. Curiously, however, there is a field in struct dirent described as 'unsigned short d_reclen;', which kind of suggests that some filesystem type may allow for embedded nuls, and use the d_reclen field to describe the filename length.

--- rod.
 
1 members found this post helpful.
Old 06-11-2013, 01:23 PM   #12
sryzdn
Member
 
Registered: Feb 2013
Posts: 274

Original Poster
Rep: Reputation: 9
Quote:
Originally Posted by theNbomr View Post
How are you looking for them? Most standard commandline tools don't have a way to print unprintable characters, so they show up differently on your terminal than you might expect them to. To truly see what bytes compose your filenames, I suggest using opendir() & readdir() to acquire filenames. Using this, you can then print the filenames using some code to print each individual byte in the filename using some always-printable format such as hexadecimal notation. As I understand it, blackhat hackers have used techniques such as embedding unprintable characters in filenames to conceal the presence of undesirable files, which works if the viewer of said filenames cannot reveal the true filename strings.

The readdir() man page says that the filename is supposed to be null-terminated, so effectively this rules out embedded nulls as part of the filename. Curiously, however, there is a field in struct dirent described as 'unsigned short d_reclen;', which kind of suggests that some filesystem type may allow for embedded nuls, and use the d_reclen field to describe the filename length.

--- rod.
I found your post so useful. Thanks...
 
Old 06-11-2013, 06:47 PM   #13
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,359

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
@OP; try these cli tools
http://linux.die.net/man/1/hexedit
http://linux.die.net/man/1/od
 
1 members found this post helpful.
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] memcpy fails to copy data, but byte by byte assignment work venu_s Programming 7 07-08-2011 03:29 AM
Split a file, byte-wise, not character-wise. stf92 Linux - Newbie 4 11-17-2010 06:43 AM
about wide character and multiple byte character George2 Programming 5 05-23-2006 01:03 AM
double byte character kjsubbu Linux - General 5 02-04-2005 05:07 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 11:25 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration