Ticket #3547: mc-3547-robust-sizeof-usage-at-function-parameter-and-use-me.patch

File mc-3547-robust-sizeof-usage-at-function-parameter-and-use-me.patch, 30.3 KB (added by and, 6 years ago)

reduce possible future coding faults, binary checksum not changes but this patch

  • lib/tty/key.c

    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) 
    923923    { 
    924924        int shift_ext_status; 
    925925 
    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) 
    927927            return 0; 
    928928        shift_ext_status = mod_status & 0xffffff00UL; 
    929929        mod_status &= 0x7f; 
  • lib/utilunix.c

    diff --git a/lib/utilunix.c b/lib/utilunix.c
    index 3498845..0f4219e 100644
    a b close_error_pipe (int error, const char *text) 
    798798            return 1; 
    799799        } 
    800800        close (old_error); 
    801         len = read (error_pipe[0], msg, MAX_PIPE_SIZE - 1); 
     801        len = read (error_pipe[0], msg, sizeof (msg)); 
    802802 
    803803        if (len >= 0) 
    804804            msg[len] = 0; 
    mc_realpath (const char *path, char *resolved_path) 
    11321132        } 
    11331133        else 
    11341134        { 
    1135             g_snprintf (got_path, PATH_MAX, "%s", new_path); 
     1135            g_snprintf (got_path, sizeof (got_path), "%s", new_path); 
    11361136            g_free (new_path); 
    11371137            new_path = got_path; 
    11381138        } 
  • lib/widget/input_complete.c

    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) 
    399399    if (!file) 
    400400        return; 
    401401 
    402     while (fgets (buffer, 255, file) != NULL) 
     402    while (fgets (buffer, sizeof (buffer) - 1, file) != NULL) 
    403403    { 
    404404        /* Skip to first character. */ 
    405405        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) 
    12841284    try_complete_automation_state_t state; 
    12851285    char **matches = NULL; 
    12861286 
    1287     memset (&state, 0, sizeof (try_complete_automation_state_t)); 
     1287    memset (&state, 0, sizeof (state)); 
    12881288    state.flags = flags; 
    12891289 
    12901290    SHOW_C_CTX ("try_complete"); 
  • src/background.c

    diff --git a/src/background.c b/src/background.c
    index a2ab343..05ffc9f 100644
    a b background_attention (int fd, void *closure) 
    256256 
    257257    if (have_ctx) 
    258258    { 
    259         if (read (fd, ctx, sizeof (file_op_context_t)) != sizeof (file_op_context_t)) 
     259        if (read (fd, ctx, sizeof (*ctx)) != sizeof (*ctx)) 
    260260        { 
    261261            return reading_failed (-1, data); 
    262262        } 
    background_attention (int fd, void *closure) 
    342342            } 
    343343 
    344344        /* 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)); 
    346346        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)); 
    348348    } 
    349349    else if (type == Return_String) 
    350350    { 
    parent_call_header (void *routine, int argc, enum ReturnType type, file_op_conte 
    416416    have_ctx = (ctx != NULL); 
    417417 
    418418    ret = write (parent_fd, &routine, sizeof (routine)); 
    419     ret = write (parent_fd, &argc, sizeof (int)); 
     419    ret = write (parent_fd, &argc, sizeof (argc)); 
    420420    ret = write (parent_fd, &type, sizeof (type)); 
    421421    ret = write (parent_fd, &have_ctx, sizeof (have_ctx)); 
    422422 
    423423    if (have_ctx) 
    424         ret = write (parent_fd, ctx, sizeof (file_op_context_t)); 
     424        ret = write (parent_fd, ctx, sizeof (*ctx)); 
    425425    (void) ret; 
    426426} 
    427427 
    parent_va_call (void *routine, gpointer data, int argc, va_list ap) 
    442442 
    443443        len = va_arg (ap, int); 
    444444        value = va_arg (ap, void *); 
    445         ret = write (parent_fd, &len, sizeof (int)); 
     445        ret = write (parent_fd, &len, sizeof (len)); 
    446446        ret = write (parent_fd, value, len); 
    447447    } 
    448448 
    449     ret = read (from_parent_fd, &i, sizeof (int)); 
     449    ret = read (from_parent_fd, &i, sizeof (i)); 
    450450    if (ctx) 
    451         ret = read (from_parent_fd, ctx, sizeof (file_op_context_t)); 
     451        ret = read (from_parent_fd, ctx, sizeof (*ctx)); 
    452452 
    453453    (void) ret; 
    454454    return i; 
    parent_va_call_string (void *routine, int argc, va_list ap) 
    470470 
    471471        len = va_arg (ap, int); 
    472472        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)) || 
    474474            (write (parent_fd, value, len) != len)) 
    475475        { 
    476476            return NULL; 
    477477        } 
    478478    } 
    479479 
    480     if (read (from_parent_fd, &i, sizeof (int)) != sizeof (int)) 
     480    if (read (from_parent_fd, &i, sizeof (i)) != sizeof (i)) 
    481481        return NULL; 
    482482    if (!i) 
    483483        return NULL; 
  • src/diffviewer/ydiff.c

    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) 
    10651065        Lprev = Lcurr; 
    10661066        Lcurr = L; 
    10671067#ifdef USE_MEMSET_IN_LCS 
    1068         memset (Lcurr, 0, (n + 1) * sizeof (int)); 
     1068        memset (Lcurr, 0, (n + 1) * sizeof (*Lcurr)); 
    10691069#endif 
    10701070        for (j = 0; j < n; j++) 
    10711071        { 
  • src/editor/edit.c

    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) 
    22382238    } 
    22392239 
    22402240    edit_clean (edit); 
    2241     memcpy (edit, e, sizeof (WEdit)); 
     2241    memcpy (edit, e, sizeof (*edit)); 
    22422242    g_free (e); 
    22432243 
    22442244    return TRUE; 
  • src/editor/editdraw.c

    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 
    554554        cur_line = edit->start_line + row; 
    555555        if (cur_line <= (unsigned int) edit->buffer.lines) 
    556556        { 
    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); 
    558558        } 
    559559        else 
    560560        { 
  • src/filemanager/cmd.c

    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) 
    247247            rotate_dash (TRUE); 
    248248            do 
    249249            { 
    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); 
    252252            } 
    253253            while (n1 == n2 && n1 == BUFSIZ && !memcmp (buf1, buf2, BUFSIZ)); 
    254254            result = (n1 != n2) || memcmp (buf1, buf2, n1); 
  • src/filemanager/dir.c

    diff --git a/src/filemanager/dir.c b/src/filemanager/dir.c
    index 92ea653..347ff64 100644
    a b dir_list_init (dir_list * list) 
    561561    } 
    562562 
    563563    fentry = &list->list[0]; 
    564     memset (fentry, 0, sizeof (file_entry_t)); 
     564    memset (fentry, 0, sizeof (*fentry)); 
    565565    fentry->fnamelen = 2; 
    566566    fentry->fname = g_strndup ("..", fentry->fnamelen); 
    567567    fentry->f.link_to_dir = 0; 
  • src/filemanager/filegui.c

    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, 
    909909 
    910910        file_eta_prepare_for_show (buffer2, ctx->eta_secs, FALSE); 
    911911        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); 
    913913        else 
    914914        { 
    915915            char buffer3[BUF_TINY]; 
    916916 
    917917            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); 
    919919        } 
    920920    } 
    921921    else 
    922922    { 
    923         g_snprintf (buffer, BUF_TINY, "%s", stalled_msg); 
     923        g_snprintf (buffer, sizeof (buffer), "%s", stalled_msg); 
    924924    } 
    925925 
    926926    label_set_text (ui->progress_file_label, buffer); 
    file_progress_show_count (file_op_context_t * ctx, size_t done, size_t total) 
    942942        return; 
    943943 
    944944    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); 
    946946    else 
    947         g_snprintf (buffer, BUF_TINY, _("Files processed: %zu"), done); 
     947        g_snprintf (buffer, sizeof (buffer), _("Files processed: %zu"), done); 
    948948    label_set_text (ui->total_files_processed_label, buffer); 
    949949} 
    950950 
    file_progress_show_total (file_op_total_context_t * tctx, file_op_context_t * ct 
    991991        { 
    992992            file_eta_prepare_for_show (buffer3, tctx->eta_secs, TRUE); 
    993993            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); 
    995995            else 
    996996            { 
    997997 
    998998                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); 
    10001000            } 
    10011001        } 
    10021002        else 
    10031003        { 
    10041004            if (tctx->bps == 0) 
    1005                 g_snprintf (buffer, BUF_TINY, _("Time: %s"), buffer2); 
     1005                g_snprintf (buffer, sizeof (buffer), _("Time: %s"), buffer2); 
    10061006            else 
    10071007            { 
    10081008                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); 
    10101010            } 
    10111011        } 
    10121012 
    file_progress_show_total (file_op_total_context_t * tctx, file_op_context_t * ct 
    10171017    { 
    10181018        size_trunc_len (buffer2, 5, tctx->copied_bytes, 0, panels_options.kilobyte_si); 
    10191019        if (!ctx->progress_totals_computed) 
    1020             g_snprintf (buffer, BUF_TINY, _(" Total: %s "), buffer2); 
     1020            g_snprintf (buffer, sizeof (buffer), _(" Total: %s "), buffer2); 
    10211021        else 
    10221022        { 
    10231023            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); 
    10251025        } 
    10261026 
    10271027        hline_set_text (ui->total_bytes_label, buffer); 
  • src/filemanager/mountlist.c

    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) 
    17261726 
    17271727    if (entry != NULL) 
    17281728    { 
    1729         memset (&fs_use, 0, sizeof (struct fs_usage)); 
     1729        memset (&fs_use, 0, sizeof (fs_use)); 
    17301730        get_fs_usage (entry->me_mountdir, NULL, &fs_use); 
    17311731 
    17321732        myfs_stats->type = entry->me_dev; 
  • src/filemanager/panelize.c

    diff --git a/src/filemanager/panelize.c b/src/filemanager/panelize.c
    index 328e7c7..14d363d 100644
    a b do_external_panelize (char *command) 
    329329    while (TRUE) 
    330330    { 
    331331        clearerr (external); 
    332         if (fgets (line, MC_MAXPATHLEN, external) == NULL) 
     332        if (fgets (line, sizeof (line), external) == NULL) 
    333333        { 
    334334            if (ferror (external) && errno == EINTR) 
    335335                continue; 
  • src/setup.c

    diff --git a/src/setup.c b/src/setup.c
    index fc57edf..9990223 100644
    a b panel_load_setup (WPanel * panel, const char *section) 
    13881388    for (i = 0; i < LIST_TYPES; i++) 
    13891389    { 
    13901390        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); 
    13921392        panel->user_status_format[i] = 
    13931393            mc_config_get_string (mc_panels_config, section, buffer2, DEFAULT_USER_FORMAT); 
    13941394    } 
    panel_save_setup (WPanel * panel, const char *section) 
    14241424 
    14251425    for (i = 0; i < LIST_TYPES; i++) 
    14261426    { 
    1427         g_snprintf (buffer, BUF_TINY, "user_status%lld", (long long) i); 
     1427        g_snprintf (buffer, sizeof (buffer), "user_status%lld", (long long) i); 
    14281428        mc_config_set_string (mc_panels_config, section, buffer, panel->user_status_format[i]); 
    14291429    } 
    14301430 
  • src/subshell/common.c

    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) 
    570570        else if (FD_ISSET (subshell_pipe[READ], &read_set)) 
    571571            /* Read the subshell's CWD and capture its prompt */ 
    572572        { 
    573             bytes = read (subshell_pipe[READ], subshell_cwd, MC_MAXPATHLEN + 1); 
     573            bytes = read (subshell_pipe[READ], subshell_cwd, sizeof (subshell_cwd)); 
    574574            if (bytes <= 0) 
    575575            { 
    576576                tcsetattr (STDOUT_FILENO, TCSANOW, &shell_mode); 
  • src/vfs/ftpfs/ftpfs.c

    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) 
    832832 
    833833    tty_enable_interrupt_key ();        /* clear the interrupt flag */ 
    834834 
    835     memset (&hints, 0, sizeof (struct addrinfo)); 
     835    memset (&hints, 0, sizeof (hints)); 
    836836    hints.ai_family = AF_UNSPEC; 
    837837    hints.ai_socktype = SOCK_STREAM; 
    838838 
    ftpfs_init_data_socket (struct vfs_class *me, struct vfs_s_super *super, 
    12581258{ 
    12591259    int result; 
    12601260 
    1261     memset (data_addr, 0, sizeof (struct sockaddr_storage)); 
     1261    memset (data_addr, 0, sizeof (*data_addr)); 
    12621262    *data_addrlen = sizeof (struct sockaddr_storage); 
    12631263 
    12641264    if (SUP->use_passive_connection) 
  • src/vfs/sftpfs/config_parser.c

    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, 
    220220    while (!feof (ssh_config_handler)) 
    221221    { 
    222222        char *cr; 
    223         if (fgets (buffer, BUF_MEDIUM, ssh_config_handler) == NULL) 
     223        if (fgets (buffer, sizeof (buffer), ssh_config_handler) == NULL) 
    224224        { 
    225225            if (errno != 0) 
    226226            { 
  • src/vfs/sftpfs/connection.c

    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) 
    8383 
    8484    tty_enable_interrupt_key ();        /* clear the interrupt flag */ 
    8585 
    86     memset (&hints, 0, sizeof (struct addrinfo)); 
     86    memset (&hints, 0, sizeof (hints)); 
    8787    hints.ai_family = AF_UNSPEC; 
    8888    hints.ai_socktype = SOCK_STREAM; 
    8989 
  • src/vfs/sftpfs/vfs_class.c

    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) 
    675675void 
    676676sftpfs_init_class (void) 
    677677{ 
    678     memset (&sftpfs_class, 0, sizeof (struct vfs_class)); 
     678    memset (&sftpfs_class, 0, sizeof (sftpfs_class)); 
    679679    sftpfs_class.name = "sftpfs"; 
    680680    sftpfs_class.prefix = "sftp"; 
    681681    sftpfs_class.flags = VFSF_NOLINKS; 
  • src/vfs/sftpfs/vfs_subclass.c

    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_ 
    176176void 
    177177sftpfs_init_subclass (void) 
    178178{ 
    179     memset (&sftpfs_subclass, 0, sizeof (struct vfs_s_subclass)); 
     179    memset (&sftpfs_subclass, 0, sizeof (sftpfs_subclass)); 
    180180    sftpfs_subclass.flags = VFS_S_REMOTE; 
    181181} 
    182182 
  • src/vfs/smbfs/helpers/lib/system.c

    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) 
    8989 
    9090        if (found) 
    9191        { 
    92             memcpy ((void *) fds, (void *) &fds2, sizeof (fds2)); 
     92            memcpy ((void *) fds, (void *) &fds2, sizeof (*fds)); 
    9393            return (found); 
    9494        } 
    9595 
  • src/vfs/smbfs/helpers/lib/util.c

    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) 
    13041304    BOOL matched; 
    13051305 
    13061306    /* 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); 
    13091309 
    13101310    if (!strchr (p2, '.')) 
    13111311    { 
  • src/vfs/smbfs/helpers/lib/util_sock.c

    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) 
    6060{ 
    6161    int v; 
    6262    unsigned int l; 
    63     l = sizeof (int); 
     63    l = sizeof (l); 
    6464    return (getsockopt (fd, SOL_SOCKET, SO_TYPE, (char *) &v, &l) == 0); 
    6565} 
    6666 
    set_socket_options (int fd, char *options) 
    161161        case OPT_BOOL: 
    162162        case OPT_INT: 
    163163            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)); 
    165165            break; 
    166166 
    167167        case OPT_ON: 
    set_socket_options (int fd, char *options) 
    171171            { 
    172172                int on = socket_options[i].value; 
    173173                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)); 
    175175            } 
    176176            break; 
    177177        } 
  • src/vfs/smbfs/helpers/libsmb/clientgen.c

    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) 
    158158 
    159159        if (nt_msg == NULL) 
    160160        { 
    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); 
    162162        } 
    163163        else 
    164164        { 
    cli_session_request (struct cli_state * cli, struct nmb_name * calling, struct n 
    24302430    int len = 4; 
    24312431    /* send a session request (RFC 1002) */ 
    24322432 
    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)); 
    24352435 
    24362436    /* put in the destination name */ 
    24372437    p = cli->outbuf + len; 
    cli_chkpath (struct cli_state * cli, char *path) 
    29322932    pstring path2; 
    29332933    char *p; 
    29342934 
    2935     safe_strcpy (path2, path, sizeof (pstring) - 1); 
     2935    safe_strcpy (path2, path, sizeof (path2) - 1); 
    29362936    trim_string (path2, NULL, "\\"); 
    29372937    if (!*path2) 
    29382938        *path2 = '\\'; 
  • src/vfs/smbfs/helpers/libsmb/namequery.c

    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) 
    270270 
    271271        *name_type = -1; 
    272272 
    273         if (!fgets_slash (line, sizeof (pstring), fp)) 
     273        if (!fgets_slash (line, sizeof (line), fp)) 
    274274            continue; 
    275275 
    276276        if (*line == '#') 
  • src/vfs/smbfs/helpers/libsmb/nmblib.c

    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 
    830830make_nmb_name (struct nmb_name *n, const char *name, int type) 
    831831{ 
    832832    extern pstring global_scope; 
    833     memset ((char *) n, '\0', sizeof (struct nmb_name)); 
     833    memset ((char *) n, '\0', sizeof (*n)); 
    834834    StrnCpy (n->name, name, 15); 
    835835    strupper (n->name); 
    836836    n->name_type = (unsigned int) type & 0xFF; 
  • src/vfs/smbfs/helpers/param/loadparm.c

    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 
    13981398***************************************************************************/ 
    13991399     static void init_service (service * pservice) 
    14001400{ 
    1401     memset ((char *) pservice, '\0', sizeof (service)); 
     1401    memset ((char *) pservice, '\0', sizeof (*pservice)); 
    14021402    copy_service (pservice, &sDefault, NULL); 
    14031403} 
    14041404 
  • src/vfs/smbfs/smbfs.c

    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) 
    11791179    g_free (bucket->user); 
    11801180    wipe_password (bucket->password); 
    11811181    g_free (bucket->home); 
    1182     memset (bucket, 0, sizeof (smbfs_connection)); 
     1182    memset (bucket, 0, sizeof (*bucket)); 
    11831183} 
    11841184 
    11851185/* --------------------------------------------------------------------------------------------- */ 
    smbfs_fake_server_stat (const char *server_url, const char *path, struct stat *b 
    14511451            { 
    14521452                DEBUG (4, ("smbfs_fake_server_stat: %s:%4o\n", 
    14531453                           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)); 
    14551455                return 0; 
    14561456            } 
    14571457            dentry = dentry->next; 
    smbfs_fake_share_stat (const char *server_url, const char *path, struct stat *bu 
    15131513        { 
    15141514            DEBUG (6, ("smbfs_fake_share_stat: %s:%4o\n", 
    15151515                       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)); 
    15171517            return 0; 
    15181518        } 
    15191519        dentry = dentry->next; 
    smbfs_get_remote_stat (smbfs_connection * sc, const char *path, struct stat *buf 
    15521552        return -1;              /* cli_list returns number of files */ 
    15531553    } 
    15541554 
    1555     memcpy (buf, &single_entry->my_stat, sizeof (struct stat)); 
     1555    memcpy (buf, &single_entry->my_stat, sizeof (*buf)); 
    15561556 
    15571557    /* don't free here, use for smbfs_fstat() */ 
    15581558    /*      g_free(single_entry->text); 
    smbfs_search_dir_entry (dir_entry * dentry, const char *text, struct stat *buf) 
    15701570    { 
    15711571        if (strcmp (text, dentry->text) == 0) 
    15721572        { 
    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)); 
    15751575            return 0; 
    15761576        } 
    15771577        dentry = dentry->next; 
    smbfs_get_stat_info (smbfs_connection * sc, const char *path, struct stat *buf) 
    16201620            mydir = p + 1;      /* advance util last '/' */ 
    16211621        if (strcmp (mydir, mypath) == 0) 
    16221622        {                       /* fake a stat for ".." */ 
    1623             memset (buf, 0, sizeof (struct stat)); 
     1623            memset (buf, 0, sizeof (*buf)); 
    16241624            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)); 
    16261626            g_free (mdp); 
    16271627            DEBUG (1, ("        PARENT:found in %s\n", current_info->dirname)); 
    16281628            return 0; 
    smbfs_get_stat_info (smbfs_connection * sc, const char *path, struct stat *buf) 
    16421642        } 
    16431643        if (strcmp (mypath, dnp) == 0) 
    16441644        { 
    1645             memset (buf, 0, sizeof (struct stat)); 
     1645            memset (buf, 0, sizeof (*buf)); 
    16461646            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)); 
    16481648            DEBUG (1, ("        CURRENT:found in %s\n", current_info->dirname)); 
    16491649            return 0; 
    16501650        } 
    smbfs_stat (const vfs_path_t * vpath, struct stat *buf) 
    17931793        { 
    17941794            /* make server name appear as directory */ 
    17951795            DEBUG (1, ("smbfs_stat: showing server as directory\n")); 
    1796             memset (buf, 0, sizeof (struct stat)); 
     1796            memset (buf, 0, sizeof (*buf)); 
    17971797            buf->st_mode = (S_IFDIR | S_IRUSR | S_IRGRP | S_IROTH) & myumask; 
    17981798            g_free (service); 
    17991799            return 0; 
    smbfs_fstat (void *data, struct stat *buf) 
    21952195 
    21962196    /* use left over from previous smbfs_get_remote_stat, if available */ 
    21972197    if (single_entry) 
    2198         memcpy (buf, &single_entry->my_stat, sizeof (struct stat)); 
     2198        memcpy (buf, &single_entry->my_stat, sizeof (*buf)); 
    21992199    else 
    22002200    {                           /* single_entry not set up: bug */ 
    22012201        my_errno = EFAULT; 
  • src/vfs/tar/tar.c

    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) 
    354354 
    355355    (void) archive; 
    356356 
    357     n = mc_read (tard, rec_buf.charptr, RECORDSIZE); 
     357    n = mc_read (tard, rec_buf.charptr, sizeof (rec_buf.charptr)); 
    358358    if (n != RECORDSIZE) 
    359359        return NULL;            /* An error has occurred */ 
    360360    current_tar_position += RECORDSIZE; 
  • src/viewer/coord_cache.c

    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 
    9494    if (pos != cache->size) 
    9595        memmove (cache->cache[pos + 1], cache->cache[pos], 
    9696                 (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)); 
    9898    cache->size++; 
    9999} 
    100100 
  • tests/lib/utilunix__my_system-common.c

    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) 
    6363 
    6464    /* store signum */ 
    6565    tmp_signum = g_new (int, 1); 
    66     memcpy (tmp_signum, &signum, sizeof (int)); 
     66    memcpy (tmp_signum, &signum, sizeof (*tmp_signum)); 
    6767    if (sigaction_signum__captured != NULL) 
    6868        g_ptr_array_add (sigaction_signum__captured, tmp_signum); 
    6969 
    sigaction (int signum, const struct sigaction *act, struct sigaction *oldact) 
    7171    if (act != NULL) 
    7272    { 
    7373        tmp_act = g_new (struct sigaction, 1); 
    74         memcpy (tmp_act, act, sizeof (struct sigaction)); 
     74        memcpy (tmp_act, act, sizeof (*tmp_act)); 
    7575    } 
    7676    else 
    7777        tmp_act = NULL; 
    sigaction (int signum, const struct sigaction *act, struct sigaction *oldact) 
    8282    if (oldact != NULL) 
    8383    { 
    8484        tmp_act = g_new (struct sigaction, 1); 
    85         memcpy (tmp_act, oldact, sizeof (struct sigaction)); 
     85        memcpy (tmp_act, oldact, sizeof (*tmp_act)); 
    8686    } 
    8787    else 
    8888        tmp_act = NULL; 
    signal (int signum, sighandler_t handler) 
    131131 
    132132    /* store signum */ 
    133133    tmp_signum = g_new (int, 1); 
    134     memcpy (tmp_signum, &signum, sizeof (int)); 
     134    memcpy (tmp_signum, &signum, sizeof (*tmp_signum)); 
    135135    g_ptr_array_add (signal_signum__captured, tmp_signum); 
    136136 
    137137    /* store handler */ 
    138138    if (handler != SIG_DFL) 
    139139    { 
    140140        tmp_handler = g_new (sighandler_t, 1); 
    141         memcpy (tmp_handler, handler, sizeof (sighandler_t)); 
     141        memcpy (tmp_handler, handler, sizeof (*tmp_handler)); 
    142142    } 
    143143    else 
    144144        tmp_handler = (void *) SIG_DFL;