~steve-sk2/linuxconsole/master

« back to all changes in this revision

Viewing changes to utils/ffmvforce.c

  • Committer: Stephen Kitt
  • Date: 2013-05-06 18:10:51 UTC
  • Revision ID: git-v1:8ad75f68352b21d4b0d4a407ec9e2dcbc0502340
Handle long device names correctly

Instead of copying device names using strncpy (incorrectly), simply
keep a pointer to the correct device name. Thanks to Ralf Jung
<post@ralfj.de> for identifying the bug
(http://bugs.debian.org/706744) and finding a nice fix.

Show diffs side-by-side

added added

removed removed

Lines of Context:
38
38
#include <SDL.h>
39
39
 
40
40
#define BIT(x) (1<<(x))
41
 
#define STR_LEN 64
42
41
#define WIN_W   400
43
42
#define WIN_H   400
44
43
#define max(a,b)        ((a)>(b)?(a):(b))
116
115
int main(int argc, char** argv)
117
116
{
118
117
        SDL_Surface* screen;
119
 
        char dev_name[STR_LEN];
 
118
        const char * dev_name = "/dev/input/event0";
120
119
        int i;
121
120
        Uint32 ticks, period = 200;
122
121
 
124
123
        if (argc <= 1) return 0;
125
124
 
126
125
        /* Parse parameters */
127
 
        strcpy(dev_name, "/dev/input/event0");
128
126
        for (i=1; i<argc; ++i) {
129
127
                if (strcmp(argv[i], "--help") == 0) {
130
128
                        printf("Usage: %s /dev/input/eventXX [-u update frequency in HZ]\n", argv[0]);
139
137
                        period = 1000.0/atof(argv[i]);
140
138
                }
141
139
                else {
142
 
                        strncpy(dev_name, argv[i], STR_LEN);
 
140
                        dev_name = argv[i];
143
141
                }
144
142
        }
145
143