Menu

#2 support for long camera names

open
nobody
None
5
2009-01-06
2009-01-06
John Loza
No

I downloaded the flashcam utility to try and get my webcam to work with various flash driven websites. I got a strange error when running it. After looking at the source, I discovered that the name of my camera (uvcvideo/VF0540 Live! Cam Video IM/Video 0000:00:02.1) was too long for the variable allocated to hold it. I upped the size of the variable to allow for longer camera names. I also changed the "strcpy" to "strncpy" to prevent buffer overflow.

diff output vs. flashcam 1.2 distro
--- code ---
~/flashcam-1.2$ diff flashcam.c flashcam.c.old
751c751
< char name[128]; // Device name reported by driver
---
> char name[32]; // Device name reported by driver
788,789c788,789
< strncpy(devices[nbDevices].dev, dev,
sizeof(devices[nbDevices].dev));
< strncpy(devices[nbDevices].name, (char *)&v4l2cap.card,
sizeof(devices[nbDevices].name));
---
> strcpy(devices[nbDevices].dev, dev);
> strcpy(devices[nbDevices].name, (char *)&v4l2cap.card);
802,803c802,803
< strncpy(devices[nbDevices].dev, dev,
sizeof(devices[nbDevices].dev));
< strncpy(devices[nbDevices].name, v4l1cap.name,
sizeof(devices[nbDevices].name));
---
> strcpy(devices[nbDevices].dev, dev);
> strcpy(devices[nbDevices].name, v4l1cap.name);
~/flashcam-1.2$
--- end code ---

Discussion


Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.