mirror of
https://github.com/libssh2/libssh2.git
synced 2026-10-24 03:48:58 +03:00
@@ -16,11 +16,13 @@ my @options = (
|
||||
"-aaccept",
|
||||
"-aatoi",
|
||||
"-acalloc",
|
||||
"-aclose",
|
||||
"-aCreateFileA",
|
||||
"-afclose",
|
||||
"-afopen",
|
||||
"-afprintf",
|
||||
"-afree",
|
||||
"-afstat",
|
||||
"-amalloc",
|
||||
"-aprintf",
|
||||
"-arealloc",
|
||||
|
||||
@@ -49,6 +49,8 @@ my @ignore_line;
|
||||
|
||||
my %banfunc = (
|
||||
"_access" => 1,
|
||||
"_fstati64" => 1,
|
||||
"_lseeki64" => 1,
|
||||
"_mbscat" => 1,
|
||||
"_mbsncat" => 1,
|
||||
"_open" => 1,
|
||||
@@ -70,6 +72,7 @@ my %banfunc = (
|
||||
"atoi" => 1,
|
||||
"atol" => 1,
|
||||
"calloc" => 1,
|
||||
"close" => 1,
|
||||
"CreateFile" => 1,
|
||||
"CreateFileA" => 1,
|
||||
"CreateFileW" => 1,
|
||||
@@ -80,9 +83,11 @@ my %banfunc = (
|
||||
"free" => 1,
|
||||
"freeaddrinfo" => 1,
|
||||
"freopen" => 1,
|
||||
"fstat" => 1,
|
||||
"getaddrinfo" => 1,
|
||||
"gets" => 1,
|
||||
"gmtime" => 1,
|
||||
"llseek" => 1,
|
||||
"LoadLibrary" => 1,
|
||||
"LoadLibraryA" => 1,
|
||||
"LoadLibraryEx" => 1,
|
||||
@@ -90,6 +95,7 @@ my %banfunc = (
|
||||
"LoadLibraryExW" => 1,
|
||||
"LoadLibraryW" => 1,
|
||||
"localtime" => 1,
|
||||
"lseek" => 1,
|
||||
"malloc" => 1,
|
||||
"mbstowcs" => 1,
|
||||
"MoveFileEx" => 1,
|
||||
@@ -149,11 +155,12 @@ my %warnings = (
|
||||
'BRACEPOS' => 'wrong position for an open brace',
|
||||
'BRACEWHILE' => 'A single space between open brace and while',
|
||||
'COMMANOSPACE' => 'comma without following space',
|
||||
"CLOSEBRACE" => 'close brace indent level vs line above is off',
|
||||
'CLOSEBRACE' => 'close brace indent level vs line above is off',
|
||||
'COMMENTNOSPACEEND' => 'no space before */',
|
||||
'COMMENTNOSPACESTART' => 'no space following /*',
|
||||
'COPYRIGHT' => 'file missing a copyright statement',
|
||||
'CPPCOMMENTS' => '// comment detected',
|
||||
'CPPSPACE' => 'space before preprocessor hash',
|
||||
'DOBRACE' => 'A single space between do and open brace',
|
||||
'EMPTYLINEBRACE' => 'Empty line before the open brace',
|
||||
'EQUALSNOSPACE' => 'equals sign without following space',
|
||||
@@ -266,7 +273,7 @@ sub readlocalfile {
|
||||
sub checkwarn {
|
||||
my ($name, $num, $col, $file, $line, $msg, $error) = @_;
|
||||
|
||||
my $w=$error?"error":"warning";
|
||||
my $w=$error ? "error" : "warning";
|
||||
my $nowarn=0;
|
||||
|
||||
#if(!$warnings{$name}) {
|
||||
@@ -405,7 +412,7 @@ readskiplist();
|
||||
readlocalfile($file);
|
||||
|
||||
do {
|
||||
if("$wlist" !~ / $file /) {
|
||||
if($wlist !~ / $file /) {
|
||||
my $fullname = $file;
|
||||
$fullname = "$dir/$file" if($fullname !~ '^\.?\.?/');
|
||||
scanfile($fullname);
|
||||
@@ -674,6 +681,11 @@ sub scanfile {
|
||||
$includes{$path} = $l;
|
||||
}
|
||||
|
||||
# detect leading space before the hash
|
||||
if($l =~ /^([ \t]+)\#/) {
|
||||
checkwarn("CPPSPACE",
|
||||
$line, 0, $file, $l, "space before preprocessor hash");
|
||||
}
|
||||
# detect and strip preprocessor directives
|
||||
if($l =~ /^[ \t]*\#/) {
|
||||
# preprocessor line
|
||||
@@ -966,9 +978,11 @@ sub scanfile {
|
||||
my $bad = $2;
|
||||
my $prefix = $1;
|
||||
my $suff = $3;
|
||||
checkwarn("BANNEDFUNC",
|
||||
$line, length($prefix), $file, $ol,
|
||||
"use of $bad is banned");
|
||||
if($prefix !~ /(->|\.)$/) {
|
||||
checkwarn("BANNEDFUNC",
|
||||
$line, length($prefix), $file, $ol,
|
||||
"use of $bad is banned");
|
||||
}
|
||||
my $search = quotemeta($prefix . $bad . $suff);
|
||||
my $replace = $prefix . 'x' x (length($bad) + 1);
|
||||
$l =~ s/$search/$replace/;
|
||||
@@ -1175,7 +1189,7 @@ sub scanfile {
|
||||
# which are tracked in the Git repo and edited in the workdir, or
|
||||
# committed locally on the branch without being in upstream master.
|
||||
#
|
||||
# The simple and naive test is to simply check for the current year,
|
||||
# The simple and naive test is to check for the current year,
|
||||
# but updating the year even without an edit is against project policy
|
||||
# (and it would fail every file on January 1st).
|
||||
#
|
||||
@@ -1216,7 +1230,6 @@ sub scanfile {
|
||||
checksrc_endoffile($file);
|
||||
|
||||
close($R);
|
||||
|
||||
}
|
||||
|
||||
if($errors || $warnings || $verbose) {
|
||||
|
||||
@@ -271,11 +271,11 @@ int main(int argc, char *argv[])
|
||||
* See /etc/termcap for more options. This is useful when opening
|
||||
* an interactive shell.
|
||||
*/
|
||||
#if 0
|
||||
#if 0
|
||||
if(libssh2_channel_request_pty(channel, "vanilla")) {
|
||||
fprintf(stderr, "Failed requesting pty\n");
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
if(argc > 5) {
|
||||
if(libssh2_channel_exec(channel, argv[5])) {
|
||||
@@ -285,12 +285,12 @@ int main(int argc, char *argv[])
|
||||
/* Instead of just running a single command with libssh2_channel_exec,
|
||||
* a shell can be opened on the channel instead, for interactive use.
|
||||
* You usually want a pty allocated first in that case (see above). */
|
||||
#if 0
|
||||
#if 0
|
||||
if(libssh2_channel_shell(channel)) {
|
||||
fprintf(stderr, "Unable to request shell on allocated pty\n");
|
||||
goto shutdown;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* At this point the shell can be interacted with using
|
||||
* libssh2_channel_read()
|
||||
|
||||
@@ -44,7 +44,7 @@
|
||||
#include <stdlib.h>
|
||||
|
||||
#if MBEDTLS_VERSION_NUMBER < 0x03010000
|
||||
#error "mbedTLS 3.1.0 or upper required"
|
||||
#error "mbedTLS 3.1.0 or upper required"
|
||||
#endif
|
||||
|
||||
/*******************************************************************/
|
||||
|
||||
@@ -770,8 +770,8 @@ int _libssh2_gettimeofday(struct timeval *tp, void *tzp)
|
||||
(void)tzp;
|
||||
if(tp) {
|
||||
#ifdef _WIN32
|
||||
/* Offset between 1601-01-01 and 1970-01-01 in 100 nanosec units */
|
||||
#define _WIN32_FT_OFFSET (116444736000000000)
|
||||
/* Offset between 1601-01-01 and 1970-01-01 in 100 nanosec units */
|
||||
#define _WIN32_FT_OFFSET (116444736000000000)
|
||||
|
||||
union {
|
||||
libssh2_uint64_t ns100; /* time since 1 Jan 1601 in 100ns units */
|
||||
|
||||
@@ -39,12 +39,12 @@ int test(LIBSSH2_SESSION *session)
|
||||
}
|
||||
|
||||
channel = libssh2_channel_open_session(session);
|
||||
#if 0
|
||||
#if 0
|
||||
if(!channel) {
|
||||
printf("Error opening channel\n");
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
rc = libssh2_channel_request_auth_agent(channel);
|
||||
if(rc) {
|
||||
|
||||
@@ -66,11 +66,11 @@ int main(int argc, char *argv[])
|
||||
(void)argc;
|
||||
(void)argv;
|
||||
|
||||
#ifdef _WIN32
|
||||
#define LIBSSH2_FALLBACK_USER_ENV "USERNAME"
|
||||
#else
|
||||
#define LIBSSH2_FALLBACK_USER_ENV "LOGNAME"
|
||||
#endif
|
||||
#ifdef _WIN32
|
||||
#define LIBSSH2_FALLBACK_USER_ENV "USERNAME"
|
||||
#else
|
||||
#define LIBSSH2_FALLBACK_USER_ENV "LOGNAME"
|
||||
#endif
|
||||
|
||||
if(getenv("USER"))
|
||||
username = getenv("USER");
|
||||
|
||||
Reference in New Issue
Block a user