Keyboard Shortcuts
Likes
- BITX20
- Messages
Search
Re: Hijacked: C vs C++
I doubt this code:? "strncpy(temp, "12345", 5);"?is storing a null anywhere.
toggle quoted message
Show quoted text
You just happen to have had a handy zero somewhere in RAM to terminate it. And the handy zero may or may not be from the "int val=0;"? . I tried this under Ubuntu with gcc 4.8.4: ################################# #include <stdio.h>
#include <string.h>
char bufa[6];
char z;
char bufb[4];
main() {
? ?strncpy(bufa, "hello", 6);
? ?z = 'Z';
? ?strncpy(bufb, "abcdefgh", 4);
? ?printf("%s %c %s \n", bufa, z, bufb);
}
########################################
That program gives the following output:? ???hello Z abcdhello? ?
Conclusions I draw from this:? ? strncpy() works exactly as documented, it is copying over the 4 letters "abcd" and no terminating null character ? ? bufa[] follows (does not precede!) bufb[] in memory, and z is off somewhere else entirely. The strncpy() function is much safer than strcpy() so long as the bytecount you give it agrees with the buffer size. This is an excellent opportunity to use a #define: #define BUFBSZ? 4 char bufb[BUFBSZ]; ? ?strncpy(bufb, "abcdefgh", BUFBSZ); The fact that reading the string back goes beyond the end of the buffer allocated? is not nearly so dangerous as having an overflow when writing. All bets are off regarding exactly how the compiler is going to allocate RAM. The Arduino IDE is also using gcc, so I'd expect similar results when programming a Nano. Jerry, KE7ER On Thu, Jul 5, 2018 at 06:20 am, Jack Purdum wrote:
|
Re: Nextion display bezel
Gary
toggle quoted message
Show quoted text
I selected PETG. looks great 73 Art N2AJO On Jul 5, 2018, at 8:22 AM, Gary Hanson <grhanson@...> wrote: |
Re: Analog Smeter
#smeter
Thanks for good adress.
?A little bit more expensive than from China (i am not a Prime member). And no shipping to France... Snif... 73 |
Re: Easy, Inexpensive Cooling Fan, Excelway Case
Thanks Mike for highlighting my misunderstanding about how CW is implemented on the uBITX!
I should have reviewed the source code / schematics before posting, pretty obvious when I look at it :) .. the difference between energizing the "TX" and the "CW-KEY" Best Regards, Gary |
Re: Bitx40 75KHz Spurious, How to solve it.
#bitx40
Great work Akira, thanks for the pictures.
toggle quoted message
Show quoted text
Skip Davis, NC9O On Jul 5, 2018, at 05:12, jj1epe@... wrote: |
Re: Completed my QCX
#ubitx
¿ªÔÆÌåÓýJuddGreat job. I added a button also. Easier to access menu. Where did you get your folding kickstand? Art- N2AJO? On Jul 5, 2018, at 8:55 AM, pat griffin <patgriffin@...> wrote:
|
Re: Hijacked: C vs C++
Jack Purdum
That's not necessarily bulletproof, either, but a step in the right direction. Try this: void setup() { ? char temp[5]; ? int val = 0; ? Serial.begin(115200); ? while (!Serial);??????????????? // Necessary on some faster Arduinos, like the Due ? strncpy(temp, "12345", 5); ? Serial.print("temp = "); ? Serial.print(temp); ? Serial.print("# val = "); ? Serial.println(val); } void loop() { } It prints out "12345". The fact that it prints out the entire string means the string termination character is stored...where? The documentation for strncpy() states: ????No null-character is implicitly appended at the end of destination if source is longer than num. Thus, in this case, destination shall not be considered ????a null terminated C string (reading it as such would overflow).
Moral: The strn*() function don't guarantee? protection against buffer overflow. It simply means you're thinking about it. Jack, W8TEE
On Thursday, July 5, 2018, 8:56:00 AM EDT, Brian Bowling <bowlingb@...> wrote:
How about making your programming safer and more robust? ?Strcat() and strcpy() can be found at the root of so many buffer overflows. If you must use them at least use the 'n' versions strncpy() and strncat().? Brian |
Re: Completed my QCX
#ubitx
¿ªÔÆÌåÓýNice job. Also, I see you are using the S meter and v 1.094 firmware as am I. Can you tell me the range in uBitx Manager you are seeing for the s-meter readings and if you are using the AGC circuit? Thanks, Pat AA4PG
Pat Griffin
http://www.cahabatechnology.com/aa4pg.html
From: [email protected] <[email protected]> on behalf of WD8WV <juddie.d.burgess@...>
Sent: Thursday, July 5, 2018 6:27:38 AM To: [email protected] Subject: Re: [BITX20] Completed my QCX #ubitx ?
Updated picture.
I added a momentary button just right if the VFO to access the menu options so I wouldn¡¯t have to push the VFO, which I still can. ?Also added a folding kickstand so when on the bench the front is elevated. -- Judd, WD8WV |
Re: Completed my QCX
#ubitx
Jack Purdum
Very nice! Jack, W8TEE
On Thursday, July 5, 2018, 8:27:52 AM EDT, WD8WV <juddie.d.burgess@...> wrote:
Updated picture. I added a momentary button just right if the VFO to access the menu options so I wouldn¡¯t have to push the VFO, which I still can. ?Also added a folding kickstand so when on the bench the front is elevated. -- Judd, WD8WV |
Re: Analog Smeter
#smeter
Also available from Amazon with 2 day shipping if you are a Prime member:?
|
Re: Completed my QCX
#ubitx
Updated picture.
I added a momentary button just right if the VFO to access the menu options so I wouldn¡¯t have to push the VFO, which I still can. ?Also added a folding kickstand so when on the bench the front is elevated. -- Judd, WD8WV |
Re: Analog Smeter
#smeter
Jean-Luc,
Thanks for sharing your BitX modifications, especially the Analog S meter. I collect D'Arsonval meters and like the retro look for my radios. 73, Bob W4RJP |
Thanks very much for the kind compliments. I hope this project turns out to useful to others on this forum.?
I tried to make it relatively easy to use, and easy for the user to add custom functionally that can offload some work from the uBITX to the backpack. As this is the first release, I hope there are only very minimal hiccups in the code. Tom, wb6b |
BITX QSO Afternoon/Evening, Sunday, July 8, 3PM & 7PM Local Time, 7277 kHz in North America, 7177 kHz elsewhere.
John P
BITX QSO Afternoon/Evening, Sunday, July 8, 3PM & 7PM Local Time, 7277 kHz in North America, 7177 kHz elsewhere.
Join us as we make contacts with our BitX-40s or uBitXs or anything else on 7.277 MHz in 40 meters! This is a worldwide event for BitX40 (and other QRP)?stations starting at 3PM and 7pm in each time zone. To participate, call CQ BitX on Sunday, starting at?3PM and/or 7PM?your local time. The BitX QSO Night continues through the evening and conditions usually improve after sunset, so it is worthwhile to participate later in the evening. Suggested Best Operating Practices: Work at QRP power levels unless conditions require more power. Report your QSO's, discuss propagation, noise, signal reports, audio reports, antenna type, etc. in this thread. This is an undirected, scheduled event.? The BITX QSO Night relies on you to call CQ BITX to initiate contacts with other stations, so warm up that final and transmit a few calls on Sunday evening.? Talk to you then! |