comparison dbutil.c @ 1355:3fdd8c5a0195 fuzz

merge main to fuzz
author Matt Johnston <matt@ucc.asn.au>
date Thu, 18 May 2017 23:45:10 +0800
parents bbc0a0ee3843
children 6b89eb92f872 336cae2238ca 58a74cb829b8
comparison
equal deleted inserted replaced
1354:7618759e9327 1355:3fdd8c5a0195
77 void (*_dropbear_exit)(int exitcode, const char* format, va_list param) ATTRIB_NORETURN 77 void (*_dropbear_exit)(int exitcode, const char* format, va_list param) ATTRIB_NORETURN
78 = generic_dropbear_exit; 78 = generic_dropbear_exit;
79 void (*_dropbear_log)(int priority, const char* format, va_list param) 79 void (*_dropbear_log)(int priority, const char* format, va_list param)
80 = generic_dropbear_log; 80 = generic_dropbear_log;
81 81
82 #ifdef DEBUG_TRACE 82 #if DEBUG_TRACE
83 int debug_trace = 0; 83 int debug_trace = 0;
84 #endif 84 #endif
85 85
86 #ifndef DISABLE_SYSLOG 86 #ifndef DISABLE_SYSLOG
87 void startsyslog(const char *ident) { 87 void startsyslog(const char *ident) {
147 _dropbear_log(priority, format, param); 147 _dropbear_log(priority, format, param);
148 va_end(param); 148 va_end(param);
149 } 149 }
150 150
151 151
152 #ifdef DEBUG_TRACE 152 #if DEBUG_TRACE
153 153
154 static double debug_start_time = -1; 154 static double debug_start_time = -1;
155 155
156 void debug_start_net() 156 void debug_start_net()
157 { 157 {
260 } 260 }
261 if (ret_errfd && pipe(errfds) != 0) { 261 if (ret_errfd && pipe(errfds) != 0) {
262 return DROPBEAR_FAILURE; 262 return DROPBEAR_FAILURE;
263 } 263 }
264 264
265 #ifdef USE_VFORK 265 #if DROPBEAR_VFORK
266 pid = vfork(); 266 pid = vfork();
267 #else 267 #else
268 pid = fork(); 268 pid = fork();
269 #endif 269 #endif
270 270
369 } 369 }
370 370
371 execv(usershell, argv); 371 execv(usershell, argv);
372 } 372 }
373 373
374 #ifdef DEBUG_TRACE 374 #if DEBUG_TRACE
375 void printhex(const char * label, const unsigned char * buf, int len) { 375 void printhex(const char * label, const unsigned char * buf, int len) {
376 376
377 int i; 377 int i;
378 378
379 fprintf(stderr, "%s\n", label); 379 fprintf(stderr, "%s\n", label);
463 463
464 /* get a line from the file into buffer in the style expected for an 464 /* get a line from the file into buffer in the style expected for an
465 * authkeys file. 465 * authkeys file.
466 * Will return DROPBEAR_SUCCESS if data is read, or DROPBEAR_FAILURE on EOF.*/ 466 * Will return DROPBEAR_SUCCESS if data is read, or DROPBEAR_FAILURE on EOF.*/
467 /* Only used for ~/.ssh/known_hosts and ~/.ssh/authorized_keys */ 467 /* Only used for ~/.ssh/known_hosts and ~/.ssh/authorized_keys */
468 #if defined(DROPBEAR_CLIENT) || defined(ENABLE_SVR_PUBKEY_AUTH) 468 #if DROPBEAR_CLIENT || DROPBEAR_SVR_PUBKEY_AUTH
469 int buf_getline(buffer * line, FILE * authfile) { 469 int buf_getline(buffer * line, FILE * authfile) {
470 470
471 int c = EOF; 471 int c = EOF;
472 472
473 buf_setpos(line, 0); 473 buf_setpos(line, 0);
679 679
680 /* Fallback for everything else - this will sometimes go backwards */ 680 /* Fallback for everything else - this will sometimes go backwards */
681 return time(NULL); 681 return time(NULL);
682 } 682 }
683 683
684 684 void fsync_parent_dir(const char* fn) {
685 #ifdef HAVE_LIBGEN_H
686 char *fn_dir = m_strdup(fn);
687 char *dir = dirname(fn_dir);
688 int dirfd = open(dir, O_RDONLY);
689
690 if (dirfd != -1) {
691 if (fsync(dirfd) != 0) {
692 TRACE(("fsync of directory %s failed: %s", dir, strerror(errno)))
693 }
694 m_close(dirfd);
695 } else {
696 TRACE(("error opening directory %s for fsync: %s", dir, strerror(errno)))
697 }
698
699 free(fn_dir);
700 #endif
701 }