- (djm) Support in bsd-snprintf.c for long long conversions from
Ben Lindstrom <mouring@pconline.com> - (djm) Cleanup NeXT support from Ben Lindstrom <mouring@pconline.com>
This commit is contained in:
parent
bea034a5bf
commit
3dfb0dd7fd
|
@ -38,6 +38,10 @@
|
|||
* missing. Some systems only have snprintf() but not vsnprintf(), so
|
||||
* the code is now broken down under HAVE_SNPRINTF and HAVE_VSNPRINTF.
|
||||
*
|
||||
* Ben Lindstrom <mouring@pconline.com> 09/27/00 for OpenSSH
|
||||
* Welcome to the world of %lld and %qd support. With other
|
||||
* long long support. This is needed for sftp-server to work
|
||||
* right.
|
||||
**************************************************************/
|
||||
|
||||
#include "config.h"
|
||||
|
@ -111,9 +115,10 @@ static void dopr_outch (char *buffer, size_t *currlen, size_t maxlen, char c );
|
|||
#define DP_F_UNSIGNED (1 << 6)
|
||||
|
||||
/* Conversion Flags */
|
||||
#define DP_C_SHORT 1
|
||||
#define DP_C_LONG 2
|
||||
#define DP_C_LDOUBLE 3
|
||||
#define DP_C_SHORT 1
|
||||
#define DP_C_LONG 2
|
||||
#define DP_C_LDOUBLE 3
|
||||
#define DP_C_LONG_LONG 4
|
||||
|
||||
#define char_to_int(p) (p - '0')
|
||||
#ifndef MAX
|
||||
|
@ -222,7 +227,6 @@ static void dopr (char *buffer, size_t maxlen, const char *format, va_list args)
|
|||
state = DP_S_MOD;
|
||||
break;
|
||||
case DP_S_MOD:
|
||||
/* Currently, we don't support Long Long, bummer */
|
||||
switch (ch)
|
||||
{
|
||||
case 'h':
|
||||
|
@ -232,7 +236,15 @@ static void dopr (char *buffer, size_t maxlen, const char *format, va_list args)
|
|||
case 'l':
|
||||
cflags = DP_C_LONG;
|
||||
ch = *format++;
|
||||
if (ch == 'l') {
|
||||
cflags = DP_C_LONG_LONG;
|
||||
ch = *format++;
|
||||
}
|
||||
break;
|
||||
case 'q':
|
||||
cflags = DP_C_LONG_LONG;
|
||||
ch = *format++;
|
||||
break;
|
||||
case 'L':
|
||||
cflags = DP_C_LDOUBLE;
|
||||
ch = *format++;
|
||||
|
@ -251,6 +263,8 @@ static void dopr (char *buffer, size_t maxlen, const char *format, va_list args)
|
|||
value = va_arg (args, short int);
|
||||
else if (cflags == DP_C_LONG)
|
||||
value = va_arg (args, long int);
|
||||
else if (cflags == DP_C_LONG_LONG)
|
||||
value = va_arg (args, long long);
|
||||
else
|
||||
value = va_arg (args, int);
|
||||
fmtint (buffer, &currlen, maxlen, value, 10, min, max, flags);
|
||||
|
@ -261,6 +275,8 @@ static void dopr (char *buffer, size_t maxlen, const char *format, va_list args)
|
|||
value = va_arg (args, unsigned short int);
|
||||
else if (cflags == DP_C_LONG)
|
||||
value = va_arg (args, unsigned long int);
|
||||
else if (cflags == DP_C_LONG_LONG)
|
||||
value = va_arg (args, unsigned long long);
|
||||
else
|
||||
value = va_arg (args, unsigned int);
|
||||
fmtint (buffer, &currlen, maxlen, value, 8, min, max, flags);
|
||||
|
@ -271,6 +287,8 @@ static void dopr (char *buffer, size_t maxlen, const char *format, va_list args)
|
|||
value = va_arg (args, unsigned short int);
|
||||
else if (cflags == DP_C_LONG)
|
||||
value = va_arg (args, unsigned long int);
|
||||
else if (cflags == DP_C_LONG_LONG)
|
||||
value = va_arg (args, unsigned long long);
|
||||
else
|
||||
value = va_arg (args, unsigned int);
|
||||
fmtint (buffer, &currlen, maxlen, value, 10, min, max, flags);
|
||||
|
@ -283,6 +301,8 @@ static void dopr (char *buffer, size_t maxlen, const char *format, va_list args)
|
|||
value = va_arg (args, unsigned short int);
|
||||
else if (cflags == DP_C_LONG)
|
||||
value = va_arg (args, unsigned long int);
|
||||
else if (cflags == DP_C_LONG_LONG)
|
||||
value = va_arg (args, unsigned long long);
|
||||
else
|
||||
value = va_arg (args, unsigned int);
|
||||
fmtint (buffer, &currlen, maxlen, value, 16, min, max, flags);
|
||||
|
@ -337,6 +357,12 @@ static void dopr (char *buffer, size_t maxlen, const char *format, va_list args)
|
|||
num = va_arg (args, long int *);
|
||||
*num = currlen;
|
||||
}
|
||||
else if (cflags == DP_C_LONG_LONG)
|
||||
{
|
||||
long long *num;
|
||||
num = va_arg (args, long long *);
|
||||
*num = currlen;
|
||||
}
|
||||
else
|
||||
{
|
||||
int *num;
|
||||
|
@ -747,9 +773,11 @@ int main (void)
|
|||
"%+22.33d",
|
||||
"%01.3d",
|
||||
"%4d",
|
||||
"%lld",
|
||||
"%qd",
|
||||
NULL
|
||||
};
|
||||
long int_nums[] = { -1, 134, 91340, 341, 0203, 0};
|
||||
long long int_nums[] = { -1, 134, 91340, 341, 0203, 0, 9999999 };
|
||||
int x, y;
|
||||
int fail = 0;
|
||||
int num = 0;
|
||||
|
|
61
next-posix.c
61
next-posix.c
|
@ -1,3 +1,25 @@
|
|||
/*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "includes.h"
|
||||
|
||||
#ifdef HAVE_NEXT
|
||||
|
@ -8,46 +30,32 @@
|
|||
pid_t
|
||||
posix_wait(int *status)
|
||||
{
|
||||
#undef wait /* Use NeXT's wait() function */
|
||||
union wait statusp;
|
||||
pid_t wait_pid;
|
||||
|
||||
#undef wait /* Use NeXT's wait() function */
|
||||
wait_pid = wait(&statusp);
|
||||
status = (int *) statusp.w_status;
|
||||
|
||||
return wait_pid;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
posix_utime(char *filename,struct utimbuf *buf)
|
||||
{
|
||||
time_t timep[2];
|
||||
|
||||
timep[0] = buf->actime;
|
||||
timep[1] = buf->modtime;
|
||||
|
||||
#undef utime /* Use NeXT's utime() function */
|
||||
return utime(filename,timep);
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
waitpid(int pid, int *stat_loc, int options)
|
||||
pid_t
|
||||
waitpid(int pid, int *stat_loc, int options)
|
||||
{
|
||||
union wait statusp;
|
||||
pid_t wait_pid;
|
||||
|
||||
if (pid <= 0) {
|
||||
if (pid != -1) {
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
pid = 0; /* wait4() expects pid=0 for indiscriminate wait. */
|
||||
pid = 0; /* wait4() wants pid=0 for indiscriminate wait. */
|
||||
}
|
||||
return wait4(pid, (union wait *)stat_loc, options, NULL);
|
||||
}
|
||||
|
||||
pid_t setsid(void)
|
||||
{
|
||||
return setpgrp(0, getpid());
|
||||
wait_pid = wait4(pid, &statusp, options, NULL);
|
||||
stat_loc = (int *)statusp.w_status;
|
||||
return wait_pid;
|
||||
}
|
||||
|
||||
int
|
||||
|
@ -81,10 +89,7 @@ tcsetattr(int fd, int opt, const struct termios *t)
|
|||
|
||||
int tcsetpgrp(int fd, pid_t pgrp)
|
||||
{
|
||||
int s;
|
||||
|
||||
s = pgrp;
|
||||
return (ioctl(fd, TIOCSPGRP, &s));
|
||||
return (ioctl(fd, TIOCSPGRP, &pgrp));
|
||||
}
|
||||
|
||||
speed_t cfgetospeed(const struct termios *t)
|
||||
|
|
45
next-posix.h
45
next-posix.h
|
@ -1,5 +1,24 @@
|
|||
/*
|
||||
* Defines and prototypes specific to NeXT system
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _NEXT_POSIX_H
|
||||
|
@ -9,15 +28,9 @@
|
|||
|
||||
#include <sys/dir.h>
|
||||
|
||||
/* readdir() returns struct direct (BSD) not struct dirent (POSIX) */
|
||||
/* NeXT's Readdir() is BSD (struct direct) not POSIX (struct dirent) */
|
||||
#define dirent direct
|
||||
|
||||
/* POSIX utime() struct */
|
||||
struct utimbuf {
|
||||
time_t actime;
|
||||
time_t modtime;
|
||||
};
|
||||
|
||||
/* FILE */
|
||||
#define O_NONBLOCK 00004 /* non-blocking open */
|
||||
|
||||
|
@ -31,19 +44,14 @@ struct utimbuf {
|
|||
#define WIFSIGNALED(w) (!WIFEXITED(w) && !WIFSTOPPED(w))
|
||||
#define WEXITSTATUS(w) (int)(WIFEXITED(w) ? (((w) >> 8) & 0377) : -1)
|
||||
#define WTERMSIG(w) (int)(WIFSIGNALED(w) ? ((w) & 0177) : -1)
|
||||
#define WCOREFLAG 0x80
|
||||
#define WCOREDUMP(w) ((w) & WCOREFLAG)
|
||||
|
||||
/* POSIX "wrapper" functions to replace to BSD functions */
|
||||
int posix_utime(char *filename, struct utimbuf *buf); /* new utime() */
|
||||
#define utime posix_utime
|
||||
|
||||
pid_t posix_wait(int *status); /* new wait() */
|
||||
#define wait posix_wait
|
||||
/* Swap out the next 'BSDish' wait() for a more POSIX complient one */
|
||||
pid_t posix_wait(int *status);
|
||||
#define wait(a) posix_wait(a)
|
||||
|
||||
/* MISC functions */
|
||||
int waitpid(int pid, int *stat_loc, int options);
|
||||
pid_t setsid(void);
|
||||
#define setsid() setpgrp(0, getpid())
|
||||
pid_t waitpid(int pid, int *stat_loc, int options);
|
||||
|
||||
/* TERMCAP */
|
||||
int tcgetattr(int fd, struct termios *t);
|
||||
|
@ -54,5 +62,4 @@ speed_t cfgetispeed(const struct termios *t);
|
|||
int cfsetospeed(struct termios *t, int speed);
|
||||
|
||||
#endif /* HAVE_NEXT */
|
||||
|
||||
#endif /* _NEXT_POSIX_H */
|
||||
|
|
2
sshd.c
2
sshd.c
|
@ -1263,7 +1263,7 @@ do_ssh1_kex()
|
|||
if (len < 0 || len > sizeof(session_key))
|
||||
fatal("do_connection: bad len from %s: session_key_int %d > sizeof(session_key) %d",
|
||||
get_remote_ipaddr(),
|
||||
len, sizeof(session_key));
|
||||
len, (int) sizeof(session_key));
|
||||
memset(session_key, 0, sizeof(session_key));
|
||||
BN_bn2bin(session_key_int, session_key + sizeof(session_key) - len);
|
||||
|
||||
|
|
Loading…
Reference in New Issue