Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
emacs
emacs
Commits
9055082e
Commit
9055082e
authored
Jan 22, 2011
by
Paul Eggert
Browse files
Check return values of some library calls.
parent
f77fabaf
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
40 additions
and
11 deletions
+40
-11
lib-src/ChangeLog
lib-src/ChangeLog
+8
-0
lib-src/hexl.c
lib-src/hexl.c
+6
-2
lib-src/make-docfile.c
lib-src/make-docfile.c
+10
-3
lib-src/movemail.c
lib-src/movemail.c
+2
-1
src/ChangeLog
src/ChangeLog
+5
-0
src/emacs.c
src/emacs.c
+1
-2
src/frame.c
src/frame.c
+8
-3
No files found.
lib-src/ChangeLog
View file @
9055082e
2011-01-23 Paul Eggert <eggert@cs.ucla.edu>
Check return values of some library calls.
* hexl.c (main): Check fread result.
* make-docfile.c (main): Check chdir result.
(scan_c_file): Check fscanf result.
* movemail.c (main): Check ftruncate result.
2011-01-17 Paul Eggert <eggert@cs.ucla.edu>
Include <unistd.h> unilaterally.
...
...
lib-src/hexl.c
View file @
9055082e
...
...
@@ -179,7 +179,9 @@ main (int argc, char **argv)
#define hexchar(x) (isdigit (x) ? x - '0' : x - 'a' + 10)
fread
(
buf
,
1
,
10
,
fp
);
/* skip 10 bytes */
/* Skip 10 bytes. */
if
(
fread
(
buf
,
1
,
10
,
fp
)
!=
10
)
break
;
for
(
i
=
0
;
i
<
16
;
++
i
)
{
...
...
@@ -207,7 +209,9 @@ main (int argc, char **argv)
if
(
i
<
16
)
break
;
fread
(
buf
,
1
,
18
,
fp
);
/* skip 18 bytes */
/* Skip 18 bytes. */
if
(
fread
(
buf
,
1
,
18
,
fp
)
!=
18
)
break
;
}
}
}
...
...
lib-src/make-docfile.c
View file @
9055082e
...
...
@@ -158,7 +158,11 @@ main (int argc, char **argv)
}
if
(
argc
>
i
+
1
&&
!
strcmp
(
argv
[
i
],
"-d"
))
{
chdir
(
argv
[
i
+
1
]);
if
(
chdir
(
argv
[
i
+
1
])
!=
0
)
{
perror
(
argv
[
i
+
1
]);
return
EXIT_FAILURE
;
}
i
+=
2
;
}
...
...
@@ -648,6 +652,7 @@ scan_c_file (char *filename, const char *mode)
if
(
defunflag
&&
(
commas
==
1
||
commas
==
2
))
{
int
scanned
=
0
;
do
c
=
getc
(
infile
);
while
(
c
==
' '
||
c
==
'\n'
||
c
==
'\r'
||
c
==
'\t'
);
...
...
@@ -655,12 +660,14 @@ scan_c_file (char *filename, const char *mode)
goto
eof
;
ungetc
(
c
,
infile
);
if
(
commas
==
2
)
/* pick up minargs */
fscanf
(
infile
,
"%d"
,
&
minargs
);
scanned
=
fscanf
(
infile
,
"%d"
,
&
minargs
);
else
/* pick up maxargs */
if
(
c
==
'M'
||
c
==
'U'
)
/* MANY || UNEVALLED */
maxargs
=
-
1
;
else
fscanf
(
infile
,
"%d"
,
&
maxargs
);
scanned
=
fscanf
(
infile
,
"%d"
,
&
maxargs
);
if
(
scanned
<
0
)
goto
eof
;
}
}
...
...
lib-src/movemail.c
View file @
9055082e
...
...
@@ -488,7 +488,8 @@ main (int argc, char **argv)
#ifdef MAIL_USE_SYSTEM_LOCK
if
(
!
preserve_mail
)
{
ftruncate
(
indesc
,
0L
);
if
(
ftruncate
(
indesc
,
0L
)
!=
0
)
pfatal_with_name
(
inname
);
}
#endif
/* MAIL_USE_SYSTEM_LOCK */
...
...
src/ChangeLog
View file @
9055082e
2011-01-23 Paul Eggert <eggert@cs.ucla.edu>
Check return values of some library calls.
* emacs.c (main): Check dup result.
* frame.c: Include <limits.h>, for INT_MIN and INT_MAX.
(frame_name_fnn_p): Check strtol result.
* image.c (x_create_bitmap_from_xpm_data): Add cast to fix type clash
when calling XpmCreatePixmapFromData.
src/emacs.c
View file @
9055082e
...
...
@@ -912,13 +912,12 @@ main (int argc, char **argv)
emacs_close
(
0
);
emacs_close
(
1
);
result
=
emacs_open
(
term
,
O_RDWR
,
0
);
if
(
result
<
0
)
if
(
result
<
0
||
dup
(
0
)
<
0
)
{
char
*
errstring
=
strerror
(
errno
);
fprintf
(
stderr
,
"%s: %s: %s
\n
"
,
argv
[
0
],
term
,
errstring
);
exit
(
1
);
}
dup
(
0
);
if
(
!
isatty
(
0
))
{
fprintf
(
stderr
,
"%s: %s: not a tty
\n
"
,
argv
[
0
],
term
);
...
...
src/frame.c
View file @
9055082e
...
...
@@ -23,6 +23,8 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
#include <stdio.h>
#include <ctype.h>
#include <errno.h>
#include <limits.h>
#include <setjmp.h>
#include "lisp.h"
#include "character.h"
...
...
@@ -2149,10 +2151,13 @@ frame_name_fnn_p (char *str, EMACS_INT len)
if (len > 1 && str[0] == 'F')
{
char *end_ptr;
long int n;
errno = 0;
n = strtol (str + 1, &end_ptr, 10);
strtol (str + 1, &end_ptr, 10);
if (end_ptr == str + len
)
if (end_ptr == str + len
&& INT_MIN <= n && n <= INT_MAX
&& ((LONG_MIN < n && n < LONG_MAX) || errno != ERANGE)
)
return 1;
}
return 0;
...
...
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