mirror of
https://gitlab.com/sortix/sortix.git
synced 2023-02-13 20:55:38 -05:00
Fix sprintf uses in sh.
This commit is contained in:
parent
bb3f591057
commit
d668c5558e
1 changed files with 6 additions and 6 deletions
|
@ -63,9 +63,9 @@ void updateenv()
|
|||
struct winsize ws;
|
||||
if ( tcgetwinsize(0, &ws) == 0 )
|
||||
{
|
||||
sprintf(str, "%zu", ws.ws_col);
|
||||
snprintf(str, sizeof(str), "%zu", ws.ws_col);
|
||||
setenv("COLUMNS", str, 1);
|
||||
sprintf(str, "%zu", ws.ws_row);
|
||||
snprintf(str, sizeof(str), "%zu", ws.ws_row);
|
||||
setenv("LINES", str, 1);
|
||||
}
|
||||
}
|
||||
|
@ -211,7 +211,7 @@ readcmd:
|
|||
|
||||
updateenv();
|
||||
char statusstr[32];
|
||||
sprintf(statusstr, "%i", status);
|
||||
snprintf(statusstr, sizeof(statusstr), "%i", status);
|
||||
setenv("?", statusstr, 1);
|
||||
|
||||
for ( char** argp = argv; *argp; argp++ )
|
||||
|
@ -559,7 +559,7 @@ void load_argv_variables(int argc, char* argv[])
|
|||
{
|
||||
char varname[sizeof(int) * 3];
|
||||
for ( int i = 0; i < argc; i++ )
|
||||
sprintf(varname, "%i", i),
|
||||
snprintf(varname, sizeof(varname), "%i", i),
|
||||
setenv(varname, argv[i], 1);
|
||||
}
|
||||
|
||||
|
@ -618,8 +618,8 @@ int main(int argc, char* argv[])
|
|||
}
|
||||
char pidstr[3 * sizeof(pid_t)];
|
||||
char ppidstr[3 * sizeof(pid_t)];
|
||||
sprintf(pidstr, "%ji", (intmax_t) getpid());
|
||||
sprintf(ppidstr, "%ji", (intmax_t) getppid());
|
||||
snprintf(pidstr, sizeof(pidstr), "%ji", (intmax_t) getpid());
|
||||
snprintf(ppidstr, sizeof(ppidstr), "%ji", (intmax_t) getppid());
|
||||
setenv("SHELL", argv[0], 1);
|
||||
setenv("$", pidstr, 1);
|
||||
setenv("PPID", ppidstr, 1);
|
||||
|
|
Loading…
Add table
Reference in a new issue