Skip to content

Commit

Permalink
Revert "fix: Give in to clang disagnostics"
Browse files Browse the repository at this point in the history
Was so wrong to stumple on C11 Annex K. Never again.
This reverts commit d7902ef.
  • Loading branch information
abelcheung committed Dec 11, 2023
1 parent d7902ef commit 9f82642
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 18 deletions.
10 changes: 4 additions & 6 deletions src/rifiuti-vista.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ _validate_index_file (const char *filename,
return FALSE;
}

copy_field (*ver, VERSION_OFFSET, FILESIZE_OFFSET);
copy_field (ver, VERSION_OFFSET, FILESIZE_OFFSET);
*ver = GUINT64_FROM_LE (*ver);
g_debug ("version = %" PRIu64, *ver);

Expand All @@ -88,7 +88,7 @@ _validate_index_file (const char *filename,

// Version 2 adds a uint32 file name strlen before file name.
// This presumably breaks the 260 char barrier in version 1.
copy_field (pathlen, VERSION1_FILENAME_OFFSET, VERSION2_FILENAME_OFFSET);
copy_field (&pathlen, VERSION1_FILENAME_OFFSET, VERSION2_FILENAME_OFFSET);
pathlen = GUINT32_FROM_LE (pathlen);

/* Header length + strlen in UTF-16 encoding */
Expand Down Expand Up @@ -140,8 +140,7 @@ _populate_record_data (void *buf,
* bug inside Windows. This is observed during deletion of dd.exe from Forensic
* Acquisition Utilities (by George M. Garner Jr) in certain localized Vista.
*/
memcpy_s (&record->filesize, sizeof(record->filesize),
buf + FILESIZE_OFFSET,
memcpy (&record->filesize, buf + FILESIZE_OFFSET,
FILETIME_OFFSET - FILESIZE_OFFSET - (int) erraneous);
if (erraneous)
{
Expand All @@ -157,8 +156,7 @@ _populate_record_data (void *buf,
}

/* File deletion time */
memcpy_s (&record->winfiletime, sizeof(record->winfiletime),
buf + FILETIME_OFFSET - (int) erraneous,
memcpy (&record->winfiletime, buf + FILETIME_OFFSET - (int) erraneous,
VERSION1_FILENAME_OFFSET - FILETIME_OFFSET);
record->winfiletime = GINT64_FROM_LE (record->winfiletime);
record->deltime = win_filetime_to_gdatetime (record->winfiletime);
Expand Down
18 changes: 8 additions & 10 deletions src/rifiuti.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,17 +66,17 @@ _validate_index_file (const char *filename,
goto validation_broken;
}

copy_field (ver, VERSION_OFFSET, KEPT_ENTRY_OFFSET);
copy_field (&ver, VERSION_OFFSET, KEPT_ENTRY_OFFSET);
ver = GUINT32_FROM_LE (ver);

// total_entry only meaningful for 95 and NT4, on other versions
// it's junk memory data, don't bother copying
if ( ( ver == VERSION_NT4 ) || ( ver == VERSION_WIN95 ) ) {
copy_field (meta->total_entry, TOTAL_ENTRY_OFFSET, RECORD_SIZE_OFFSET);
copy_field (&meta->total_entry, TOTAL_ENTRY_OFFSET, RECORD_SIZE_OFFSET);
meta->total_entry = GUINT32_FROM_LE (meta->total_entry);
}

copy_field (meta->recordsize, RECORD_SIZE_OFFSET, FILESIZE_SUM_OFFSET);
copy_field (&meta->recordsize, RECORD_SIZE_OFFSET, FILESIZE_SUM_OFFSET);
meta->recordsize = GUINT32_FROM_LE (meta->recordsize);

g_free (buf);
Expand Down Expand Up @@ -148,17 +148,15 @@ _populate_record_data (void *buf,
record = g_malloc0 (sizeof (rbin_struct));

legacy_fname = g_malloc0 (RECORD_INDEX_OFFSET - LEGACY_FILENAME_OFFSET);
memcpy_s (legacy_fname, RECORD_INDEX_OFFSET - LEGACY_FILENAME_OFFSET,
buf + LEGACY_FILENAME_OFFSET,
RECORD_INDEX_OFFSET - LEGACY_FILENAME_OFFSET);
copy_field (legacy_fname, LEGACY_FILENAME_OFFSET, RECORD_INDEX_OFFSET);

/* Index number associated with the record */
copy_field (record->index_n, RECORD_INDEX_OFFSET, DRIVE_LETTER_OFFSET);
copy_field (&record->index_n, RECORD_INDEX_OFFSET, DRIVE_LETTER_OFFSET);
record->index_n = GUINT32_FROM_LE (record->index_n);
g_debug ("index=%u", record->index_n);

/* Number representing drive letter, 'A:' = 0, etc */
copy_field (drivenum, DRIVE_LETTER_OFFSET, FILETIME_OFFSET);
copy_field (&drivenum, DRIVE_LETTER_OFFSET, FILETIME_OFFSET);
drivenum = GUINT32_FROM_LE (drivenum);
g_debug ("drive=%u", drivenum);
if (drivenum >= sizeof (driveletters) - 1) {
Expand All @@ -179,13 +177,13 @@ _populate_record_data (void *buf,
}

/* File deletion time */
copy_field (record->winfiletime, FILETIME_OFFSET, FILESIZE_OFFSET);
copy_field (&record->winfiletime, FILETIME_OFFSET, FILESIZE_OFFSET);
record->winfiletime = GINT64_FROM_LE (record->winfiletime);
record->deltime = win_filetime_to_gdatetime (record->winfiletime);

/* File size or occupied cluster size */
/* BEWARE! This is 32bit data casted to 64bit struct member */
copy_field (record->filesize, FILESIZE_OFFSET, UNICODE_FILENAME_OFFSET);
copy_field (&record->filesize, FILESIZE_OFFSET, UNICODE_FILENAME_OFFSET);
record->filesize = GUINT64_FROM_LE (record->filesize);
g_debug ("filesize=%" PRIu64, record->filesize);

Expand Down
4 changes: 2 additions & 2 deletions src/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -241,9 +241,9 @@ typedef struct _rbin_struct

} rbin_struct;

/* convenience macro that copies fixed size field */
/* convenience macro */
#define copy_field(field, off1, off2) \
memcpy_s(&(field), sizeof(field), buf + (off1), (off2) - (off1))
memcpy((field), buf + (off1), (off2) - (off1))

/*! Every Windows use this GUID in recycle bin desktop.ini */
#define RECYCLE_BIN_CLSID "645FF040-5081-101B-9F08-00AA002F954E"
Expand Down

0 comments on commit 9f82642

Please sign in to comment.