-
From 34daa0d7deff6ce1f7ac0fd45682d5d0c4c52fdb Mon Sep 17 00:00:00 2001
From: Andreas Mohr <and@gmx.li>
Date: Sun, 20 Dec 2015 01:42:50 +0100
Subject: [PATCH] robust sizeof() usage at function parameter and use memcpy
destination sizeof for more resilient to errors
Signed-off-by: Andreas Mohr <and@gmx.li>
---
lib/tty/key.c | 2 +-
lib/utilunix.c | 4 ++--
lib/widget/input_complete.c | 4 ++--
src/background.c | 20 ++++++++++----------
src/diffviewer/ydiff.c | 2 +-
src/editor/edit.c | 2 +-
src/editor/editdraw.c | 2 +-
src/filemanager/cmd.c | 4 ++--
src/filemanager/dir.c | 2 +-
src/filemanager/filegui.c | 22 +++++++++++-----------
src/filemanager/mountlist.c | 2 +-
src/filemanager/panelize.c | 2 +-
src/setup.c | 4 ++--
src/subshell/common.c | 2 +-
src/vfs/ftpfs/ftpfs.c | 4 ++--
src/vfs/sftpfs/config_parser.c | 2 +-
src/vfs/sftpfs/connection.c | 2 +-
src/vfs/sftpfs/vfs_class.c | 2 +-
src/vfs/sftpfs/vfs_subclass.c | 2 +-
src/vfs/smbfs/helpers/lib/system.c | 2 +-
src/vfs/smbfs/helpers/lib/util.c | 4 ++--
src/vfs/smbfs/helpers/lib/util_sock.c | 6 +++---
src/vfs/smbfs/helpers/libsmb/clientgen.c | 8 ++++----
src/vfs/smbfs/helpers/libsmb/namequery.c | 2 +-
src/vfs/smbfs/helpers/libsmb/nmblib.c | 2 +-
src/vfs/smbfs/helpers/param/loadparm.c | 2 +-
src/vfs/smbfs/smbfs.c | 24 ++++++++++++------------
src/vfs/tar/tar.c | 2 +-
src/viewer/coord_cache.c | 2 +-
tests/lib/utilunix__my_system-common.c | 10 +++++-----
30 files changed, 75 insertions(+), 75 deletions(-)
diff --git a/lib/tty/key.c b/lib/tty/key.c
index e3e38f3..8e862ff 100644
a
|
b
|
get_modifier (void) |
923 | 923 | { |
924 | 924 | int shift_ext_status; |
925 | 925 | |
926 | | if (devctl (fileno (stdin), DCMD_CHR_LINESTATUS, &mod_status, sizeof (int), NULL) == -1) |
| 926 | if (devctl (fileno (stdin), DCMD_CHR_LINESTATUS, &mod_status, sizeof (mod_status), NULL) == -1) |
927 | 927 | return 0; |
928 | 928 | shift_ext_status = mod_status & 0xffffff00UL; |
929 | 929 | mod_status &= 0x7f; |
-
diff --git a/lib/utilunix.c b/lib/utilunix.c
index 3498845..0f4219e 100644
a
|
b
|
close_error_pipe (int error, const char *text) |
798 | 798 | return 1; |
799 | 799 | } |
800 | 800 | close (old_error); |
801 | | len = read (error_pipe[0], msg, MAX_PIPE_SIZE - 1); |
| 801 | len = read (error_pipe[0], msg, sizeof (msg)); |
802 | 802 | |
803 | 803 | if (len >= 0) |
804 | 804 | msg[len] = 0; |
… |
… |
mc_realpath (const char *path, char *resolved_path) |
1132 | 1132 | } |
1133 | 1133 | else |
1134 | 1134 | { |
1135 | | g_snprintf (got_path, PATH_MAX, "%s", new_path); |
| 1135 | g_snprintf (got_path, sizeof (got_path), "%s", new_path); |
1136 | 1136 | g_free (new_path); |
1137 | 1137 | new_path = got_path; |
1138 | 1138 | } |
-
diff --git a/lib/widget/input_complete.c b/lib/widget/input_complete.c
index 200d414..bc43302 100644
a
|
b
|
fetch_hosts (const char *filename) |
399 | 399 | if (!file) |
400 | 400 | return; |
401 | 401 | |
402 | | while (fgets (buffer, 255, file) != NULL) |
| 402 | while (fgets (buffer, sizeof (buffer) - 1, file) != NULL) |
403 | 403 | { |
404 | 404 | /* Skip to first character. */ |
405 | 405 | for (bi = buffer; bi[0] != '\0' && str_isspace (bi); str_next_char (&bi)); |
… |
… |
try_complete (char *text, int *lc_start, int *lc_end, input_complete_t flags) |
1284 | 1284 | try_complete_automation_state_t state; |
1285 | 1285 | char **matches = NULL; |
1286 | 1286 | |
1287 | | memset (&state, 0, sizeof (try_complete_automation_state_t)); |
| 1287 | memset (&state, 0, sizeof (state)); |
1288 | 1288 | state.flags = flags; |
1289 | 1289 | |
1290 | 1290 | SHOW_C_CTX ("try_complete"); |
-
diff --git a/src/background.c b/src/background.c
index a2ab343..05ffc9f 100644
a
|
b
|
background_attention (int fd, void *closure) |
256 | 256 | |
257 | 257 | if (have_ctx) |
258 | 258 | { |
259 | | if (read (fd, ctx, sizeof (file_op_context_t)) != sizeof (file_op_context_t)) |
| 259 | if (read (fd, ctx, sizeof (*ctx)) != sizeof (*ctx)) |
260 | 260 | { |
261 | 261 | return reading_failed (-1, data); |
262 | 262 | } |
… |
… |
background_attention (int fd, void *closure) |
342 | 342 | } |
343 | 343 | |
344 | 344 | /* Send the result code and the value for shared variables */ |
345 | | ret = write (to_child_fd, &result, sizeof (int)); |
| 345 | ret = write (to_child_fd, &result, sizeof (result)); |
346 | 346 | if (have_ctx && to_child_fd != -1) |
347 | | ret = write (to_child_fd, ctx, sizeof (file_op_context_t)); |
| 347 | ret = write (to_child_fd, ctx, sizeof (*ctx)); |
348 | 348 | } |
349 | 349 | else if (type == Return_String) |
350 | 350 | { |
… |
… |
parent_call_header (void *routine, int argc, enum ReturnType type, file_op_conte |
416 | 416 | have_ctx = (ctx != NULL); |
417 | 417 | |
418 | 418 | ret = write (parent_fd, &routine, sizeof (routine)); |
419 | | ret = write (parent_fd, &argc, sizeof (int)); |
| 419 | ret = write (parent_fd, &argc, sizeof (argc)); |
420 | 420 | ret = write (parent_fd, &type, sizeof (type)); |
421 | 421 | ret = write (parent_fd, &have_ctx, sizeof (have_ctx)); |
422 | 422 | |
423 | 423 | if (have_ctx) |
424 | | ret = write (parent_fd, ctx, sizeof (file_op_context_t)); |
| 424 | ret = write (parent_fd, ctx, sizeof (*ctx)); |
425 | 425 | (void) ret; |
426 | 426 | } |
427 | 427 | |
… |
… |
parent_va_call (void *routine, gpointer data, int argc, va_list ap) |
442 | 442 | |
443 | 443 | len = va_arg (ap, int); |
444 | 444 | value = va_arg (ap, void *); |
445 | | ret = write (parent_fd, &len, sizeof (int)); |
| 445 | ret = write (parent_fd, &len, sizeof (len)); |
446 | 446 | ret = write (parent_fd, value, len); |
447 | 447 | } |
448 | 448 | |
449 | | ret = read (from_parent_fd, &i, sizeof (int)); |
| 449 | ret = read (from_parent_fd, &i, sizeof (i)); |
450 | 450 | if (ctx) |
451 | | ret = read (from_parent_fd, ctx, sizeof (file_op_context_t)); |
| 451 | ret = read (from_parent_fd, ctx, sizeof (*ctx)); |
452 | 452 | |
453 | 453 | (void) ret; |
454 | 454 | return i; |
… |
… |
parent_va_call_string (void *routine, int argc, va_list ap) |
470 | 470 | |
471 | 471 | len = va_arg (ap, int); |
472 | 472 | value = va_arg (ap, void *); |
473 | | if ((write (parent_fd, &len, sizeof (int)) != sizeof (int)) || |
| 473 | if ((write (parent_fd, &len, sizeof (len)) != sizeof (len)) || |
474 | 474 | (write (parent_fd, value, len) != len)) |
475 | 475 | { |
476 | 476 | return NULL; |
477 | 477 | } |
478 | 478 | } |
479 | 479 | |
480 | | if (read (from_parent_fd, &i, sizeof (int)) != sizeof (int)) |
| 480 | if (read (from_parent_fd, &i, sizeof (i)) != sizeof (i)) |
481 | 481 | return NULL; |
482 | 482 | if (!i) |
483 | 483 | return NULL; |
-
diff --git a/src/diffviewer/ydiff.c b/src/diffviewer/ydiff.c
index d1597cc..9575a5a 100644
a
|
b
|
lcsubstr (const char *s, int m, const char *t, int n, GArray * ret, int min) |
1065 | 1065 | Lprev = Lcurr; |
1066 | 1066 | Lcurr = L; |
1067 | 1067 | #ifdef USE_MEMSET_IN_LCS |
1068 | | memset (Lcurr, 0, (n + 1) * sizeof (int)); |
| 1068 | memset (Lcurr, 0, (n + 1) * sizeof (*Lcurr)); |
1069 | 1069 | #endif |
1070 | 1070 | for (j = 0; j < n; j++) |
1071 | 1071 | { |
-
diff --git a/src/editor/edit.c b/src/editor/edit.c
index 808239b..da93edc 100644
a
|
b
|
edit_reload_line (WEdit * edit, const vfs_path_t * filename_vpath, long line) |
2238 | 2238 | } |
2239 | 2239 | |
2240 | 2240 | edit_clean (edit); |
2241 | | memcpy (edit, e, sizeof (WEdit)); |
| 2241 | memcpy (edit, e, sizeof (*edit)); |
2242 | 2242 | g_free (e); |
2243 | 2243 | |
2244 | 2244 | return TRUE; |
-
diff --git a/src/editor/editdraw.c b/src/editor/editdraw.c
index 0fd09c2..bb92ac7 100644
a
|
b
|
edit_draw_this_line (WEdit * edit, off_t b, long row, long start_col, long end_c |
554 | 554 | cur_line = edit->start_line + row; |
555 | 555 | if (cur_line <= (unsigned int) edit->buffer.lines) |
556 | 556 | { |
557 | | g_snprintf (line_stat, LINE_STATE_WIDTH + 1, "%7i ", cur_line + 1); |
| 557 | g_snprintf (line_stat, sizeof (line_stat), "%7i ", cur_line + 1); |
558 | 558 | } |
559 | 559 | else |
560 | 560 | { |
-
diff --git a/src/filemanager/cmd.c b/src/filemanager/cmd.c
index 0179aed..8bcf299 100644
a
|
b
|
compare_files (const vfs_path_t * vpath1, const vfs_path_t * vpath2, off_t size) |
247 | 247 | rotate_dash (TRUE); |
248 | 248 | do |
249 | 249 | { |
250 | | while ((n1 = read (file1, buf1, BUFSIZ)) == -1 && errno == EINTR); |
251 | | while ((n2 = read (file2, buf2, BUFSIZ)) == -1 && errno == EINTR); |
| 250 | while ((n1 = read (file1, buf1, sizeof (buf1))) == -1 && errno == EINTR); |
| 251 | while ((n2 = read (file2, buf2, sizeof (buf2))) == -1 && errno == EINTR); |
252 | 252 | } |
253 | 253 | while (n1 == n2 && n1 == BUFSIZ && !memcmp (buf1, buf2, BUFSIZ)); |
254 | 254 | result = (n1 != n2) || memcmp (buf1, buf2, n1); |
-
diff --git a/src/filemanager/dir.c b/src/filemanager/dir.c
index 92ea653..347ff64 100644
a
|
b
|
dir_list_init (dir_list * list) |
561 | 561 | } |
562 | 562 | |
563 | 563 | fentry = &list->list[0]; |
564 | | memset (fentry, 0, sizeof (file_entry_t)); |
| 564 | memset (fentry, 0, sizeof (*fentry)); |
565 | 565 | fentry->fnamelen = 2; |
566 | 566 | fentry->fname = g_strndup ("..", fentry->fnamelen); |
567 | 567 | fentry->f.link_to_dir = 0; |
-
diff --git a/src/filemanager/filegui.c b/src/filemanager/filegui.c
index 243264b..cc070e7 100644
a
|
b
|
file_progress_show (file_op_context_t * ctx, off_t done, off_t total, |
909 | 909 | |
910 | 910 | file_eta_prepare_for_show (buffer2, ctx->eta_secs, FALSE); |
911 | 911 | if (ctx->bps == 0) |
912 | | g_snprintf (buffer, BUF_TINY, "%s %s", buffer2, stalled_msg); |
| 912 | g_snprintf (buffer, sizeof (buffer), "%s %s", buffer2, stalled_msg); |
913 | 913 | else |
914 | 914 | { |
915 | 915 | char buffer3[BUF_TINY]; |
916 | 916 | |
917 | 917 | file_bps_prepare_for_show (buffer3, ctx->bps); |
918 | | g_snprintf (buffer, BUF_TINY, "%s (%s) %s", buffer2, buffer3, stalled_msg); |
| 918 | g_snprintf (buffer, sizeof (buffer), "%s (%s) %s", buffer2, buffer3, stalled_msg); |
919 | 919 | } |
920 | 920 | } |
921 | 921 | else |
922 | 922 | { |
923 | | g_snprintf (buffer, BUF_TINY, "%s", stalled_msg); |
| 923 | g_snprintf (buffer, sizeof (buffer), "%s", stalled_msg); |
924 | 924 | } |
925 | 925 | |
926 | 926 | label_set_text (ui->progress_file_label, buffer); |
… |
… |
file_progress_show_count (file_op_context_t * ctx, size_t done, size_t total) |
942 | 942 | return; |
943 | 943 | |
944 | 944 | if (ctx->progress_totals_computed) |
945 | | g_snprintf (buffer, BUF_TINY, _("Files processed: %zu/%zu"), done, total); |
| 945 | g_snprintf (buffer, sizeof (buffer), _("Files processed: %zu/%zu"), done, total); |
946 | 946 | else |
947 | | g_snprintf (buffer, BUF_TINY, _("Files processed: %zu"), done); |
| 947 | g_snprintf (buffer, sizeof (buffer), _("Files processed: %zu"), done); |
948 | 948 | label_set_text (ui->total_files_processed_label, buffer); |
949 | 949 | } |
950 | 950 | |
… |
… |
file_progress_show_total (file_op_total_context_t * tctx, file_op_context_t * ct |
991 | 991 | { |
992 | 992 | file_eta_prepare_for_show (buffer3, tctx->eta_secs, TRUE); |
993 | 993 | if (tctx->bps == 0) |
994 | | g_snprintf (buffer, BUF_TINY, _("Time: %s %s"), buffer2, buffer3); |
| 994 | g_snprintf (buffer, sizeof (buffer), _("Time: %s %s"), buffer2, buffer3); |
995 | 995 | else |
996 | 996 | { |
997 | 997 | |
998 | 998 | file_bps_prepare_for_show (buffer4, (long) tctx->bps); |
999 | | g_snprintf (buffer, BUF_TINY, _("Time: %s %s (%s)"), buffer2, buffer3, buffer4); |
| 999 | g_snprintf (buffer, sizeof (buffer), _("Time: %s %s (%s)"), buffer2, buffer3, buffer4); |
1000 | 1000 | } |
1001 | 1001 | } |
1002 | 1002 | else |
1003 | 1003 | { |
1004 | 1004 | if (tctx->bps == 0) |
1005 | | g_snprintf (buffer, BUF_TINY, _("Time: %s"), buffer2); |
| 1005 | g_snprintf (buffer, sizeof (buffer), _("Time: %s"), buffer2); |
1006 | 1006 | else |
1007 | 1007 | { |
1008 | 1008 | file_bps_prepare_for_show (buffer4, (long) tctx->bps); |
1009 | | g_snprintf (buffer, BUF_TINY, _("Time: %s (%s)"), buffer2, buffer4); |
| 1009 | g_snprintf (buffer, sizeof (buffer), _("Time: %s (%s)"), buffer2, buffer4); |
1010 | 1010 | } |
1011 | 1011 | } |
1012 | 1012 | |
… |
… |
file_progress_show_total (file_op_total_context_t * tctx, file_op_context_t * ct |
1017 | 1017 | { |
1018 | 1018 | size_trunc_len (buffer2, 5, tctx->copied_bytes, 0, panels_options.kilobyte_si); |
1019 | 1019 | if (!ctx->progress_totals_computed) |
1020 | | g_snprintf (buffer, BUF_TINY, _(" Total: %s "), buffer2); |
| 1020 | g_snprintf (buffer, sizeof (buffer), _(" Total: %s "), buffer2); |
1021 | 1021 | else |
1022 | 1022 | { |
1023 | 1023 | size_trunc_len (buffer3, 5, ctx->progress_bytes, 0, panels_options.kilobyte_si); |
1024 | | g_snprintf (buffer, BUF_TINY, _(" Total: %s/%s "), buffer2, buffer3); |
| 1024 | g_snprintf (buffer, sizeof (buffer), _(" Total: %s/%s "), buffer2, buffer3); |
1025 | 1025 | } |
1026 | 1026 | |
1027 | 1027 | hline_set_text (ui->total_bytes_label, buffer); |
-
diff --git a/src/filemanager/mountlist.c b/src/filemanager/mountlist.c
index 0fb9e60..aec6115 100644
a
|
b
|
my_statfs (struct my_statfs *myfs_stats, const char *path) |
1726 | 1726 | |
1727 | 1727 | if (entry != NULL) |
1728 | 1728 | { |
1729 | | memset (&fs_use, 0, sizeof (struct fs_usage)); |
| 1729 | memset (&fs_use, 0, sizeof (fs_use)); |
1730 | 1730 | get_fs_usage (entry->me_mountdir, NULL, &fs_use); |
1731 | 1731 | |
1732 | 1732 | myfs_stats->type = entry->me_dev; |
-
diff --git a/src/filemanager/panelize.c b/src/filemanager/panelize.c
index 328e7c7..14d363d 100644
a
|
b
|
do_external_panelize (char *command) |
329 | 329 | while (TRUE) |
330 | 330 | { |
331 | 331 | clearerr (external); |
332 | | if (fgets (line, MC_MAXPATHLEN, external) == NULL) |
| 332 | if (fgets (line, sizeof (line), external) == NULL) |
333 | 333 | { |
334 | 334 | if (ferror (external) && errno == EINTR) |
335 | 335 | continue; |
-
diff --git a/src/setup.c b/src/setup.c
index fc57edf..9990223 100644
a
|
b
|
panel_load_setup (WPanel * panel, const char *section) |
1388 | 1388 | for (i = 0; i < LIST_TYPES; i++) |
1389 | 1389 | { |
1390 | 1390 | g_free (panel->user_status_format[i]); |
1391 | | g_snprintf (buffer2, BUF_TINY, "user_status%lld", (long long) i); |
| 1391 | g_snprintf (buffer2, sizeof (buffer2), "user_status%lld", (long long) i); |
1392 | 1392 | panel->user_status_format[i] = |
1393 | 1393 | mc_config_get_string (mc_panels_config, section, buffer2, DEFAULT_USER_FORMAT); |
1394 | 1394 | } |
… |
… |
panel_save_setup (WPanel * panel, const char *section) |
1424 | 1424 | |
1425 | 1425 | for (i = 0; i < LIST_TYPES; i++) |
1426 | 1426 | { |
1427 | | g_snprintf (buffer, BUF_TINY, "user_status%lld", (long long) i); |
| 1427 | g_snprintf (buffer, sizeof (buffer), "user_status%lld", (long long) i); |
1428 | 1428 | mc_config_set_string (mc_panels_config, section, buffer, panel->user_status_format[i]); |
1429 | 1429 | } |
1430 | 1430 | |
-
diff --git a/src/subshell/common.c b/src/subshell/common.c
index e0163f0..d36aa12 100644
a
|
b
|
feed_subshell (int how, int fail_on_error) |
570 | 570 | else if (FD_ISSET (subshell_pipe[READ], &read_set)) |
571 | 571 | /* Read the subshell's CWD and capture its prompt */ |
572 | 572 | { |
573 | | bytes = read (subshell_pipe[READ], subshell_cwd, MC_MAXPATHLEN + 1); |
| 573 | bytes = read (subshell_pipe[READ], subshell_cwd, sizeof (subshell_cwd)); |
574 | 574 | if (bytes <= 0) |
575 | 575 | { |
576 | 576 | tcsetattr (STDOUT_FILENO, TCSANOW, &shell_mode); |
-
diff --git a/src/vfs/ftpfs/ftpfs.c b/src/vfs/ftpfs/ftpfs.c
index d7c6485..84c730c 100644
a
|
b
|
ftpfs_open_socket (struct vfs_class *me, struct vfs_s_super *super) |
832 | 832 | |
833 | 833 | tty_enable_interrupt_key (); /* clear the interrupt flag */ |
834 | 834 | |
835 | | memset (&hints, 0, sizeof (struct addrinfo)); |
| 835 | memset (&hints, 0, sizeof (hints)); |
836 | 836 | hints.ai_family = AF_UNSPEC; |
837 | 837 | hints.ai_socktype = SOCK_STREAM; |
838 | 838 | |
… |
… |
ftpfs_init_data_socket (struct vfs_class *me, struct vfs_s_super *super, |
1258 | 1258 | { |
1259 | 1259 | int result; |
1260 | 1260 | |
1261 | | memset (data_addr, 0, sizeof (struct sockaddr_storage)); |
| 1261 | memset (data_addr, 0, sizeof (*data_addr)); |
1262 | 1262 | *data_addrlen = sizeof (struct sockaddr_storage); |
1263 | 1263 | |
1264 | 1264 | if (SUP->use_passive_connection) |
-
diff --git a/src/vfs/sftpfs/config_parser.c b/src/vfs/sftpfs/config_parser.c
index c1cdc4b..7c51e72 100644
a
|
b
|
sftpfs_fill_config_entity_from_config (FILE * ssh_config_handler, |
220 | 220 | while (!feof (ssh_config_handler)) |
221 | 221 | { |
222 | 222 | char *cr; |
223 | | if (fgets (buffer, BUF_MEDIUM, ssh_config_handler) == NULL) |
| 223 | if (fgets (buffer, sizeof (buffer), ssh_config_handler) == NULL) |
224 | 224 | { |
225 | 225 | if (errno != 0) |
226 | 226 | { |
-
diff --git a/src/vfs/sftpfs/connection.c b/src/vfs/sftpfs/connection.c
index 9b97fd0..55323af 100644
a
|
b
|
sftpfs_open_socket (struct vfs_s_super *super, GError ** mcerror) |
83 | 83 | |
84 | 84 | tty_enable_interrupt_key (); /* clear the interrupt flag */ |
85 | 85 | |
86 | | memset (&hints, 0, sizeof (struct addrinfo)); |
| 86 | memset (&hints, 0, sizeof (hints)); |
87 | 87 | hints.ai_family = AF_UNSPEC; |
88 | 88 | hints.ai_socktype = SOCK_STREAM; |
89 | 89 | |
-
diff --git a/src/vfs/sftpfs/vfs_class.c b/src/vfs/sftpfs/vfs_class.c
index 3504c26..a0f709c 100644
a
|
b
|
sftpfs_cb_fill_names (struct vfs_class *me, fill_names_f func) |
675 | 675 | void |
676 | 676 | sftpfs_init_class (void) |
677 | 677 | { |
678 | | memset (&sftpfs_class, 0, sizeof (struct vfs_class)); |
| 678 | memset (&sftpfs_class, 0, sizeof (sftpfs_class)); |
679 | 679 | sftpfs_class.name = "sftpfs"; |
680 | 680 | sftpfs_class.prefix = "sftp"; |
681 | 681 | sftpfs_class.flags = VFSF_NOLINKS; |
-
diff --git a/src/vfs/sftpfs/vfs_subclass.c b/src/vfs/sftpfs/vfs_subclass.c
index ce6ae3b..4c63438 100644
a
|
b
|
sftpfs_cb_dir_load (struct vfs_class *me, struct vfs_s_inode *dir, char *remote_ |
176 | 176 | void |
177 | 177 | sftpfs_init_subclass (void) |
178 | 178 | { |
179 | | memset (&sftpfs_subclass, 0, sizeof (struct vfs_s_subclass)); |
| 179 | memset (&sftpfs_subclass, 0, sizeof (sftpfs_subclass)); |
180 | 180 | sftpfs_subclass.flags = VFS_S_REMOTE; |
181 | 181 | } |
182 | 182 | |
-
diff --git a/src/vfs/smbfs/helpers/lib/system.c b/src/vfs/smbfs/helpers/lib/system.c
index a57fb79..f23d2c5 100644
a
|
b
|
sys_select (int maxfd, fd_set * fds, struct timeval *tval) |
89 | 89 | |
90 | 90 | if (found) |
91 | 91 | { |
92 | | memcpy ((void *) fds, (void *) &fds2, sizeof (fds2)); |
| 92 | memcpy ((void *) fds, (void *) &fds2, sizeof (*fds)); |
93 | 93 | return (found); |
94 | 94 | } |
95 | 95 | |
-
diff --git a/src/vfs/smbfs/helpers/lib/util.c b/src/vfs/smbfs/helpers/lib/util.c
index 1974a84..76a24d0 100644
a
|
b
|
unix_mask_match (char *str, char *regexp, int case_sig, BOOL trans2) |
1304 | 1304 | BOOL matched; |
1305 | 1305 | |
1306 | 1306 | /* Make local copies of str and regexp */ |
1307 | | StrnCpy (p1, regexp, sizeof (pstring) - 1); |
1308 | | StrnCpy (p2, str, sizeof (pstring) - 1); |
| 1307 | StrnCpy (p1, regexp, sizeof (p1) - 1); |
| 1308 | StrnCpy (p2, str, sizeof (p2) - 1); |
1309 | 1309 | |
1310 | 1310 | if (!strchr (p2, '.')) |
1311 | 1311 | { |
-
diff --git a/src/vfs/smbfs/helpers/lib/util_sock.c b/src/vfs/smbfs/helpers/lib/util_sock.c
index 877fac1..2e12895 100644
a
|
b
|
is_a_socket (int fd) |
60 | 60 | { |
61 | 61 | int v; |
62 | 62 | unsigned int l; |
63 | | l = sizeof (int); |
| 63 | l = sizeof (l); |
64 | 64 | return (getsockopt (fd, SOL_SOCKET, SO_TYPE, (char *) &v, &l) == 0); |
65 | 65 | } |
66 | 66 | |
… |
… |
set_socket_options (int fd, char *options) |
161 | 161 | case OPT_BOOL: |
162 | 162 | case OPT_INT: |
163 | 163 | ret = setsockopt (fd, socket_options[i].level, |
164 | | socket_options[i].option, (char *) &value, sizeof (int)); |
| 164 | socket_options[i].option, (char *) &value, sizeof (value)); |
165 | 165 | break; |
166 | 166 | |
167 | 167 | case OPT_ON: |
… |
… |
set_socket_options (int fd, char *options) |
171 | 171 | { |
172 | 172 | int on = socket_options[i].value; |
173 | 173 | ret = setsockopt (fd, socket_options[i].level, |
174 | | socket_options[i].option, (char *) &on, sizeof (int)); |
| 174 | socket_options[i].option, (char *) &on, sizeof (on)); |
175 | 175 | } |
176 | 176 | break; |
177 | 177 | } |
-
diff --git a/src/vfs/smbfs/helpers/libsmb/clientgen.c b/src/vfs/smbfs/helpers/libsmb/clientgen.c
index 6426357..3a6eb9a 100644
a
|
b
|
cli_errstr (struct cli_state *cli) |
158 | 158 | |
159 | 159 | if (nt_msg == NULL) |
160 | 160 | { |
161 | | slprintf (error_message, sizeof (fstring) - 1, "NT code %d", nt_rpc_error); |
| 161 | slprintf (error_message, sizeof (error_message) - 1, "NT code %d", nt_rpc_error); |
162 | 162 | } |
163 | 163 | else |
164 | 164 | { |
… |
… |
cli_session_request (struct cli_state * cli, struct nmb_name * calling, struct n |
2430 | 2430 | int len = 4; |
2431 | 2431 | /* send a session request (RFC 1002) */ |
2432 | 2432 | |
2433 | | memcpy (&(cli->calling), calling, sizeof (*calling)); |
2434 | | memcpy (&(cli->called), called, sizeof (*called)); |
| 2433 | memcpy (&(cli->calling), calling, sizeof (cli->calling)); |
| 2434 | memcpy (&(cli->called), called, sizeof (cli->called)); |
2435 | 2435 | |
2436 | 2436 | /* put in the destination name */ |
2437 | 2437 | p = cli->outbuf + len; |
… |
… |
cli_chkpath (struct cli_state * cli, char *path) |
2932 | 2932 | pstring path2; |
2933 | 2933 | char *p; |
2934 | 2934 | |
2935 | | safe_strcpy (path2, path, sizeof (pstring) - 1); |
| 2935 | safe_strcpy (path2, path, sizeof (path2) - 1); |
2936 | 2936 | trim_string (path2, NULL, "\\"); |
2937 | 2937 | if (!*path2) |
2938 | 2938 | *path2 = '\\'; |
-
diff --git a/src/vfs/smbfs/helpers/libsmb/namequery.c b/src/vfs/smbfs/helpers/libsmb/namequery.c
index 69064d8..cee5bee 100644
a
|
b
|
getlmhostsent (FILE * fp, pstring name, int *name_type, struct in_addr * ipaddr) |
270 | 270 | |
271 | 271 | *name_type = -1; |
272 | 272 | |
273 | | if (!fgets_slash (line, sizeof (pstring), fp)) |
| 273 | if (!fgets_slash (line, sizeof (line), fp)) |
274 | 274 | continue; |
275 | 275 | |
276 | 276 | if (*line == '#') |
-
diff --git a/src/vfs/smbfs/helpers/libsmb/nmblib.c b/src/vfs/smbfs/helpers/libsmb/nmblib.c
index 4e80058..ab5d036 100644
a
|
b
|
void |
830 | 830 | make_nmb_name (struct nmb_name *n, const char *name, int type) |
831 | 831 | { |
832 | 832 | extern pstring global_scope; |
833 | | memset ((char *) n, '\0', sizeof (struct nmb_name)); |
| 833 | memset ((char *) n, '\0', sizeof (*n)); |
834 | 834 | StrnCpy (n->name, name, 15); |
835 | 835 | strupper (n->name); |
836 | 836 | n->name_type = (unsigned int) type & 0xFF; |
-
diff --git a/src/vfs/smbfs/helpers/param/loadparm.c b/src/vfs/smbfs/helpers/param/loadparm.c
index da1a608..075ce38 100644
a
|
b
|
initialise a service to the defaults |
1398 | 1398 | ***************************************************************************/ |
1399 | 1399 | static void init_service (service * pservice) |
1400 | 1400 | { |
1401 | | memset ((char *) pservice, '\0', sizeof (service)); |
| 1401 | memset ((char *) pservice, '\0', sizeof (*pservice)); |
1402 | 1402 | copy_service (pservice, &sDefault, NULL); |
1403 | 1403 | } |
1404 | 1404 | |
-
diff --git a/src/vfs/smbfs/smbfs.c b/src/vfs/smbfs/smbfs.c
index cf507e6..670a5e5 100644
a
|
b
|
smbfs_free_bucket (smbfs_connection * bucket) |
1179 | 1179 | g_free (bucket->user); |
1180 | 1180 | wipe_password (bucket->password); |
1181 | 1181 | g_free (bucket->home); |
1182 | | memset (bucket, 0, sizeof (smbfs_connection)); |
| 1182 | memset (bucket, 0, sizeof (*bucket)); |
1183 | 1183 | } |
1184 | 1184 | |
1185 | 1185 | /* --------------------------------------------------------------------------------------------- */ |
… |
… |
smbfs_fake_server_stat (const char *server_url, const char *path, struct stat *b |
1451 | 1451 | { |
1452 | 1452 | DEBUG (4, ("smbfs_fake_server_stat: %s:%4o\n", |
1453 | 1453 | dentry->text, (int) dentry->my_stat.st_mode)); |
1454 | | memcpy (buf, &dentry->my_stat, sizeof (struct stat)); |
| 1454 | memcpy (buf, &dentry->my_stat, sizeof (*buf)); |
1455 | 1455 | return 0; |
1456 | 1456 | } |
1457 | 1457 | dentry = dentry->next; |
… |
… |
smbfs_fake_share_stat (const char *server_url, const char *path, struct stat *bu |
1513 | 1513 | { |
1514 | 1514 | DEBUG (6, ("smbfs_fake_share_stat: %s:%4o\n", |
1515 | 1515 | dentry->text, (int) dentry->my_stat.st_mode)); |
1516 | | memcpy (buf, &dentry->my_stat, sizeof (struct stat)); |
| 1516 | memcpy (buf, &dentry->my_stat, sizeof (*buf)); |
1517 | 1517 | return 0; |
1518 | 1518 | } |
1519 | 1519 | dentry = dentry->next; |
… |
… |
smbfs_get_remote_stat (smbfs_connection * sc, const char *path, struct stat *buf |
1552 | 1552 | return -1; /* cli_list returns number of files */ |
1553 | 1553 | } |
1554 | 1554 | |
1555 | | memcpy (buf, &single_entry->my_stat, sizeof (struct stat)); |
| 1555 | memcpy (buf, &single_entry->my_stat, sizeof (*buf)); |
1556 | 1556 | |
1557 | 1557 | /* don't free here, use for smbfs_fstat() */ |
1558 | 1558 | /* g_free(single_entry->text); |
… |
… |
smbfs_search_dir_entry (dir_entry * dentry, const char *text, struct stat *buf) |
1570 | 1570 | { |
1571 | 1571 | if (strcmp (text, dentry->text) == 0) |
1572 | 1572 | { |
1573 | | memcpy (buf, &dentry->my_stat, sizeof (struct stat)); |
1574 | | memcpy (&single_entry->my_stat, &dentry->my_stat, sizeof (struct stat)); |
| 1573 | memcpy (buf, &dentry->my_stat, sizeof (*buf)); |
| 1574 | memcpy (&single_entry->my_stat, &dentry->my_stat, sizeof (single_entry->my_stat)); |
1575 | 1575 | return 0; |
1576 | 1576 | } |
1577 | 1577 | dentry = dentry->next; |
… |
… |
smbfs_get_stat_info (smbfs_connection * sc, const char *path, struct stat *buf) |
1620 | 1620 | mydir = p + 1; /* advance util last '/' */ |
1621 | 1621 | if (strcmp (mydir, mypath) == 0) |
1622 | 1622 | { /* fake a stat for ".." */ |
1623 | | memset (buf, 0, sizeof (struct stat)); |
| 1623 | memset (buf, 0, sizeof (*buf)); |
1624 | 1624 | buf->st_mode = (S_IFDIR | S_IRUSR | S_IRGRP | S_IROTH) & myumask; |
1625 | | memcpy (&single_entry->my_stat, buf, sizeof (struct stat)); |
| 1625 | memcpy (&single_entry->my_stat, buf, sizeof (single_entry->my_stat)); |
1626 | 1626 | g_free (mdp); |
1627 | 1627 | DEBUG (1, (" PARENT:found in %s\n", current_info->dirname)); |
1628 | 1628 | return 0; |
… |
… |
smbfs_get_stat_info (smbfs_connection * sc, const char *path, struct stat *buf) |
1642 | 1642 | } |
1643 | 1643 | if (strcmp (mypath, dnp) == 0) |
1644 | 1644 | { |
1645 | | memset (buf, 0, sizeof (struct stat)); |
| 1645 | memset (buf, 0, sizeof (*buf)); |
1646 | 1646 | buf->st_mode = (S_IFDIR | S_IRUSR | S_IRGRP | S_IROTH) & myumask; |
1647 | | memcpy (&single_entry->my_stat, buf, sizeof (struct stat)); |
| 1647 | memcpy (&single_entry->my_stat, buf, sizeof (single_entry->my_stat)); |
1648 | 1648 | DEBUG (1, (" CURRENT:found in %s\n", current_info->dirname)); |
1649 | 1649 | return 0; |
1650 | 1650 | } |
… |
… |
smbfs_stat (const vfs_path_t * vpath, struct stat *buf) |
1793 | 1793 | { |
1794 | 1794 | /* make server name appear as directory */ |
1795 | 1795 | DEBUG (1, ("smbfs_stat: showing server as directory\n")); |
1796 | | memset (buf, 0, sizeof (struct stat)); |
| 1796 | memset (buf, 0, sizeof (*buf)); |
1797 | 1797 | buf->st_mode = (S_IFDIR | S_IRUSR | S_IRGRP | S_IROTH) & myumask; |
1798 | 1798 | g_free (service); |
1799 | 1799 | return 0; |
… |
… |
smbfs_fstat (void *data, struct stat *buf) |
2195 | 2195 | |
2196 | 2196 | /* use left over from previous smbfs_get_remote_stat, if available */ |
2197 | 2197 | if (single_entry) |
2198 | | memcpy (buf, &single_entry->my_stat, sizeof (struct stat)); |
| 2198 | memcpy (buf, &single_entry->my_stat, sizeof (*buf)); |
2199 | 2199 | else |
2200 | 2200 | { /* single_entry not set up: bug */ |
2201 | 2201 | my_errno = EFAULT; |
-
diff --git a/src/vfs/tar/tar.c b/src/vfs/tar/tar.c
index db7c691..3b9ef67 100644
a
|
b
|
tar_get_next_record (struct vfs_s_super *archive, int tard) |
354 | 354 | |
355 | 355 | (void) archive; |
356 | 356 | |
357 | | n = mc_read (tard, rec_buf.charptr, RECORDSIZE); |
| 357 | n = mc_read (tard, rec_buf.charptr, sizeof (rec_buf.charptr)); |
358 | 358 | if (n != RECORDSIZE) |
359 | 359 | return NULL; /* An error has occurred */ |
360 | 360 | current_tar_position += RECORDSIZE; |
-
diff --git a/src/viewer/coord_cache.c b/src/viewer/coord_cache.c
index 152ed92..fb8a792 100644
a
|
b
|
mcview_ccache_add_entry (coord_cache_t * cache, size_t pos, const coord_cache_en |
94 | 94 | if (pos != cache->size) |
95 | 95 | memmove (cache->cache[pos + 1], cache->cache[pos], |
96 | 96 | (cache->size - pos) * sizeof (coord_cache_entry_t *)); |
97 | | cache->cache[pos] = g_memdup (entry, sizeof (coord_cache_entry_t)); |
| 97 | cache->cache[pos] = g_memdup (entry, sizeof (*entry)); |
98 | 98 | cache->size++; |
99 | 99 | } |
100 | 100 | |
-
diff --git a/tests/lib/utilunix__my_system-common.c b/tests/lib/utilunix__my_system-common.c
index 70124ff..508e1d1 100644
a
|
b
|
sigaction (int signum, const struct sigaction *act, struct sigaction *oldact) |
63 | 63 | |
64 | 64 | /* store signum */ |
65 | 65 | tmp_signum = g_new (int, 1); |
66 | | memcpy (tmp_signum, &signum, sizeof (int)); |
| 66 | memcpy (tmp_signum, &signum, sizeof (*tmp_signum)); |
67 | 67 | if (sigaction_signum__captured != NULL) |
68 | 68 | g_ptr_array_add (sigaction_signum__captured, tmp_signum); |
69 | 69 | |
… |
… |
sigaction (int signum, const struct sigaction *act, struct sigaction *oldact) |
71 | 71 | if (act != NULL) |
72 | 72 | { |
73 | 73 | tmp_act = g_new (struct sigaction, 1); |
74 | | memcpy (tmp_act, act, sizeof (struct sigaction)); |
| 74 | memcpy (tmp_act, act, sizeof (*tmp_act)); |
75 | 75 | } |
76 | 76 | else |
77 | 77 | tmp_act = NULL; |
… |
… |
sigaction (int signum, const struct sigaction *act, struct sigaction *oldact) |
82 | 82 | if (oldact != NULL) |
83 | 83 | { |
84 | 84 | tmp_act = g_new (struct sigaction, 1); |
85 | | memcpy (tmp_act, oldact, sizeof (struct sigaction)); |
| 85 | memcpy (tmp_act, oldact, sizeof (*tmp_act)); |
86 | 86 | } |
87 | 87 | else |
88 | 88 | tmp_act = NULL; |
… |
… |
signal (int signum, sighandler_t handler) |
131 | 131 | |
132 | 132 | /* store signum */ |
133 | 133 | tmp_signum = g_new (int, 1); |
134 | | memcpy (tmp_signum, &signum, sizeof (int)); |
| 134 | memcpy (tmp_signum, &signum, sizeof (*tmp_signum)); |
135 | 135 | g_ptr_array_add (signal_signum__captured, tmp_signum); |
136 | 136 | |
137 | 137 | /* store handler */ |
138 | 138 | if (handler != SIG_DFL) |
139 | 139 | { |
140 | 140 | tmp_handler = g_new (sighandler_t, 1); |
141 | | memcpy (tmp_handler, handler, sizeof (sighandler_t)); |
| 141 | memcpy (tmp_handler, handler, sizeof (*tmp_handler)); |
142 | 142 | } |
143 | 143 | else |
144 | 144 | tmp_handler = (void *) SIG_DFL; |