FreeBSD Bugzilla – Attachment 146223 Details for
Bug 192971
[PATCH]Some utilies might lead to overflow
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Diff proposal
patch-atoi.txt (text/plain), 2.53 KB, created by
David CARLIER
on 2014-08-24 18:51:04 UTC
(
hide
)
Description:
Diff proposal
Filename:
MIME Type:
Creator:
David CARLIER
Created:
2014-08-24 18:51:04 UTC
Size:
2.53 KB
patch
obsolete
>Index: bin/ls/ls.c >=================================================================== >--- bin/ls/ls.c (revision 270508) >+++ bin/ls/ls.c (working copy) >@@ -157,6 +157,7 @@ > struct winsize win; > int ch, fts_options, notused; > char *p; >+ const char *errstr = NULL; > #ifdef COLORLS > char termcapbuf[1024]; /* termcap definition buffer */ > char tcapbuf[512]; /* capability buffer */ >@@ -169,7 +170,7 @@ > if (isatty(STDOUT_FILENO)) { > termwidth = 80; > if ((p = getenv("COLUMNS")) != NULL && *p != '\0') >- termwidth = atoi(p); >+ termwidth = strtonum(p, 0, INT_MAX, &errstr); > else if (ioctl(STDOUT_FILENO, TIOCGWINSZ, &win) != -1 && > win.ws_col > 0) > termwidth = win.ws_col; >@@ -179,9 +180,12 @@ > /* retrieve environment variable, in case of explicit -C */ > p = getenv("COLUMNS"); > if (p) >- termwidth = atoi(p); >+ termwidth = strtonum(p, 0, INT_MAX, &errstr); > } > >+ if (errstr) >+ termwidth = 80; >+ > fts_options = FTS_PHYSICAL; > if (getenv("LS_SAMESORT")) > f_samesort = 1; >Index: bin/stty/stty.c >=================================================================== >--- bin/stty/stty.c (revision 270492) >+++ bin/stty/stty.c (working copy) >@@ -50,6 +50,7 @@ > #include <stdio.h> > #include <stdlib.h> > #include <string.h> >+#include <limits.h> > #include <unistd.h> > > #include "stty.h" >@@ -61,7 +62,7 @@ > struct info i; > enum FMT fmt; > int ch; >- const char *file; >+ const char *file, *errstr = NULL; > > fmt = NOTSET; > i.fd = STDIN_FILENO; >@@ -130,7 +131,9 @@ > if (isdigit(**argv)) { > speed_t speed; > >- speed = atoi(*argv); >+ speed = strtonum(*argv, 0, UINT_MAX, &errstr); >+ if (errstr) >+ err(1, "speed"); > cfsetospeed(&i.t, speed); > cfsetispeed(&i.t, speed); > i.set = 1; >Index: contrib/nvi/cl/cl_term.c >=================================================================== >--- contrib/nvi/cl/cl_term.c (revision 270492) >+++ contrib/nvi/cl/cl_term.c (working copy) >@@ -360,6 +360,7 @@ > size_t col, row; > int rval; > char *p; >+ const char *errstr = NULL; > > /* Assume it's changed. */ > if (changedp != NULL) >@@ -451,10 +452,16 @@ > * deleting the LINES and COLUMNS environment variables from their > * dot-files. > */ >- if ((p = getenv("LINES")) != NULL) >- row = strtol(p, NULL, 10); >- if ((p = getenv("COLUMNS")) != NULL) >- col = strtol(p, NULL, 10); >+ if ((p = getenv("LINES")) != NULL) { >+ row = strtonum(p, 0, INT_MAX, &errstr); >+ if (errstr) >+ row = 24; >+ } >+ if ((p = getenv("COLUMNS")) != NULL) { >+ col = strtonum(p, 0, INT_MAX, &errstr); >+ if (errstr) >+ col = 80; >+ } > > if (rowp != NULL) > *rowp = row;
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 192971
: 146223 |
146248