Update blink1 to 1.98. Replace sprintf() and strcpy() with snprintf()
and strncpy() to avoid linker warnings. Fix a bus error that occurs when pulling the blink(1) device from the USB port while running blink1-tool --blink. OK jung@
This commit is contained in:
parent
05323901f6
commit
992c32d8de
@ -1,14 +1,13 @@
|
||||
# $OpenBSD: Makefile,v 1.3 2015/10/08 21:19:22 sthen Exp $
|
||||
# $OpenBSD: Makefile,v 1.4 2015/12/23 10:53:53 bluhm Exp $
|
||||
|
||||
SHARED_ONLY = Yes
|
||||
|
||||
COMMENT = software tools for blink(1) LED notification light
|
||||
|
||||
V = 1.97
|
||||
V = 1.98
|
||||
DISTNAME = ${GH_PROJECT}-${V}
|
||||
REVISION = 0
|
||||
|
||||
SO_V = 0.0
|
||||
SO_V = 0.1
|
||||
SHARED_LIBS = blink1 ${SO_V}
|
||||
|
||||
CATEGORIES = misc
|
||||
|
@ -1,2 +1,2 @@
|
||||
SHA256 (blink1-1.97.tar.gz) = l0citGYknuR+wnZZsWDS5P0MK8NzLQCfGA+P+1PcXZI=
|
||||
SIZE (blink1-1.97.tar.gz) = 30193800
|
||||
SHA256 (blink1-1.98.tar.gz) = K7+ISMPGVquPsBA1/TEQOjIfvuIBZGkc9n43BsS1CxY=
|
||||
SIZE (blink1-1.98.tar.gz) = 29439933
|
||||
|
@ -1,10 +1,10 @@
|
||||
$OpenBSD: patch-commandline_Makefile,v 1.1.1.1 2015/04/05 18:47:13 jung Exp $
|
||||
$OpenBSD: patch-commandline_Makefile,v 1.2 2015/12/23 10:53:53 bluhm Exp $
|
||||
|
||||
todo: submit to upstream
|
||||
|
||||
--- commandline/Makefile.orig Sat Jan 31 00:45:10 2015
|
||||
+++ commandline/Makefile Sat Mar 28 14:19:54 2015
|
||||
@@ -111,9 +111,13 @@ ifeq "$(UNAME)" "FreeBSD"
|
||||
--- commandline/Makefile.orig Wed Sep 9 03:06:56 2015
|
||||
+++ commandline/Makefile Wed Dec 23 11:33:08 2015
|
||||
@@ -113,9 +113,13 @@ ifeq "$(UNAME)" "FreeBSD"
|
||||
OS=freebsd
|
||||
endif
|
||||
|
||||
@ -19,7 +19,7 @@ todo: submit to upstream
|
||||
# deal with case of no git or no git tags, check for presence of "v" (i.e. "v1.93")
|
||||
ifneq ($(findstring v,$(GIT_TAG)), v)
|
||||
GIT_TAG:="v0"
|
||||
@@ -275,6 +279,37 @@ INCLOCATION ?= $(PREFIX)/include
|
||||
@@ -278,6 +282,37 @@ INCLOCATION ?= $(PREFIX)/include
|
||||
|
||||
endif
|
||||
|
||||
@ -57,7 +57,7 @@ todo: submit to upstream
|
||||
################# WRT Linux ################################################
|
||||
ifeq "$(OS)" "wrtlinux"
|
||||
LIBTARGET = libblink1.so
|
||||
@@ -364,7 +399,7 @@ endif
|
||||
@@ -371,7 +406,7 @@ endif
|
||||
|
||||
#CFLAGS += -O -Wall -std=gnu99 -I ../hardware/firmware
|
||||
CFLAGS += -std=gnu99
|
||||
@ -66,7 +66,7 @@ todo: submit to upstream
|
||||
CFLAGS += -DBLINK1_VERSION=\"$(BLINK1_VERSION)\"
|
||||
|
||||
OBJS += blink1-lib.o
|
||||
@@ -382,6 +417,7 @@ help:
|
||||
@@ -389,6 +424,7 @@ help:
|
||||
@echo "make OS=windows ... build Windows blink1-lib and blink1-tool"
|
||||
@echo "make OS=linux ... build Linux blink1-lib and blink1-tool"
|
||||
@echo "make OS=freebsd ... build FreeBSD blink1-lib and blink1-tool"
|
||||
@ -74,7 +74,7 @@ todo: submit to upstream
|
||||
@echo "make OS=macosx ... build Mac OS X blink1-lib and blink1-tool"
|
||||
@echo "make OS=wrt ... build OpenWrt blink1-lib and blink1-tool"
|
||||
@echo "make OS=wrtcross... build for OpenWrt using cross-compiler"
|
||||
@@ -402,7 +438,7 @@ $(OBJS): %.o: %.c
|
||||
@@ -409,7 +445,7 @@ $(OBJS): %.o: %.c
|
||||
|
||||
blink1-tool: $(OBJS) blink1-tool.o
|
||||
$(CC) $(CFLAGS) -c blink1-tool.c -o blink1-tool.o
|
||||
@ -83,7 +83,7 @@ todo: submit to upstream
|
||||
|
||||
# FIXME: verify we don't need MONGOOSE_LIBS and pthread & dl are avilable everywhere
|
||||
blink1-tiny-server: $(OBJS) server/blink1-tiny-server.c
|
||||
@@ -421,9 +457,9 @@ package: lib blink1-tool
|
||||
@@ -428,9 +464,9 @@ package: lib blink1-tool
|
||||
@#mkdir -f builds && cp blink1-tool-$(PKGOKS).zip builds
|
||||
|
||||
install: all
|
||||
|
@ -0,0 +1,34 @@
|
||||
$OpenBSD: patch-commandline_blink1-lib-lowlevel-hidapi_h,v 1.1 2015/12/23 10:53:53 bluhm Exp $
|
||||
--- commandline/blink1-lib-lowlevel-hidapi.h.orig Wed Sep 9 03:06:56 2015
|
||||
+++ commandline/blink1-lib-lowlevel-hidapi.h Wed Dec 23 00:00:26 2015
|
||||
@@ -20,8 +20,10 @@ int blink1_enumerateByVidPid(int vid, int pid)
|
||||
if( (cur_dev->vendor_id != 0 && cur_dev->product_id != 0) &&
|
||||
(cur_dev->vendor_id == vid && cur_dev->product_id == pid) ) {
|
||||
if( cur_dev->serial_number != NULL ) { // can happen if not root
|
||||
- strcpy( blink1_infos[p].path, cur_dev->path );
|
||||
- sprintf( blink1_infos[p].serial, "%ls", cur_dev->serial_number);
|
||||
+ strncpy( blink1_infos[p].path, cur_dev->path,
|
||||
+ sizeof(blink1_infos[p].path));
|
||||
+ snprintf(blink1_infos[p].serial, sizeof(blink1_infos[p].serial),
|
||||
+ "%ls", cur_dev->serial_number);
|
||||
//wcscpy( blink1_infos[p].serial, cur_dev->serial_number );
|
||||
//uint32_t sn = wcstol( cur_dev->serial_number, NULL, 16);
|
||||
uint32_t serialnum = strtol( blink1_infos[p].serial, NULL, 16);
|
||||
@@ -104,7 +106,7 @@ blink1_device* blink1_openById( uint32_t i )
|
||||
LOG("blink1_openById: %d \n", i );
|
||||
if( i > blink1_max_devices ) { // then i is a serial number not an array index
|
||||
char serialstr[serialstrmax];
|
||||
- sprintf( serialstr, "%X", i); // convert to wchar_t*
|
||||
+ snprintf(serialstr, sizeof(serialstr), "%X", i); // convert to wchar_t*
|
||||
return blink1_openBySerial( serialstr );
|
||||
}
|
||||
else {
|
||||
@@ -189,7 +191,7 @@ char *blink1_error_msg(int errCode)
|
||||
case USBOPEN_ERR_NOTFOUND: return "The specified device was not found";
|
||||
case USBOPEN_ERR_IO: return "Communication error with device";
|
||||
default:
|
||||
- sprintf(buf, "Unknown USB error %d", errCode);
|
||||
+ snprintf(buf, sizeof(buf), "Unknown USB error %d", errCode);
|
||||
return buf;
|
||||
}
|
||||
*/
|
@ -0,0 +1,42 @@
|
||||
$OpenBSD: patch-commandline_blink1-lib-lowlevel-hiddata_h,v 1.1 2015/12/23 10:53:53 bluhm Exp $
|
||||
--- commandline/blink1-lib-lowlevel-hiddata.h.orig Wed Sep 9 03:06:56 2015
|
||||
+++ commandline/blink1-lib-lowlevel-hiddata.h Wed Dec 23 00:00:37 2015
|
||||
@@ -15,7 +15,7 @@ char *blink1_error_msg(int errCode)
|
||||
case USBOPEN_ERR_NOTFOUND: return "The specified device was not found";
|
||||
case USBOPEN_ERR_IO: return "Communication error with device";
|
||||
default:
|
||||
- sprintf(buffer, "Unknown USB error %d", errCode);
|
||||
+ snprintf(buffer, sizeof(buffer), "Unknown USB error %d", errCode);
|
||||
return buffer;
|
||||
}
|
||||
return NULL; /* not reached */
|
||||
@@ -46,8 +46,10 @@ int blink1_enumerateByVidPid(int vid, int pid)
|
||||
if( (cur_dev->vendor_id != 0 && cur_dev->product_id != 0) &&
|
||||
(cur_dev->vendor_id == vid && cur_dev->product_id == pid) ) {
|
||||
if( cur_dev->serial_number != NULL ) { // can happen if not root
|
||||
- strcpy( blink1_infos[p].path, cur_dev->path );
|
||||
- sprintf( blink1_infos[p].serial, "%ls", cur_dev->serial_number);
|
||||
+ strncpy( blink1_infos[p].path, cur_dev->path,
|
||||
+ sizeof(blink1_infos[p].path));
|
||||
+ snprintf(blink1_infos[p].serial, sizeof(blink1_infos[p].serial),
|
||||
+ "%ls", cur_dev->serial_number);
|
||||
//wcscpy( blink1_infos[p].serial, cur_dev->serial_number );
|
||||
//uint32_t sn = wcstol( cur_dev->serial_number, NULL, 16);
|
||||
uint32_t serialnum = strtol( blink1_infos[p].serial, NULL, 16);
|
||||
@@ -136,7 +138,7 @@ blink1_device* blink1_openById( uint32_t i )
|
||||
{
|
||||
if( i > blink1_max_devices ) { // then i is a serial number not array index
|
||||
char serialstr[serialstrmax];
|
||||
- sprintf( serialstr, "%X", i); // convert to wchar_t*
|
||||
+ snprintf(serialstr, sizeof(serialstr), "%X", i); // convert to wchar_t*
|
||||
return blink1_openBySerial( serialstr );
|
||||
}
|
||||
else {
|
||||
@@ -154,6 +156,7 @@ blink1_device* blink1_open(void)
|
||||
LOG("blink1_open\n");
|
||||
if( rc != USBOPEN_SUCCESS ) {
|
||||
LOG("cannot open: \n");
|
||||
+ static_dev = NULL;
|
||||
}
|
||||
return static_dev;
|
||||
}
|
12
misc/blink1/patches/patch-commandline_blink1-lib_c
Normal file
12
misc/blink1/patches/patch-commandline_blink1-lib_c
Normal file
@ -0,0 +1,12 @@
|
||||
$OpenBSD: patch-commandline_blink1-lib_c,v 1.1 2015/12/23 10:53:54 bluhm Exp $
|
||||
--- commandline/blink1-lib.c.orig Wed Sep 9 03:06:56 2015
|
||||
+++ commandline/blink1-lib.c Wed Dec 23 00:00:26 2015
|
||||
@@ -102,7 +102,7 @@ int blink1_getCacheIndexById( uint32_t i )
|
||||
{
|
||||
if( i > blink1_max_devices ) { // then i is a serial number not an array index
|
||||
char serialstr[serialstrmax];
|
||||
- sprintf( serialstr, "%X", i); // convert to wchar_t*
|
||||
+ snprintf(serialstr, sizeof(serialstr), "%X", i); // convert to wchar_t*
|
||||
return blink1_getCacheIndexBySerial( serialstr );
|
||||
}
|
||||
return i;
|
22
misc/blink1/patches/patch-commandline_blink1-tool_c
Normal file
22
misc/blink1/patches/patch-commandline_blink1-tool_c
Normal file
@ -0,0 +1,22 @@
|
||||
$OpenBSD: patch-commandline_blink1-tool_c,v 1.1 2015/12/23 10:53:54 bluhm Exp $
|
||||
--- commandline/blink1-tool.c.orig Wed Sep 9 03:06:56 2015
|
||||
+++ commandline/blink1-tool.c Wed Dec 23 00:00:26 2015
|
||||
@@ -509,7 +509,7 @@ int main(int argc, char** argv)
|
||||
dev = blink1_openById( deviceIds[0] );
|
||||
rc = blink1_getVersion(dev);
|
||||
blink1_close(dev);
|
||||
- sprintf(verbuf, ", fw version: %d", rc);
|
||||
+ snprintf(verbuf, sizeof(verbuf), ", fw version: %d", rc);
|
||||
}
|
||||
msg("blink1-tool version: %s%s\n",BLINK1_VERSION,verbuf);
|
||||
exit(0);
|
||||
@@ -741,7 +741,8 @@ int main(int argc, char** argv)
|
||||
do_rand =1;
|
||||
}
|
||||
char ledstr[16];
|
||||
- sprintf(ledstr, "#%2.2x%2.2x%2.2x", rgbbuf.r,rgbbuf.g,rgbbuf.b);
|
||||
+ snprintf(ledstr, sizeof(ledstr), "#%2.2x%2.2x%2.2x",
|
||||
+ rgbbuf.r,rgbbuf.g,rgbbuf.b);
|
||||
msg("chase effect %d to %d (with %d leds), color %s, ",
|
||||
led_start, led_end, chase_length,
|
||||
((do_rand) ? "random" : ledstr));
|
Loading…
Reference in New Issue
Block a user