LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
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-10-2013, 12:52 AM   #1
sryzdn
Member
 
Registered: Feb 2013
Posts: 273

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, 01:18 AM   #2
evo2
LQ Guru
 
Registered: Jan 2009
Location: Japan
Distribution: Mostly Debian and Scientific Linux
Posts: 5,753

Rep: Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288
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, 02:48 AM   #3
sryzdn
Member
 
Registered: Feb 2013
Posts: 273

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, 07:49 AM   #4
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.9, Centos 7.3
Posts: 17,417

Rep: Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397
See this table http://www.asciitable.com/
 
Old 06-10-2013, 02:57 PM   #5
rtmistler
Moderator
 
Registered: Mar 2011
Location: Sutton, MA. USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu
Posts: 5,980
Blog Entries: 12

Rep: Reputation: 2044Reputation: 2044Reputation: 2044Reputation: 2044Reputation: 2044Reputation: 2044Reputation: 2044Reputation: 2044Reputation: 2044Reputation: 2044Reputation: 2044
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, 07:14 PM   #6
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.9, Centos 7.3
Posts: 17,417

Rep: Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397
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, 05:55 AM   #7
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,576
Blog Entries: 31

Rep: Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195
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 08:34 AM.
 
Old 06-11-2013, 08:16 AM   #8
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.9, Centos 7.3
Posts: 17,417

Rep: Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397
I should have said most; there's always one ....
 
Old 06-11-2013, 08:24 AM   #9
rtmistler
Moderator
 
Registered: Mar 2011
Location: Sutton, MA. USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu
Posts: 5,980
Blog Entries: 12

Rep: Reputation: 2044Reputation: 2044Reputation: 2044Reputation: 2044Reputation: 2044Reputation: 2044Reputation: 2044Reputation: 2044Reputation: 2044Reputation: 2044Reputation: 2044
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, 10:24 AM   #10
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,714

Rep: Reputation: 1280Reputation: 1280Reputation: 1280Reputation: 1280Reputation: 1280Reputation: 1280Reputation: 1280Reputation: 1280Reputation: 1280
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, 11:39 AM   #11
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,397
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, 02:23 PM   #12
sryzdn
Member
 
Registered: Feb 2013
Posts: 273

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, 07:47 PM   #13
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.9, Centos 7.3
Posts: 17,417

Rep: Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397
@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


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 04:29 AM
Split a file, byte-wise, not character-wise. stf92 Linux - Newbie 4 11-17-2010 07:43 AM
about wide character and multiple byte character George2 Programming 5 05-23-2006 02:03 AM
double byte character kjsubbu Linux - General 5 02-04-2005 06:07 PM

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

All times are GMT -5. The time now is 12:13 PM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration