diff options
author | Joseph Hunkeler <jhunk@stsci.edu> | 2009-09-17 20:34:13 -0400 |
---|---|---|
committer | Joseph Hunkeler <jhunk@stsci.edu> | 2009-09-17 20:34:13 -0400 |
commit | 269705bc057034970527c0c382e14003ef5b02f0 (patch) | |
tree | 32df3e2355e727ccf8892cf6aefba292a8863579 /netnuke.c | |
parent | 56a2de1b74225f056c8dee1bfd3156d1d6aea68f (diff) | |
download | NetNuke-269705bc057034970527c0c382e14003ef5b02f0.tar.gz |
Using memcpy instead of strncpy for the character arrays inside the structures. It feels more stable.
Added some more checking to see whether or not the device we wiping is actually usable or not.
Diffstat (limited to 'netnuke.c')
-rw-r--r-- | netnuke.c | 12 |
1 files changed, 6 insertions, 6 deletions
@@ -229,7 +229,7 @@ int nuke(media_t device) (intmax_t)((long double)bytes / ((long double)currentTime - (long double)startTime)), "", HN_AUTOSCALE, HN_B | HN_NOSPACE | HN_DECIMAL); - printf("%s: ", mediashort); + printf("%s: ", (char*)&device.nameshort); if(udef_passes > 1) printf("pass %d ", pass); @@ -314,7 +314,7 @@ void buildMediaList(media_t devices[]) device_stats.ide++; } - if(strstr(device.name, "da") == 0 || + else if(strstr(device.name, "da") == 0 || strstr(device.name, "sd") == 0) { device_stats.scsi++; @@ -400,9 +400,9 @@ media_t getMediaInfo(const char* media) mi.ident[0] = '\0'; #endif - strncpy(mi.name, media, strlen(media)); - strncpy(mi.nameshort, &media[5], strlen(media)); - + memcpy(mi.name, media, strlen(media)+1); + memcpy(mi.nameshort, &media[5], strlen(media)); + /* Mark the media as usuable or unusable */ if(mi.size > 0) mi.usable = USABLE_MEDIA; @@ -660,7 +660,7 @@ int main(int argc, char* argv[]) do { - if(devices[i].usable == USABLE_MEDIA && i <= device_stats.total) + if(devices[i].usable == USABLE_MEDIA && devices[i].name[0] != '\0' && i <= device_stats.total) { /* Pass control off to the nuker */ nuke(devices[i]); |