Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nx-libs
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
1
Issues
1
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
dimbor
nx-libs
Commits
19a3918a
Commit
19a3918a
authored
Jan 02, 2018
by
Ulrich Sibiller
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Display.c: pass down buffer size to nxagentLookForIconFile
Also comment the code and convert error messages to warnings.
parent
ea1e0bea
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
24 deletions
+22
-24
Display.c
nx-X11/programs/Xserver/hw/nxagent/Display.c
+22
-24
No files found.
nx-X11/programs/Xserver/hw/nxagent/Display.c
View file @
19a3918a
...
...
@@ -1815,12 +1815,10 @@ FIXME: Is this needed?
}
static
FILE
*
nxagentLookForIconFile
(
char
*
iconName
,
const
char
*
permission
,
char
*
return_path
)
char
*
return_path
,
int
return_path_size
)
{
char
*
path
;
char
*
end
;
char
singlePath
[
PATH_MAX
];
int
breakLoop
;
FILE
*
fptr
=
NULL
;
#ifdef WIN32
...
...
@@ -1836,56 +1834,56 @@ static FILE *nxagentLookForIconFile(char *iconName, const char *permission,
return
NULL
;
}
for
(
breakLoop
=
0
;
breakLoop
==
0
&&
fptr
==
NULL
;
)
for
(
int
breakLoop
=
False
;
breakLoop
==
False
&&
fptr
==
NULL
;
)
{
end
=
strchr
(
path
,
separator
);
char
*
end
=
strchr
(
path
,
separator
);
/* separator found */
if
(
end
!=
NULL
)
{
if
((
end
-
path
)
>
sizeof
(
singlePath
)
-
1
)
{
fprintf
(
stderr
,
"Warning: P
ath too long - ignored
.
\n
"
);
fprintf
(
stderr
,
"Warning: P
ATH component too long - ignoring it
.
\n
"
);
path
=
end
+
1
;
continue
;
}
strncpy
(
singlePath
,
path
,
(
unsigned
long
)(
end
-
path
));
singlePath
[(
unsigned
long
)(
end
-
path
)]
=
'\0'
;
snprintf
(
singlePath
,
(
unsigned
long
)(
end
-
path
+
1
),
"%s"
,
path
);
path
=
end
+
1
;
}
else
{
if
(
strlen
(
path
)
>
sizeof
(
singlePath
)
-
1
)
{
fprintf
(
stderr
,
"
Error: Path too long
.
\n
"
);
fprintf
(
stderr
,
"
Warning: PATH component too long - ignoring it
.
\n
"
);
return
NULL
;
}
s
trcpy
(
singlePath
,
path
);
s
nprintf
(
singlePath
,
sizeof
(
singlePath
),
"%s"
,
path
);
breakLoop
=
1
;
breakLoop
=
True
;
}
if
(
singlePath
[
strlen
(
singlePath
)
-
1
]
==
slash
[
0
])
/* cut off trailing slashes, if any */
while
(
singlePath
[
strlen
(
singlePath
)
-
1
]
==
slash
[
0
])
{
singlePath
[
strlen
(
singlePath
)
-
1
]
=
'\0'
;
singlePath
[
strlen
(
singlePath
)
-
1
]
=
'\0'
;
}
if
(
strlen
(
singlePath
)
+
strlen
(
iconName
)
+
1
<
sizeof
(
singlePath
)
<
)
/* append slash and icon name */
if
(
strlen
(
singlePath
)
+
strlen
(
iconName
)
+
1
<
sizeof
(
singlePath
))
{
strncat
(
singlePath
,
slash
,
1
);
strcat
(
singlePath
,
iconName
);
if
((
fptr
=
fopen
(
singlePath
,
permission
))
!=
NULL
)
{
s
trcpy
(
return_path
,
singlePath
);
s
nprintf
(
return_path
,
return_path_size
,
"%s"
,
singlePath
);
}
}
else
{
fprintf
(
stderr
,
"
Error: P
ath too long.
\n
"
);
fprintf
(
stderr
,
"
Warning: Icon p
ath too long.
\n
"
);
}
}
...
...
@@ -1909,13 +1907,13 @@ Bool nxagentMakeIcon(Display *display, Pixmap *nxIcon, Pixmap *nxMask)
*/
if
(
nxagentX2go
)
{
agent_icon_name
=
X2GOAGENT_ICON_NAME
;
agentIconData
=
x2goagentIconData
;
agent_icon_name
=
X2GOAGENT_ICON_NAME
;
agentIconData
=
x2goagentIconData
;
}
else
{
agent_icon_name
=
NXAGENT_ICON_NAME
;
agentIconData
=
nxagentIconData
;
agent_icon_name
=
NXAGENT_ICON_NAME
;
agentIconData
=
nxagentIconData
;
}
/* FIXME: use a compile time define here, /usr/NX is a nomachine path */
...
...
@@ -1923,7 +1921,7 @@ Bool nxagentMakeIcon(Display *display, Pixmap *nxIcon, Pixmap *nxMask)
if
((
icon_fp
=
fopen
(
default_path
,
"r"
))
==
NULL
)
{
icon_fp
=
nxagentLookForIconFile
(
agent_icon_name
,
"r"
,
icon_path
);
icon_fp
=
nxagentLookForIconFile
(
agent_icon_name
,
"r"
,
icon_path
,
sizeof
(
icon_path
)
);
if
(
icon_fp
!=
NULL
)
{
...
...
@@ -1935,7 +1933,7 @@ Bool nxagentMakeIcon(Display *display, Pixmap *nxIcon, Pixmap *nxMask)
{
fclose
(
icon_fp
);
success
=
True
;
s
trcpy
(
icon_path
,
default_path
);
s
nprintf
(
icon_path
,
sizeof
(
icon_path
),
"%s"
,
default_path
);
}
if
(
success
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment